Yandex GO for Business SDK
Project description
Yandex Go for Business SDK (Python)
Officially supported Python client for Yandex Go for Business
Documentation: https://taxi__business-api.docs-viewer.yandex.ru/ru/
Quickstart
Prerequisites
- Python 3.8 or higher
pipversion 9.0.1 or higher
If necessary, upgrade your version of pip:
$ python -m pip install --upgrade pip
If you cannot upgrade pip due to a system-owned installation, you can
run the example in a virtualenv:
$ python -m pip install virtualenv
$ virtualenv venv
$ source venv/bin/activate
$ python -m pip install --upgrade pip
Install Yandex Go for Business SDK:
$ python -m pip install yandex_b2b_go
Getting started
Your requests are authorized via an OAuth token.
client = yandex_b2b_go.Client(token='y2_...')
Or you can use context manager
async with yandex_b2b_go.Client(token='y2_...') as client:
pass
Get user list
Example method for get users list.
import yandex_b2b_go
TOKEN = 'y2_...'
client = yandex_b2b_go.Client(token=TOKEN)
user_manager = yandex_b2b_go.UserManager(client=client)
users = await user_manager.list(limit=20, cursor='djEgMTY2M...MGM3OTE=')
This method return class UserListResponse
Get user create
Example method for user create.
import yandex_b2b_go
TOKEN = 'y2_...'
client = yandex_b2b_go.Client(token=TOKEN)
user_manager = yandex_b2b_go.UserManager(client=client)
user = yandex_b2b_go.typing.User(
fullname='Иванов Илья',
phone='+79990000000',
is_active=True,
)
response = await user_manager.create(user=user)
This method return class UserCreateResponse
Class Client have parameters
timeout- the time in seconds to limit the execution of the requestlog_level- the logging level for a specific method. Defaultlogging.INFOlog_request- whether to log the entire request. DefaultFalselog_response- whether to log the entire response. DefaultFalse
Example
Set log_level = WARNING and log_request = True
import logging
import yandex_b2b_go
TOKEN = 'y2_...'
client = yandex_b2b_go.Client(token=TOKEN, log_level=logging.WARNING, log_request=True)
user_manager = yandex_b2b_go.UserManager(client=client)
users = await user_manager.list(limit=1)
Output:
2024-09-17 16:20:03,166 WARNING Request=GET, for url=https://b2b-api.go.yandex.ru/integration/2.0/users?limit=1, params={'limit': '1'}, body=None
2024-09-17 16:20:03,814 WARNING GET request https://b2b-api.go.yandex.ru/integration/2.0/users success with status code 200
Set log_response = True
import yandex_b2b_go
TOKEN = 'y2_...'
client = yandex_b2b_go.Client(token=TOKEN, log_response=True)
user_manager = yandex_b2b_go.UserManager(client=client)
users = await user_manager.list(limit=1)
Output:
2024-09-17 16:22:22,995 INFO Performing GET request to https://b2b-api.go.yandex.ru/integration/2.0/users
2024-09-17 16:22:23,276 INFO GET request https://b2b-api.go.yandex.ru/integration/2.0/users success with status code 200, body={'items': [{'fullname': 'Иванов Илья', 'is_active': True, 'phone': '+79990000000', 'id': '0516587…..c5a8adb58', 'is_deleted': False, 'cost_center': '', 'department_id': '9080a2……208a1856', 'email': 'email1@email.ru', 'limits': [{'limit_id': 'e31cc52437...', 'service': 'eats2'}, {'limit_id': '4afef98...', 'service': 'drive'}, {'limit_id': '20569bb9d...', 'service': 'taxi'}], 'nickname': 'id1234572', 'client_id': '1f300a6…..edf867021c'}], 'limit': 1, 'total_amount': 20, 'next_cursor': 'djEgMTY2NjA3OTAN….GM4MTgwMDFlNTAzYjg3NTQ='}
Contributing
Dependencies
Use make deps command to install library, its production and development dependencies.
Formatting
Use make format to autoformat code with black tool.
Tests
make testto run tests for current python versionmake lintto run only linters for current python version
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yandex_b2b_go-1.0.4.tar.gz.
File metadata
- Download URL: yandex_b2b_go-1.0.4.tar.gz
- Upload date:
- Size: 95.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73ff6f94fd7e3ddce95f84d7a447f59f70143aae75cfbbee3c50ee17f0648518
|
|
| MD5 |
c84c183ec50dfd82ca8882efb6d9d206
|
|
| BLAKE2b-256 |
ebecdf0d758390034173be6aec18ca689de8b64b5449110441e50901f5427fe6
|
File details
Details for the file yandex_b2b_go-1.0.4-py3-none-any.whl.
File metadata
- Download URL: yandex_b2b_go-1.0.4-py3-none-any.whl
- Upload date:
- Size: 36.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e512f7b21e98ee86557e706e086ec351ab1c012e6635bb6465442d3c20b1efc7
|
|
| MD5 |
2adc97066b9dd753f1d965f3690cd0f5
|
|
| BLAKE2b-256 |
471b1d848ce893e02a09e2125b31ad818624238a07c97b853c297180c2566b4b
|