SDK for Sweetspot Team to interact with backend APIs
Project description
Sweetspot Python SDK
This Python library helps Sweetspot developers interact with their backend APIs to modify shops, merchants, and consumers.
Installation
pip install sweetspot-sdk
Client
The API client can be initialized as follows:
from sweetspot.client import Client
client = Client(
csrf_refresh_token='csrf_refresh_token',
csrf_access_token='csrf_access_token',
access_token_cookie='access_token_cookie',
refresh_token_cookie='refresh_token_cookie',
environment='development')
API calls return an ApiResponse object that includes the following fields:
| Field | Description |
|---|---|
status_code |
Status code of the HTTP response |
reason_phrase |
Reason phrase of the HTTP response |
headers |
Headers of the HTTP response as a dictionary |
text |
The body of the HTTP response as a string |
request |
HTTP request info |
errors |
Errors, if they exist |
body |
The deserialized body of the HTTP response |
cookies |
The deserialized cookies of the HTTP response |
Make Calls with the API Client
from sweetspot.client import Client
client = Client(
csrf_refresh_token='csrf_refresh_token',
csrf_access_token='csrf_access_token',
access_token_cookie='access_token_cookie',
refresh_token_cookie='refresh_token_cookie',
environment='development')
category_result = client.category.get_all_categories()
if category_result.is_success():
categories = category_result.body
Authenticating the API Client
The client must obtain access tokens and cookies in order to call protected endpoints.
from sweetspot.client import Client
client = Client()
login_payload = {
'email':email,
'password':password
}
authentication_result = client.authentication.get_authentication_information(login_payload)
if authentication_result.is_success():
client.update_config(**authentication_result.cookies)
#call protected endpoint
category_result = client.category.get_all_categories()
if category_result.is_success():
categories = category_result.body
Project details
Release history Release notifications | RSS feed
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 sweetspot-sdk-0.1.2.tar.gz.
File metadata
- Download URL: sweetspot-sdk-0.1.2.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
276a6d8ee9c29e599f599c3f205b211ee1c6789130793e8578da58a452af53ff
|
|
| MD5 |
b420bd7dd60317f77a182c48fe8d7e5a
|
|
| BLAKE2b-256 |
b80677a9670570eba2b1aa5375458712e1f3c2cc7ff33e84d774ecf26c71db36
|
File details
Details for the file sweetspot_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: sweetspot_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f8bab50dfd3ccc7d68064758278beb4fa1fd87ca9dfdb0c1cbfa93a3578d023
|
|
| MD5 |
e89b8e3347cb6bd0e51a41784274255c
|
|
| BLAKE2b-256 |
72a8193949040354fe6ccaba912585cee1c821853da180ffc4b55ef5e4af9d0a
|