Skip to main content

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


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.0.7.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sweetspot_sdk-0.0.7-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file sweetspot-sdk-0.0.7.tar.gz.

File metadata

  • Download URL: sweetspot-sdk-0.0.7.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.5

File hashes

Hashes for sweetspot-sdk-0.0.7.tar.gz
Algorithm Hash digest
SHA256 ff115f3b8e9794e0d3b4923c4fc8087288d133bc459bdcf129b3454439bf2916
MD5 6fea6037125e673ff5b0ba702dcba733
BLAKE2b-256 053493d3a72c39426ede9f5d2f5cc9ef5be07b6d6e92dbb0e4c0a24acd42e599

See more details on using hashes here.

File details

Details for the file sweetspot_sdk-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: sweetspot_sdk-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.5

File hashes

Hashes for sweetspot_sdk-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 32b49488b1e8e595549a64f5d64aecdb794bafb07e2c4adb80070e94d1502448
MD5 38aaaba2bfd9cb71a11cff3cb8e56ba2
BLAKE2b-256 2a67957758e64433753d5c104f7a80cba60cd2a098589e1189371a1b485d2cd0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page