Package: decisiontelecom
IT-Decision Telecom Python SDKConvenient Python client for IT-Decision Telecom messaging API.RequirementsSign upfor a free IT-Decision Telecom accountRequest login and password to send SMS messages and access key to send Viber messagesPython version 3.8 or higher installedYou should have an application written in Python to make use of this SDKInstallationThe easiest way to install the decisiontelecom package is either via pip:$ pip install decisiontelecomor manually by downloading the source and run the setup.py script:$ python setup.py installUsageWe have put some self-explanatory usage examples in theexamplesfolder,
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:fromdecisiontelecom.smsimportSmsClientfromdecisiontelecom.viberimportViberClientfromdecisiontelecom.viber_plus_smsimportViberPlusSmsClientThen, 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 informationbalance=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))exceptSmsErrorassms_error:# sms_error contains specific DecisionTelecom error with the code of what went wrong during the operationprint("Error while getting balance information. Error code:%d(%s)"%(sms_error.error_code.value,sms_error.error_code))exceptExceptionaserror:# A non-DecisionTelecom error occurred during the operation (like connection error)print(error)Error handlingAll 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 raiseSmsErrorwhich contains an SMS error code.
Viber and Viber plus SMS client methods might raiseViberErrorwhich contains some error details like name, message, status and code.See provided examples on how to handle specific DecisionTelecom exceptions.SMS errorsSMS client methods return errors in form of the error code. Here are all possible error codes:40 - Invalid number41 - Incorrect sender42 - Invalid message ID43 - Incorrect JSON44 - Invalid login or password45 - User locked46 - Empty text47 - Empty login48 - Empty password49 - Not enough money to send a message50 - Authentication error51 - Invalid phone numberViber errorsViber and Viber plus SMS client methods return errors in form of a class with thename,message,codeandstatusproperties.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}