Python client for API sailplay.ru
Docs are available at https://sailplay.readthedocs.org/. Pull requests with documentation enhancements and/or fixes are awesome and most welcome.
Requirements
python >= 2.6
Installation
sailplay could be installed using pip:
pip install sailplay
Usage
Initialize API client
You should have pin, store_department_id and store_department_key from the service.
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
client.login() print client.token
Working with api
Sailplay have nice and easy syntax. Just have a look:
# 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 :)
For now client chooses API version automaticaly.
Context manager
You could redefine the client settings in context:
with client.ctx(silence=True):
# Errors will not be raised here
client.api.users.add(user_phone='...', first_name='...', last_name='...')
Raw api request
You could make raw request to sailplay API:
client.request(method='GET', url='/users/info', data={...})
Have a nice codding!
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/sailplay/issues
Contributing
Development of starter happens at github: https://github.com/klen/sailplay
Contributors
klen (Kirill Klenov)
License
Licensed under a BSD license.
Metadata
Release files for sailplay 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sailplay-0.2.0.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sailplay-0.2.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 11.9 kB
Release files / sailplay-0.2.0.tar.gz
| Download URL | sailplay-0.2.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b62627d55b305e95e893b522a601c71f19ecc7992ffaa451a004bef860fbace2
|
|
BLAKE2b-256 checksum How to use checksums |
cb607534e9f626c2aad2979833de3655be9c078d425dd191e477be131bc80c95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / sailplay-0.2.0-py2.py3-none-any.whl
| Download URL | sailplay-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
bd50842530f1476c63dd69d1882eb9ce416c60ae67a4bc6f78ce183066aeaf92
|
|
BLAKE2b-256 checksum How to use checksums |
a8502764f66c1f935f511d57e28d5a5fc705ebc3520cfc84e42375c15752f0ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |