sailplay.ru的api客户端

sailpla的Python项目详细描述


api sailplay.ru的python客户端 Build StatusCoveralshttps://pypip.in/d/sailplay/badge.pnghttps://badge.fury.io/py/sailplay.png

文档可在https://sailplay.readthedocs.org/上获得。拉动请求 通过文档增强和/或修复是非常棒的,非常受欢迎。

Requirements

  • python=2.6

Installation

sailplay可以使用pip安装:

pip install sailplay

Usage

Initialize API client

您应该有pin商店部门id商店部门密钥 服务。

from sailplay import SailPlayClient

client = SailPlayClient(pin, store_department_id, store_department_key)

Additional params

client = SailPlayClient(
    pin, store_department_id, store_department_key,
    token="token-here", # Set token manually (default "")
    silence=True,       # Dont fail on API errors (default False)
    loglevel="debug",   # Set log level (default INFO)
)

Get API token

注意

不需要。客户端将在API请求时自动获取令牌。

client.login()
print client.token

Working with api

sailplay有很好且简单的语法。看看:

# Get events list  http://sailplay.ru/api/v2/events/list/
client.api.events.list()

# Create a new user http://sailplay.ru/api/v2/users/add/?...
client.api.users.add(user_phone='...', first_name='...', last_name='...')

# Get info about user http://sailplay.ru/api/v2/users/info/?...
client.api.users.info(user_phone='...')

# Create purchase http://sailplay.ru/api/v2/purchases/new/?...
client.api.purchases.new(**params)

# You also could use getitem syntax for params
client.api.users['custom-vars'](**params)
# Same as
client.api['users']['custom-vars'](**params)

# And etc. I hope you make decision how the client works :)

目前,客户机选择API版本automaticaly。

Context manager

您可以在上下文中重新定义客户端设置:

with client.ctx(silence=True):
    # Errors will not be raised here
    client.api.users.add(user_phone='...', first_name='...', last_name='...')

Raw api request

您可以向sailplay api发出原始请求:

client.request(method='GET', url='/users/info', data={...})

好好编码!

Bug tracker

如果您有任何建议、错误报告或 烦恼请向问题追踪者报告 在https://github.com/klen/sailplay/issues

Contributors

  • klen(基里尔·克莱诺夫)

License

根据BSD license授权。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何加载。java文件到编译器?   java写入文件和I/O   java日历返回错误的当前日期安卓   if语句if变量等于1(java)   java很难让Joda有时间使用我的bukkit插件   json如何创建基于java的应用程序,该应用程序将从网站获取输入   java如何在多页中打印大型JPanel   java my spinner在添加从firebase数据库中选择的多个值时被覆盖   java用Play框架覆盖HTTP方法   试图获取所有用户时,java错误请求400。Dto和表格   java支持bean加载图像后javascript自动调用JS函数   java在MTOM的@StreamingAttachment(Metro)中,Parsely的意思是什么   具有可抢占线程队列的多线程java执行器   Java Opencv connectedComponentsWithStats   java如何向数组中添加2D数组的数目   eclipse为什么我的Java Zork克隆不能正确循环?   java在哪里放置定制的第二个web。xml   java如何更改最近应用列表中显示的快照?   java Browser#getText()返回空字符串