https://github.com/infobip/oneapi-python
oneapi-python
https://github.com/infobip/oneapi-python
Last synced: 9 months ago
JSON representation
oneapi-python
- Host: GitHub
- URL: https://github.com/infobip/oneapi-python
- Owner: infobip
- License: apache-2.0
- Created: 2012-07-27T13:36:14.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2016-09-08T20:23:12.000Z (over 9 years ago)
- Last Synced: 2025-04-13T05:18:36.478Z (9 months ago)
- Language: Python
- Size: 424 KB
- Stars: 12
- Watchers: 15
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
OneApi python client
============================
Basic messaging example
-----------------------
First initialize the messaging client using your username and password:
sms_client = oneapi.SmsClient(username, password)
An exception will be thrown if your username and/or password are incorrect.
Prepare the message:
sms = models.SMSRequest()
sms.sender_address = address
sms.address = address
sms.message = 'Test message'
sms.callback_data = 'Any string'
Send the message:
result = sms_client.send_sms(sms)
# store client correlator because we can later query for the delivery status with it:
client_correlator = result.client_correlator
Later you can query for the delivery status of the message:
query_status = sms_client.query_delivery_status(client_correlator)
delivery_status = query_status.delivery_info[0].delivery_status
Possible statuses are: **DeliveredToTerminal**, **DeliveryUncertain**, **DeliveryImpossible**, **MessageWaiting** and **DeliveredToNetwork**.
Messaging with notification push example
-----------------------
Same as with the standard messaging example, but when preparing your message:
sms = models.SMSRequest()
sms.sender_address = address
sms.address = address
sms.message = 'Test message'
# The url where the delivery notification will be pushed:
sms.notify_url = notify_url
When the delivery notification is pushed to your server as a HTTP POST request, you must process the body of the message with the following code:
delivery_status = oneapi.SmsClient.unserialize_delivery_status(http_body)
HLR example
-----------------------
Initialize and login the data connection client:
data_connection_client = oneapi.DataConnectionProfileClient(username, password)
Retrieve the roaming status (HLR):
response = data_connection_client.retrieve_roaming_status(destination_address)
HLR with notification push example
-----------------------
Similar to the previous example, but this time you must set the notification url where the result will be pushed:
response = data_connection_client.retrieve_roaming_status(address, notify_url)
When the roaming status notification is pushed to your server as a HTTP POST request, you must process the body of the message with the following code:
roaming_status = oneapi.DataConnectionProfileClient.unserialize_roaming_status(http_body)
Retrieve inbound messages example
-----------------------
With the existing sms client (see the basic messaging example to see how to start it):
result = sms_client.retrieve_inbound_messages()
Inbound message push example
-----------------------
The subscription to recive inbound messages can be set up on our site.
When the inbound message notification is pushed to your server as a HTTP POST request, you must process the body of the message with the following code:
inbound_message = oneapi.SmsClient.unserialize_inbound_messages(http_body)
License
-------
This library is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)