Suprsend library for Python
Project description
suprsend-py-sdk
This package can be included in a python3 project to easily integrate
with Suprsend
platform.
We're working towards creating SDK in other languages as well.
Suprsend SDKs available in following languages
- python3 >= 3.7 (
suprsend-py-sdk
)
Installation
suprsend-py-sdk
is available on PyPI. You can install using pip.
pip cache purge && pip install suprsend-py-sdk
Usage
Initialize the Suprsend SDK
from suprsend import Suprsend
# Initialize SDK
supr_client = Suprsend("env_key", "env_secret")
Following example shows a sample request for triggering a workflow.
It triggers a notification to a user with id: distinct_id
,
email: user@example.com
& androidpush-token: __android_push_token__
using template purchase-made
and notification_category system
# Prepare Workflow body
workflow_body = {
"name": "Purchase Workflow",
"template": "purchase-made",
"notification_category": "system",
"delay": "15m",
"users": [
{
"distinct_id": "0f988f74-6982-41c5-8752-facb6911fb08",
"$email": ["user@example.com"],
"$androidpush": ["__android_push_token__"],
}
],
"data": {
"template": {
"first_name": "User",
"spend_amount": "$10"
},
"$attachments": [
{
"filename": "billing.pdf",
"contentType": "application/pdf",
"data": "Q29uZ3JhdHVsYXRpb25zLCB5b3UgY2FuIGJhc2U2NCBkZWNvZGUh",
}
],
}
}
# Trigger workflow
supr_client.trigger_workflow(workflow_body)
Add attachments
To add one or more Attachments to a Notification (viz. Email, Whatsapp),
call supr_client.add_attachment(...)
for each file.
Ensure that file_path is proper, otherwise it will raise FileNotFoundError.
# this snippet can be used to add attachment to workflow_body.
file_path = "/home/user/billing.pdf"
supr_client.add_attachment(workflow_body, file_path)
Attachment structure
The add_attachment(...)
call appends below structure to data->'$attachments'
{
"filename": "billing.pdf",
"contentType": "application/pdf",
"data": "Q29uZ3JhdHVsYXRpb25zLCB5b3UgY2FuIGJhc2U2NCBkZWNvZGUh",
}
Where
filename
- name of file.contentType
- MIME-type of file content.data
- base64-encoded content of file.
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
File details
Details for the file suprsend-py-sdk-0.0.12.tar.gz
.
File metadata
- Download URL: suprsend-py-sdk-0.0.12.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cabce834973b7ec5d4de4304094b0754c84a5b9cf28c089403c7537e0dababf |
|
MD5 | f0965fd8009fe9a7d8b4e8979c8475b9 |
|
BLAKE2b-256 | c2921a9530c95ae08b1021b1aa6434dbb3ad1459b1adbd6a3cecaeea2abdc806 |
File details
Details for the file suprsend_py_sdk-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: suprsend_py_sdk-0.0.12-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20e2aad9cafafacb690b3ab9d9e6f0f921bb0f2d119a11a3337104503c3f0305 |
|
MD5 | 9a29b8dec921cee1aaecf044cac9c347 |
|
BLAKE2b-256 | c87cdadb25850a64675464b855aafe997744ed5d75f9888049be9c1f5f606bec |