Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/infobip/oneapi-ruby
oneapi-ruby
https://github.com/infobip/oneapi-ruby
Last synced: 4 days ago
JSON representation
oneapi-ruby
- Host: GitHub
- URL: https://github.com/infobip/oneapi-ruby
- Owner: infobip
- License: apache-2.0
- Created: 2012-08-07T09:26:12.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-11-23T13:20:00.000Z (almost 9 years ago)
- Last Synced: 2024-11-02T12:06:38.714Z (12 days ago)
- Language: Ruby
- Size: 64.5 KB
- Stars: 18
- Watchers: 21
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
OneApi ruby client
============================Basic messaging example
-----------------------First initialize the messaging client using your username and password:
sms_client = OneApi::SmsClient.new(username, password)
An exception will be thrown if your username and/or password are incorrect.
Prepare the message:
sms = OneApi::SMSRequest.new
sms.sender_address = '38598123456'
sms.address = destination_address
sms.message = 'Test message'
sms.callback_data = 'Any string'Send the message:
result = sms_client.send_sms(sms)
# Store the client correlator to be able to query for the delivery status later:
client_correlator = result.client_correlatorLater you can query for the delivery status of the message:
delivery_status = sms_client.query_delivery_status(client_correlator)
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 = OneApi::SMSRequest.new
sms.sender_address = '38598123456'
sms.address = '38598123456'
sms.message = 'Test message'
sms.callback_data = 'Any string'
sms.notify_url = "http://#{local_ip_address}:#{port}"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_info = OneApi::SmsClient.unserialize_delivery_status(body)
Sending message with special characters example
-----------------------If you want to send message with special characters, this is how you prepare your message:
#Create Language object
language = OneApi::Language.new#set specific language code
language.language_code = 'TR'#use single shift table for specific language ('false' or 'true')
language.use_single_shift = true#use locking shift table for specific language ('false' or 'true')
language.use_locking_shift = falsesms = OneApi::SMSRequest.new
sms.sender_address = '38598123456'
sms.address = destination_address
sms.message = 'Some text in Turkish'
sms.callback_data = 'Any string'
sms.language = languageCurrently supported languages (with their language codes) are: `Spanish - "SP"`, `Portuguese - "PT"`, `Turkish - "TR"`.
HLR example
-----------------------Initialize and login the data connection client:
data_connection_client = OneApi::DataConnectionProfileClient.new(username, password)
Retrieve the roaming status (HLR):
result = 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:
data_connection_client.retrieve_roaming_status(destination_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:
delivery_info = OneApi::DataConnectionProfileClient.unserialize_roaming_status(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_messages = 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)