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 JNA调用与带有字节[]的java JNA调用的行为不同   java基于键列表获取子映射   重启后永久增加java堆大小?   JavaHTTPS服务器:相互SSL身份验证   java为什么接受接口的方法会拒绝该接口的实现?   片段中的java视图无法应用于()   ms access Java SQL更新命令不工作   java将web服务自动打包和部署到Oracle Application Server 10g   java有没有办法在安卓 studio中为安卓时钟设置多个警报?   位于FTP服务器上的文件上的Java校验和md5   在Java中创建类时遇到问题。有些方法不太确定   java错误:在类chrome\u驱动程序中找不到主方法   通用海图(Javascript\Java)