Package: websms
websmsPython library that allows to send messages using websms platform.Based onsms_plusserverpackage.Installationpip install websmsUsageIn order to use this library users need to have an account on
websms platform (https://websms.com/).Quick startwebsmsprovides module-level convenience functions to make sending messages easier:fromwebsmsimportconfigure,send_sms# Configure service:configure(username='user',password='pass')# Send a message:send_sms(recipients_address_list=['+4911122233344'],message_content='Hello!')Configurationconfigurefunction allows to set all configuration options. These options
will be used by other functions / classes of the module by default.fromwebsmsimportconfigureconfigure(# Your websms credentials (required):username='user',password='pass',# Optional parameters:sender_address='Foo',# SMS sender address or namesender_address_type='alphanumeric',# SMS sender address formatmax_sms_per_message=3,# Maximum number of messages for a long SMStimeout=60# Default timeout for service API calls)Sending messagesThe easiest way to send a message is to callsend_smsfunction:>>>fromwebsmsimportsend_sms>>>send_sms(['+4911122233344'],'Hello!')'006214b5440071843da1'# Transfer ID - unique message identifierUser can provide a custom sender name or number insender_addressparameter:send_sms(recipients_address_list=['+4911122233344'],message_content='Hello!',sender_address='+4955544433300',sender_address_type='international')In order to test SMS service without sending actual message, user can settestparameter toTrue:send_sms(recipients_address_list=['+4911122233344'],message_content='Hello!',test=True)All API calls are made using HTTP requests to websms web API. User can
specify network timeout for each request:send_sms(recipients_address_list=['+4911122233344'],message_content='Hello!',timeout=30)To silence exceptions raised due to network errors or errors returned from
provider's API, user can setfail_silentlyparameter toTrue:send_sms(recipients_address_list=['+4911122233344'],message_content='Hello!',fail_silently=True)In this case,send_smsfunction will returnNonewhen error occurs.Using Object-Oriented APIAll functions ofwebsmspackage can be accessed using object-oriented
API -SMSclass:>>>fromwebsmsimportSMS>>>sms=SMS(['+4911122233344'],'Hello!')>>>sms.send()'006214b5440071843da1'All parameters available in module-level functions are also valid for
methods ofSMSclass:>>>fromwebsmsimportSMS>>>sms=SMS(['+4911122233344'],'Hello!')>>>sms.send(fail_silently=True)'006214b5440071843da1'Multiple configurationswebserversupports global and local configurations.
By default, module level functions and classes use global configuration
(webserver.default_service) which can be altered usingconfigurefunction.
To create independent configurations' user can create new instance ofSMSServiceclass and pass it to module-level functions or methods ofSMSclass
asserviceparameter:>>>fromwebsmsimportSMS,SMSService>>>service=SMSService(username='user',password='password')>>>sms=SMS(['+4911122233344'],'Hello!')>>>sms.send(service=service)'006214b5440071843da1'SMS Response objectsAll technical parameters returned by websms API calls, can be inspected
by usingpost_responseandstate_responseattributes ofSMSobjects.Exceptionswebsmscalls may raise the following exceptions:ConfigurationError: Service is improperly configured.CommunicationError: Unable to communicate to APIRequestError: API responded with an errorRequirementsPython 3.6+