Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maceto/slybroadcast
A minimal Slybroadcast Ruby client implementation
https://github.com/maceto/slybroadcast
client ruby slybroadcast
Last synced: 25 days ago
JSON representation
A minimal Slybroadcast Ruby client implementation
- Host: GitHub
- URL: https://github.com/maceto/slybroadcast
- Owner: maceto
- License: mit
- Created: 2017-04-27T20:21:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-12T21:41:07.000Z (over 7 years ago)
- Last Synced: 2024-08-09T12:19:22.594Z (3 months ago)
- Topics: client, ruby, slybroadcast
- Language: Ruby
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
slybroadcast
=========A minimal Slybroadcast Ruby client implementation. Based on Slybroadcast API Version 2.1
See slybroadcast.com for information about this product.
Usage
-----------``` ruby
require 'slybroadcast'
Slybroadcast::Client.credentials = { c_uid: '[email protected]', c_password: 'xxx' }```
or
``` ruby
Slybroadcast::Client.verify({ c_uid: '[email protected]', c_password: 'secret' })
```
### Verify Username and Password
To verify your slybroadcast Username and Password.
``` ruby
Slybroadcast::Client.credentials = { c_uid: '[email protected]', c_password: 'xxx' }
result = Slybroadcast::Client.verifyresult.success?
trueresult.failed?
false```
### Send a Campaign
Posibles Params
Param name | Definition | Example
------------ | ------------- | -----------
*c_uid* | Your Email Address | value="[email protected]"
*c_password* | Your Password | value="12345678"
*c_url* | URL for audio file if recorded elsewhere | value="http://www.yoursite.com/wav"
*c_audio* | Audio file type (WAV or Mp3) | value="WAV"
*c_record_audio* | Audio file name if recorded through the Slybroadcast Recording Center | name="MeetupRecording1"
*c_phone* | Destination phone numbers | MAX: 10,000 per submission | value="6173999980,6173999981"
*session_id* | Session/Campaign ID | value="9123456789"
*c_callerID* | Caller ID of campaign | value="6173999980"
*c_date* | Date/Time of delivery (EST) YYYY-MM-DD HH:MM:SS Must use military time format | value="2015-12-31 15:00:00" value="now"
*mobile_only* | Campaign sent to mobile numbers only | value="1"
*c_endtime* | End Time for campaign (EST) HH:MM:SS | Must use military time format value="17:59:59"
*c_sys_audio_name* | Use ONLY if sending the system file name of your audio file | value="r18904b140407197964.wav"
*c_dispo_url* | URL that will receive call status post backs | value=https://www.yoursite.com/results"Campaign submission with audio file previously uploaded.
``` ruby
result = Slybroadcast::Client.campaign_call(
c_phone: "+16173999981, +16173999982, +16173999983",
c_record_audio: "Meetup1",
c_callerID: "+16173999980",
c_date: "now",
mobile_only: "1"
)result.success?
trueresult.session_id
1234567788result.failed?
falseresult.error
"Bad Audio, can't download"```
Campaign submission using a client's audio file.
``` ruby
result = Slybroadcast::Client.campaign_call(
c_phone: "+16173999981, +16173999982, +16173999983",
c_url: "https://user_audio_url",
c_callerID: "+16173999980",
c_date: "now",
mobile_only: "1",
c_audio: "mp3"
)result.success?
trueresult.session_id
1234567788result.failed?
falseresult.error
"Bad Audio, can't download"```
To receive a status of each call, MobileSphere uses webhook. The POST HTTP Form method is used. Clients should provide a URL to which each call status data can be posted automatically. This is optional.
Example: *c_dispo_url* = "https://www.yoursite.com/results"
If *c_dispo_url* is provided, each call status is sent back using POST
and you can use Slybroadcast::Utilities.callback_parser to parse this
POSTPosible response :
session_id, phone_number, status, failure_reason, delivery_time, carrier
Example
``` ruby
example_body = "9996130985|9996449444|OK||2017-05-11 17:38:18|verizon wireless:6006 - svr/2"
Slybroadcast::Utilities.callback_parser(example_body) do |session_id, phone_number, status, failure_reason, delivery_time, carrier|
{
session_id: session_id,
phone_number: phone_number,
status: status,
failure_reason: failure_reason,
delivery_time: delivery_time,
carrier: carrier
}
end```
### Request Status Campaign
To request the call status of one phone number, the following parameters must be included. Be sure the session_id is the one received in response to your initial campaign submission.
``` ruby
result = Slybroadcast::Client.campaign_status(
session_id: "123456",
c_phone: "9996449444"
)result.success?
trueresult.call
{
:session_id=>"123456",
:phone_number=>"9996449444",
:status=>"OK",
:failure_reason=>"",
:delivery_time=>"2017-05-11 17:38:18",
:carrier=>"verizon wireless:6006 - svr/2"
}```
### Pause Campaign
To temporarily pause a campaign or session, but not cancel it.
``` ruby
result = Slybroadcast::Client.campaign_pause(session_id: "6045428032")
result.success?
trueresult.session_id
1234567788result.failed?
falseresult.error
"already finished"```
### Resume Campaign
To resume a campaign.
``` ruby
result = Slybroadcast::Client.campaign_resume(session_id: "6045428032")
result.success?
trueresult.session_id
1234567788result.failed?
falseresult.error
"already finished"```
### Cancel Campaign
To cancel a campaign.
``` ruby
result = Slybroadcast::Client.campaign_cancel(session_id: "6045428032")
result.success?
trueresult.session_id
1234567788result.failed?
falseresult.error
"already finished"```
### Request Account Message Balance
To request the number of remaining messages in your account.
``` ruby
result = Slybroadcast::Client.account_message_balance
result.success?
trueresult.remaining_messages
"12345"result.pending_messages
"123"result.failed?
false```
### Retrieve a List of all Audio Files
To view a full list of your audio files.
``` ruby
result = Slybroadcast::Client.list_audio_files
result.success?
trueresult.list
[
{:system_file_name=>"170425242023265.wav", :audio_file_name=>"123456", :created=>"2017-04-25 22:42:25"},
{:system_file_name=>"294b755.wav", :audio_file_name=>"recording20160425-31049-1mq2hk7", :created=>"2017-05-03 20:39:11"},
{:system_file_name=>"15213094.wav", :audio_file_name=>"Test01", :created=>"2017-05-03 20:38:16"}
]result.failed?
false```