# Puzzel SMS Gateway Python Client <!-- omit in toc -->
[![GitHub License](https://img.shields.io/github/license/PuzzelSolutions/smsgw-client-python?color=blue)](LICENSE)
[![Latest Version](https://img.shields.io/pypi/v/puzzel_sms_gateway_client.svg)](https://pypi.org/project/puzzel_sms_gateway_client/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/puzzel_sms_gateway_client.svg)](https://pypi.python.org/pypi/smsgw-client-python/)
[![Downloads](https://pepy.tech/badge/puzzel_sms_gateway_client)](https://pepy.tech/project/puzzel_sms_gateway_client)
[![Coverage](https://img.shields.io/codecov/c/github/PuzzelSolutions/smsgw-client-python?color=blue)](https://app.codecov.io/gh/PuzzelSolutions/smsgw-client-python)
[![GitHub issues](https://img.shields.io/github/issues-raw/PuzzelSolutions/smsgw-client-python)](https://github.com/PuzzelSolutions/smsgw-client-python/issues)
![GitHub last commit](https://img.shields.io/github/last-commit/PuzzelSolutions/smsgw-client-python)
Copyright 2024 [Puzzel AS](https://www.puzzel.com)\
[_Released under the MIT license_](LICENSE).
Python client for the Puzzel SMS Gateway.
## Contents <!-- omit in toc -->
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Using pip](#using-pip)
- [Using Poetry](#using-poetry)
- [Usage](#usage)
- [Importing as a module](#importing-as-a-module)
- [Using classes directly](#using-classes-directly)
- [Using object instantiation](#using-object-instantiation)
- [Sending message to multiple recipients](#sending-message-to-multiple-recipients)
## Prerequisites
```toml
python = "^3.10.5"
requests = "^2.28.1"
pydantic = "^1.9.1"
fastapi = "^0.78.0"
```
Please see [pyproject.toml](pyproject.toml) for the full citation information.
## Installation
### Using pip
```bash
python -m pip install puzzel_sms_gateway_client
```
### Using Poetry
```bash
poetry add puzzel_sms_gateway_client
```
## Usage
For all the following examples it is recommended to define the following needed variables as secrets in your repository, environment variables or as constants in the script.
### Importing as a module
```python
import puzzel_sms_gateway_client as smsgw
BASE_ADDRESS: str = "https://[YOUR_SERVER_ADDRESS]/gw/rs"
SERVICE_ID: int = [YOUR_SERVICE_ID]
USERNAME: str = "[YOUR_USERNAME]"
PASSWORD: str = "[YOUR_PASSWORD]"
client = smsgw.Client(
service_id=SERVICE_ID,
username=USERNAME,
password=PASSWORD,
base_address=BASE_ADDRESS,
)
response = client.send(
messages=[
smsgw.Message(
recipient="+47xxxxxxxxx", # Country code + phone number
content="Hello World!",
),
]
)
```
### Using classes directly
```python
from puzzel_sms_gateway_client import (
Client,
GasSettings,
Message,
MessageSettings,
OriginatorSettings,
Parameter,
SendWindow,
)
BASE_ADDRESS: str = "https://[YOUR_SERVER_ADDRESS]/gw/rs"
SERVICE_ID: int = [YOUR_SERVICE_ID]
USERNAME: str = "[YOUR_USERNAME]"
PASSWORD: str = "[YOUR_PASSWORD]"
client = Client(
service_id=SERVICE_ID,
username=USERNAME,
password=PASSWORD,
base_address=BASE_ADDRESS,
)
response = client.send(
messages=[
Message(
recipient="+47xxxxxxxxx", # Country code + phone number
content="Hello World!",
settings=MessageSettings( # Optional
send_window=SendWindow(
start_date="2022-07-13",
stop_date="2022-07-13", # Optional
start_time="15:20:00",
stop_time="15:30:00", # Optional
),
),
),
]
)
```
### Using object instantiation
```python
from puzzel_sms_gateway_client import (
Client,
GasSettings,
Message,
MessageSettings,
OriginatorSettings,
Parameter,
SendWindow,
)
BASE_ADDRESS: str = "https://[YOUR_SERVER_ADDRESS]/gw/rs"
SERVICE_ID: int = [YOUR_SERVICE_ID]
USERNAME: str = "[YOUR_USERNAME]"
PASSWORD: str = "[YOUR_PASSWORD]"
gas_settings = GasSettings(
service_code="02001",
description="SMS", # Optional
)
originator_settings = OriginatorSettings(
originator_type="NETWORK",
originator="1960",
)
send_window = SendWindow(
start_date="2022-07-14",
stop_date="2022-07-14", # Optional
start_time="09:20:00",
stop_time="09:30:00", # Optional
)
parameter = Parameter( # All are optional
business_model="contact center",
dcs="F5",
udh="0B0504158200000023AB0201",
pid=65,
flash=True,
parsing_type="AUTO_DETECT",
skip_customer_report_delivery=True,
strex_verification_timeout="10",
strex_merchant_sell_option="pin",
strex_confirm_channel="sms",
strex_authorization_token="some_token",
)
message_settings = MessageSettings( # All are optional
priority=1,
validity=173,
differentiator="sms group 1",
invoice_node="marketing department",
age=18,
new_session=True,
session_id="01bxmt7f8b8h3zkwe2vg",
auto_detect_encoding=True,
safe_remove_non_gsm_characters=True, # Deprecated
originator_settings=originator_settings,
gas_settings=gas_settings,
send_window=send_window,
parameter=parameter,
)
client = Client(
service_id=SERVICE_ID,
username=USERNAME,
password=PASSWORD,
base_address=BASE_ADDRESS,
batch_reference="some_batch_reference", # Optional
)
message = Message(
recipient="+47xxxxxxxxx", # Country code + phone number
content="Hello World!",
price=100, # Optional
client_reference="some_client_reference", # Optional
settings=message_settings, # Optional
)
response = client.send(messages=[message])
```
### Sending message to multiple recipients
```python
import json
from puzzel_sms_gateway_client import (
Client,
Message,
)
BASE_ADDRESS: str = "https://[YOUR_SERVER_ADDRESS]/gw/rs"
SERVICE_ID: int = [YOUR_SERVICE_ID]
USERNAME: str = "[YOUR_USERNAME]"
PASSWORD: str = "[YOUR_PASSWORD]"
recipients = [
"+47xxxxxxxx1", # Country code + phone number
"+47xxxxxxxx2", # Country code + phone number
]
client = Client(
service_id=SERVICE_ID,
username=USERNAME,
password=PASSWORD,
base_address=BASE_ADDRESS,
)
response = client.send(
messages=[
Message(
content="Hello World!",
)
],
recipients=recipients,
)
print(json.dumps(response.json(), indent=4))
```
Output:
```json
{
"batchReference": "60908fdd-6da7-4658-b0f7-5685e513c19f",
"messageStatus": [
{
"statusCode": 1,
"statusMessage": "Message enqueued for sending",
"clientReference": null,
"recipient": "+47xxxxxxxx1",
"messageId": "7a04egxihb00",
"sessionId": null,
"sequenceIndex": 1
},
{
"statusCode": 1,
"statusMessage": "Message enqueued for sending",
"clientReference": null,
"recipient": "+47xxxxxxxx2",
"messageId": "7a04egxihc00",
"sessionId": null,
"sequenceIndex": 2
}
]
}
```
Raw data
{
"_id": null,
"home_page": "https://www.puzzel.com",
"name": "puzzel_sms_gateway_client",
"maintainer": "Lewi Uberg",
"docs_url": null,
"requires_python": ">=3.10.5,<4.0.0",
"maintainer_email": "lewi.uberg@puzzel.com",
"keywords": "puzzel,sms,smsgw,sms-gw,smsapi,sms-api,sms-gateway,sms-gateway-client,gsm",
"author": "Lewi Lie Uberg",
"author_email": "lewi.uberg@puzzel.com",
"download_url": "https://files.pythonhosted.org/packages/da/ea/f2cf325968c68ce3dcacca836bca23005f5c4b9030d5eebd2c9bbdf513d7/puzzel_sms_gateway_client-2.0.2.tar.gz",
"platform": null,
"description": "# Puzzel SMS Gateway Python Client <!-- omit in toc -->\n\n[![GitHub License](https://img.shields.io/github/license/PuzzelSolutions/smsgw-client-python?color=blue)](LICENSE)\n[![Latest Version](https://img.shields.io/pypi/v/puzzel_sms_gateway_client.svg)](https://pypi.org/project/puzzel_sms_gateway_client/)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/puzzel_sms_gateway_client.svg)](https://pypi.python.org/pypi/smsgw-client-python/)\n[![Downloads](https://pepy.tech/badge/puzzel_sms_gateway_client)](https://pepy.tech/project/puzzel_sms_gateway_client)\n[![Coverage](https://img.shields.io/codecov/c/github/PuzzelSolutions/smsgw-client-python?color=blue)](https://app.codecov.io/gh/PuzzelSolutions/smsgw-client-python)\n[![GitHub issues](https://img.shields.io/github/issues-raw/PuzzelSolutions/smsgw-client-python)](https://github.com/PuzzelSolutions/smsgw-client-python/issues)\n![GitHub last commit](https://img.shields.io/github/last-commit/PuzzelSolutions/smsgw-client-python)\n\nCopyright 2024 [Puzzel AS](https://www.puzzel.com)\\\n[_Released under the MIT license_](LICENSE).\n\nPython client for the Puzzel SMS Gateway.\n\n## Contents <!-- omit in toc -->\n\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n - [Using pip](#using-pip)\n - [Using Poetry](#using-poetry)\n- [Usage](#usage)\n - [Importing as a module](#importing-as-a-module)\n - [Using classes directly](#using-classes-directly)\n - [Using object instantiation](#using-object-instantiation)\n - [Sending message to multiple recipients](#sending-message-to-multiple-recipients)\n\n## Prerequisites\n\n```toml\npython = \"^3.10.5\"\nrequests = \"^2.28.1\"\npydantic = \"^1.9.1\"\nfastapi = \"^0.78.0\"\n```\n\nPlease see [pyproject.toml](pyproject.toml) for the full citation information.\n\n## Installation\n\n### Using pip\n\n```bash\npython -m pip install puzzel_sms_gateway_client\n```\n\n### Using Poetry\n\n```bash\npoetry add puzzel_sms_gateway_client\n```\n\n## Usage\n\nFor all the following examples it is recommended to define the following needed variables as secrets in your repository, environment variables or as constants in the script.\n\n### Importing as a module\n\n```python\nimport puzzel_sms_gateway_client as smsgw\n\nBASE_ADDRESS: str = \"https://[YOUR_SERVER_ADDRESS]/gw/rs\"\nSERVICE_ID: int = [YOUR_SERVICE_ID]\nUSERNAME: str = \"[YOUR_USERNAME]\"\nPASSWORD: str = \"[YOUR_PASSWORD]\"\n\n\nclient = smsgw.Client(\n service_id=SERVICE_ID,\n username=USERNAME,\n password=PASSWORD,\n base_address=BASE_ADDRESS,\n)\n\nresponse = client.send(\n messages=[\n smsgw.Message(\n recipient=\"+47xxxxxxxxx\", # Country code + phone number\n content=\"Hello World!\",\n ),\n ]\n)\n```\n\n### Using classes directly\n\n```python\nfrom puzzel_sms_gateway_client import (\n Client,\n GasSettings,\n Message,\n MessageSettings,\n OriginatorSettings,\n Parameter,\n SendWindow,\n)\n\n\nBASE_ADDRESS: str = \"https://[YOUR_SERVER_ADDRESS]/gw/rs\"\nSERVICE_ID: int = [YOUR_SERVICE_ID]\nUSERNAME: str = \"[YOUR_USERNAME]\"\nPASSWORD: str = \"[YOUR_PASSWORD]\"\n\n\nclient = Client(\n service_id=SERVICE_ID,\n username=USERNAME,\n password=PASSWORD,\n base_address=BASE_ADDRESS,\n)\n\nresponse = client.send(\n messages=[\n Message(\n recipient=\"+47xxxxxxxxx\", # Country code + phone number\n content=\"Hello World!\",\n settings=MessageSettings( # Optional\n send_window=SendWindow(\n start_date=\"2022-07-13\",\n stop_date=\"2022-07-13\", # Optional\n start_time=\"15:20:00\",\n stop_time=\"15:30:00\", # Optional\n ),\n ),\n ),\n ]\n)\n```\n\n### Using object instantiation\n\n```python\nfrom puzzel_sms_gateway_client import (\n Client,\n GasSettings,\n Message,\n MessageSettings,\n OriginatorSettings,\n Parameter,\n SendWindow,\n)\n\nBASE_ADDRESS: str = \"https://[YOUR_SERVER_ADDRESS]/gw/rs\"\nSERVICE_ID: int = [YOUR_SERVICE_ID]\nUSERNAME: str = \"[YOUR_USERNAME]\"\nPASSWORD: str = \"[YOUR_PASSWORD]\"\n\ngas_settings = GasSettings(\n service_code=\"02001\",\n description=\"SMS\", # Optional\n)\n\noriginator_settings = OriginatorSettings(\n originator_type=\"NETWORK\",\n originator=\"1960\",\n)\n\nsend_window = SendWindow(\n start_date=\"2022-07-14\",\n stop_date=\"2022-07-14\", # Optional\n start_time=\"09:20:00\",\n stop_time=\"09:30:00\", # Optional\n)\n\nparameter = Parameter( # All are optional\n business_model=\"contact center\",\n dcs=\"F5\",\n udh=\"0B0504158200000023AB0201\",\n pid=65,\n flash=True,\n parsing_type=\"AUTO_DETECT\",\n skip_customer_report_delivery=True,\n strex_verification_timeout=\"10\",\n strex_merchant_sell_option=\"pin\",\n strex_confirm_channel=\"sms\",\n strex_authorization_token=\"some_token\",\n)\n\nmessage_settings = MessageSettings( # All are optional\n priority=1,\n validity=173,\n differentiator=\"sms group 1\",\n invoice_node=\"marketing department\",\n age=18,\n new_session=True,\n session_id=\"01bxmt7f8b8h3zkwe2vg\",\n auto_detect_encoding=True,\n safe_remove_non_gsm_characters=True, # Deprecated\n originator_settings=originator_settings,\n gas_settings=gas_settings,\n send_window=send_window,\n parameter=parameter,\n)\n\n\nclient = Client(\n service_id=SERVICE_ID,\n username=USERNAME,\n password=PASSWORD,\n base_address=BASE_ADDRESS,\n batch_reference=\"some_batch_reference\", # Optional\n)\n\nmessage = Message(\n recipient=\"+47xxxxxxxxx\", # Country code + phone number\n content=\"Hello World!\",\n price=100, # Optional\n client_reference=\"some_client_reference\", # Optional\n settings=message_settings, # Optional\n)\n\nresponse = client.send(messages=[message])\n```\n\n### Sending message to multiple recipients\n\n```python\nimport json\n\nfrom puzzel_sms_gateway_client import (\n Client,\n Message,\n)\n\nBASE_ADDRESS: str = \"https://[YOUR_SERVER_ADDRESS]/gw/rs\"\nSERVICE_ID: int = [YOUR_SERVICE_ID]\nUSERNAME: str = \"[YOUR_USERNAME]\"\nPASSWORD: str = \"[YOUR_PASSWORD]\"\n\nrecipients = [\n \"+47xxxxxxxx1\", # Country code + phone number\n \"+47xxxxxxxx2\", # Country code + phone number\n]\n\n\nclient = Client(\n service_id=SERVICE_ID,\n username=USERNAME,\n password=PASSWORD,\n base_address=BASE_ADDRESS,\n)\n\nresponse = client.send(\n messages=[\n Message(\n content=\"Hello World!\",\n )\n ],\n recipients=recipients,\n)\n\nprint(json.dumps(response.json(), indent=4))\n```\n\nOutput:\n\n```json\n{\n \"batchReference\": \"60908fdd-6da7-4658-b0f7-5685e513c19f\",\n \"messageStatus\": [\n {\n \"statusCode\": 1,\n \"statusMessage\": \"Message enqueued for sending\",\n \"clientReference\": null,\n \"recipient\": \"+47xxxxxxxx1\",\n \"messageId\": \"7a04egxihb00\",\n \"sessionId\": null,\n \"sequenceIndex\": 1\n },\n {\n \"statusCode\": 1,\n \"statusMessage\": \"Message enqueued for sending\",\n \"clientReference\": null,\n \"recipient\": \"+47xxxxxxxx2\",\n \"messageId\": \"7a04egxihc00\",\n \"sessionId\": null,\n \"sequenceIndex\": 2\n }\n ]\n}\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python client for Puzzel SMS Gateway",
"version": "2.0.2",
"project_urls": {
"Documentation": "https://github.com/PuzzelSolutions/SMS",
"Homepage": "https://www.puzzel.com",
"Repository": "https://github.com/PuzzelSolutions/smsgw-client-python"
},
"split_keywords": [
"puzzel",
"sms",
"smsgw",
"sms-gw",
"smsapi",
"sms-api",
"sms-gateway",
"sms-gateway-client",
"gsm"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "85d3566613125aea98f751221a94347de90e0b036c8875143f849f862d7eff81",
"md5": "cfb0dc227b8aee3dd286ca3256e25685",
"sha256": "6287c29614efc85ebc2946515707e00aed876a93caeb9f37c56b50c104533852"
},
"downloads": -1,
"filename": "puzzel_sms_gateway_client-2.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cfb0dc227b8aee3dd286ca3256e25685",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10.5,<4.0.0",
"size": 9465,
"upload_time": "2024-03-06T12:18:22",
"upload_time_iso_8601": "2024-03-06T12:18:22.531453Z",
"url": "https://files.pythonhosted.org/packages/85/d3/566613125aea98f751221a94347de90e0b036c8875143f849f862d7eff81/puzzel_sms_gateway_client-2.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "daeaf2cf325968c68ce3dcacca836bca23005f5c4b9030d5eebd2c9bbdf513d7",
"md5": "4f59d4dd453b3f12ee6cb65b4bf2dee8",
"sha256": "5a9954f23baaea1836f8e20b5dc69a692ca60ae223ad33d23a9e7f173a2a84ef"
},
"downloads": -1,
"filename": "puzzel_sms_gateway_client-2.0.2.tar.gz",
"has_sig": false,
"md5_digest": "4f59d4dd453b3f12ee6cb65b4bf2dee8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10.5,<4.0.0",
"size": 10952,
"upload_time": "2024-03-06T12:18:24",
"upload_time_iso_8601": "2024-03-06T12:18:24.171619Z",
"url": "https://files.pythonhosted.org/packages/da/ea/f2cf325968c68ce3dcacca836bca23005f5c4b9030d5eebd2c9bbdf513d7/puzzel_sms_gateway_client-2.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-06 12:18:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PuzzelSolutions",
"github_project": "SMS",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "puzzel_sms_gateway_client"
}