Skip to main content

A Python client library for IT-Decision Telecom messaging API

Project description

IT-Decision Telecom Python SDK

Convenient Python client for IT-Decision Telecom messaging API.

Python package License: MIT

Requirements

  • Sign up for a free IT-Decision Telecom account
  • Request login and password to send SMS messages and access key to send Viber messages
  • Python version 3.8 or higher installed
  • You should have an application written in Python to make use of this SDK

Installation

The easiest way to install the decisiontelecom package is either via pip:

$ pip install decisiontelecom

or manually by downloading the source and run the setup.py script:

$ python setup.py install

Usage

We have put some self-explanatory usage examples in the examples folder, but here is a quick reference on how IT-Decision Telecom clients work. First, you need to import DecisionTelecom module which corresponds to your needs:

from decisiontelecom.sms import SmsClient
from decisiontelecom.viber import ViberClient
from decisiontelecom.viber_plus_sms import ViberPlusSmsClient

Then, create an instance of a required client. Be sure to use real login, password and access key.

sms_client = SmsClient("<YOUR_LOGIN>", "<YOUR_PASSWORD>")
viber_client = ViberClient("<YOUR_ACCESS_KEY>")
viber_plus_sms_client = ViberPlusSmsClient("<YOUR_ACCESS_KEY>")

Now you can use created client to perform needed operations. For example, this is how you can get your SMS balance:

try:
    # Call client get_balance method to get SMS balance information
    balance = sms_client.get_balance()

    # get_balance method should return SMS balance information.
    print("Balance: %f, Credit: %f, Currency: %s" % (balance.balance, balance.credit, balance.currency))
except SmsError as sms_error:
    # sms_error contains specific DecisionTelecom error with the code of what went wrong during the operation
    print("Error while getting balance information. Error code: %d (%s)" % (sms_error.error_code.value, sms_error.error_code))
except Exception as error:
    # A non-DecisionTelecom error occurred during the operation (like connection error)
    print(error)

Error handling

All client methods raise an exception in case if something went wrong during the operation. It might be a general exception in case of connection error or unsuccessful response status code, for example. Or it might be a specific DecisionTelecom error with some details of what went wrong.

SMS client methods might raise SmsError which contains an SMS error code. Viber and Viber plus SMS client methods might raise ViberError which contains some error details like name, message, status and code.

See provided examples on how to handle specific DecisionTelecom exceptions.

SMS errors

SMS client methods return errors in form of the error code. Here are all possible error codes:

  • 40 - Invalid number
  • 41 - Incorrect sender
  • 42 - Invalid message ID
  • 43 - Incorrect JSON
  • 44 - Invalid login or password
  • 45 - User locked
  • 46 - Empty text
  • 47 - Empty login
  • 48 - Empty password
  • 49 - Not enough money to send a message
  • 50 - Authentication error
  • 51 - Invalid phone number

Viber errors

Viber and Viber plus SMS client methods return errors in form of a class with the name, message, code and status properties.

Known Viber errors are:

{
  "name": "Too Many Requests",
  "message": "Rate limit exceeded",
  "code": 0,
  "status": 429
}
{
  "name": "Invalid Parameter: [param_name]",
  "message": "Empty parameter or parameter validation error",
  "code": 1,
  "status": 400
}
{
  "name": "Internal server error",
  "message": "The server encountered an unexpected condition which prevented it from fulfilling the request",
  "code": 2,
  "status": 500
}
{
  "name": "Topup balance is required",
  "message": "User balance is empty",
  "code": 3,
  "status": 402
}

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

decisiontelecom-1.0.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

decisiontelecom-1.0.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file decisiontelecom-1.0.0.tar.gz.

File metadata

  • Download URL: decisiontelecom-1.0.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.1

File hashes

Hashes for decisiontelecom-1.0.0.tar.gz
Algorithm Hash digest
SHA256 26e55e7b9bc1703062dfd1b5c3f57d8319c7c914b52be06e20e3527d5114ec9f
MD5 feb0a320dda17a978b8524d11314afaf
BLAKE2b-256 6d2ad0656766927beaef1a30d4d4036db131174051459b68e4c8a586e48c6768

See more details on using hashes here.

File details

Details for the file decisiontelecom-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: decisiontelecom-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.1

File hashes

Hashes for decisiontelecom-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ace3ce503e089fc9b7afa21135f77d427c9ca834674c6f19abd4751997e3ce2c
MD5 ab81bb557f0dbc9dd4010fa1012f6c49
BLAKE2b-256 9267a5a21e53900767ad1bdef7deb89f966c3700afcd2d22a9993548f12c474b

See more details on using hashes here.

Supported by

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