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
sweetspot-sdk-0.1.3.tar.gz
(12.2 kB
view hashes)
Built Distribution
Close
Hashes for sweetspot_sdk-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0be58ba07f2f1763e766289c6d178af98bdf7b7a6c2e9dd48e0fc187ace3ae6c |
|
MD5 | cbe462212b7cfbd034718b222cda209a |
|
BLAKE2b-256 | c5480e82c683e9a7363a5a9a080ba338d7efcd41b96443494d03fc95dbb03ecc |