slybroadcast 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +60 -2
- data/lib/slybroadcast.rb +1 -0
- data/lib/slybroadcast/client.rb +29 -51
- data/lib/slybroadcast/parsers/audio_file_list_response.rb +6 -8
- data/lib/slybroadcast/utilities.rb +31 -0
- data/lib/slybroadcast/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f8f6a8747476a80dcbbe3868654a7c08fc34acf
|
|
4
|
+
data.tar.gz: ad2eb126702586e1edbe0c78913a885a08f61bc2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06decec7fae6e1a8bd101b6e2037eef0aa4d974ebb17fb8bbb4ddf1e30f36f7d8c9450817ca1b09d339dee0a2a55d5ea253c11fb39c516fb2781d119fb563b7b
|
|
7
|
+
data.tar.gz: 535a79a120af68b410b9d2f59df5ab646b6d4f77e598402a2a2707109a46b4d4b5b066a9bcb40423c307e7a0094ddd93dab354b356d44c3d395a1e6509186937
|
data/README.md
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
slybroadcast
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
-
A minimal Slybroadcast Ruby client implementation
|
|
4
|
+
A minimal Slybroadcast Ruby client implementation. Based on Slybroadcast API Version 2.1
|
|
5
|
+
|
|
6
|
+
See slybroadcast.com for information about this product.
|
|
5
7
|
|
|
6
8
|
Usage
|
|
7
9
|
-----------
|
|
8
10
|
|
|
9
11
|
``` ruby
|
|
10
12
|
|
|
11
|
-
require '
|
|
13
|
+
require 'slybroadcast'
|
|
12
14
|
Slybroadcast::Client.credentials = { c_uid: 'example@email.com', c_password: 'xxx' }
|
|
13
15
|
|
|
14
16
|
```
|
|
15
17
|
|
|
18
|
+
or
|
|
19
|
+
|
|
20
|
+
``` ruby
|
|
21
|
+
|
|
22
|
+
Slybroadcast::Client.verify({ c_uid: 'user@example.com', c_password: 'secret' })
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
|
|
16
26
|
### Verify Username and Password
|
|
17
27
|
|
|
18
28
|
To verify your slybroadcast Username and Password.
|
|
@@ -32,6 +42,25 @@ false
|
|
|
32
42
|
|
|
33
43
|
### Send a Campaign
|
|
34
44
|
|
|
45
|
+
Posibles Params
|
|
46
|
+
|
|
47
|
+
Param name | Definition | Example
|
|
48
|
+
------------ | ------------- | -----------
|
|
49
|
+
*c_uid* | Your Email Address | value="admin@mobile-sphere.com"
|
|
50
|
+
*c_password* | Your Password | value="12345678"
|
|
51
|
+
*c_url* | URL for audio file if recorded elsewhere | value="http://www.yoursite.com/wav"
|
|
52
|
+
*c_audio* | Audio file type (WAV or Mp3) | value="WAV"
|
|
53
|
+
*c_record_audio* | Audio file name if recorded through the Slybroadcast Recording Center | name="MeetupRecording1"
|
|
54
|
+
*c_phone* | Destination phone numbers | MAX: 10,000 per submission | value="6173999980,6173999981"
|
|
55
|
+
*session_id* | Session/Campaign ID | value="9123456789"
|
|
56
|
+
*c_callerID* | Caller ID of campaign | value="6173999980"
|
|
57
|
+
*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"
|
|
58
|
+
*mobile_only* | Campaign sent to mobile numbers only | value="1"
|
|
59
|
+
*c_endtime* | End Time for campaign (EST) HH:MM:SS | Must use military time format value="17:59:59"
|
|
60
|
+
*c_sys_audio_name* | Use ONLY if sending the system file name of your audio file | value="r18904b140407197964.wav"
|
|
61
|
+
*c_dispo_url* | URL that will receive call status post backs | value=https://www.yoursite.com/results"
|
|
62
|
+
|
|
63
|
+
|
|
35
64
|
Campaign submission with audio file previously uploaded.
|
|
36
65
|
|
|
37
66
|
``` ruby
|
|
@@ -89,6 +118,35 @@ result.error
|
|
|
89
118
|
|
|
90
119
|
```
|
|
91
120
|
|
|
121
|
+
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.
|
|
122
|
+
|
|
123
|
+
Example: *c_dispo_url* = "https://www.yoursite.com/results"
|
|
124
|
+
|
|
125
|
+
If *c_dispo_url* is provided, each call status is sent back using POST
|
|
126
|
+
and you can use Slybroadcast::Utilities.callback_parser to parse this
|
|
127
|
+
POST
|
|
128
|
+
|
|
129
|
+
Posible response :
|
|
130
|
+
|
|
131
|
+
session_id, phone_number, status, failure_reason, delivery_time, carrier
|
|
132
|
+
|
|
133
|
+
Example
|
|
134
|
+
|
|
135
|
+
``` ruby
|
|
136
|
+
|
|
137
|
+
Slybroadcast::Utilities.callback_parser(body) do |session_id, phone_number, status, failure_reason, delivery_time, carrier|
|
|
138
|
+
{
|
|
139
|
+
session_id: session_id,
|
|
140
|
+
phone_number: phone_number,
|
|
141
|
+
status: status,
|
|
142
|
+
failure_reason: failure_reason,
|
|
143
|
+
delivery_time: delivery_time,
|
|
144
|
+
carrier: carrier
|
|
145
|
+
}
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
|
|
92
150
|
### Pause Campaign
|
|
93
151
|
|
|
94
152
|
To temporarily pause a campaign or session, but not cancel it.
|
data/lib/slybroadcast.rb
CHANGED
data/lib/slybroadcast/client.rb
CHANGED
|
@@ -29,9 +29,7 @@ module Slybroadcast
|
|
|
29
29
|
ENDPOINTS = {
|
|
30
30
|
verify: 'vmb.php',
|
|
31
31
|
campaign_call_status: 'vmb.php',
|
|
32
|
-
|
|
33
|
-
campaign_resume: 'vmb.php',
|
|
34
|
-
campaign_cancel: 'vmb.php',
|
|
32
|
+
campaign: 'vmb.php',
|
|
35
33
|
account_message_balance: 'vmb.php',
|
|
36
34
|
download_audio_file: 'vmb.dla.php',
|
|
37
35
|
list_audio_files: 'vmb.aflist.php'
|
|
@@ -47,86 +45,66 @@ module Slybroadcast
|
|
|
47
45
|
|
|
48
46
|
def verify(**options)
|
|
49
47
|
params = set_credentials(options.merge(c_option: :user_verify))
|
|
50
|
-
res =
|
|
51
|
-
endpoint_url,
|
|
52
|
-
set_credentials(options.merge(c_option: :user_verify))
|
|
53
|
-
)
|
|
48
|
+
res = make_post(endpoint_url, params)
|
|
54
49
|
raise Exceptions::InvalidCredentials, 'Invalid `c_uid` or `c_password`' unless res.body.eql?("OK")
|
|
55
50
|
true
|
|
56
51
|
end
|
|
57
52
|
|
|
58
53
|
def campaign_call_status(**options)
|
|
59
54
|
params = set_credentials(options)
|
|
55
|
+
res = make_post(endpoint_url, params)
|
|
56
|
+
parse_response(:CampaignStatusResponse, res)
|
|
57
|
+
end
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
result = Parsers::CampaignStatusResponse.new(res.body)
|
|
66
|
-
result.success? ? result : handle_error(result.error)
|
|
59
|
+
def campaign(**options)
|
|
60
|
+
params = set_credentials(options)
|
|
61
|
+
res = make_post(endpoint_url, params)
|
|
62
|
+
parse_response(:CampaignActionsResponse, res)
|
|
67
63
|
end
|
|
68
64
|
|
|
69
65
|
def campaign_pause(**options)
|
|
70
|
-
|
|
71
|
-
res = Net::HTTP.post_form(
|
|
72
|
-
endpoint_url,
|
|
73
|
-
params
|
|
74
|
-
)
|
|
75
|
-
result = Parsers::CampaignActionsResponse.new(res.body)
|
|
76
|
-
result.success? ? result : handle_error(result.error)
|
|
66
|
+
campaign(options.merge(c_option: :pause))
|
|
77
67
|
end
|
|
78
68
|
|
|
79
69
|
def campaign_resume(**options)
|
|
80
|
-
|
|
81
|
-
res = Net::HTTP.post_form(
|
|
82
|
-
endpoint_url,
|
|
83
|
-
params
|
|
84
|
-
)
|
|
85
|
-
result = Parsers::CampaignActionsResponse.new(res.body)
|
|
86
|
-
result.success? ? result : handle_error(result.error)
|
|
70
|
+
campaign(options.merge(c_option: :run))
|
|
87
71
|
end
|
|
88
72
|
|
|
89
73
|
def campaign_cancel(**options)
|
|
90
|
-
|
|
91
|
-
res = Net::HTTP.post_form(
|
|
92
|
-
endpoint_url,
|
|
93
|
-
params
|
|
94
|
-
)
|
|
95
|
-
result = Parsers::CampaignActionsResponse.new(res.body)
|
|
96
|
-
result.success? ? result : handle_error(result.error)
|
|
74
|
+
campaign(options.merge(c_option: :stop))
|
|
97
75
|
end
|
|
98
76
|
|
|
99
77
|
def account_message_balance
|
|
100
78
|
params = set_credentials(remain_message: '1')
|
|
101
|
-
res =
|
|
102
|
-
|
|
103
|
-
params
|
|
104
|
-
)
|
|
105
|
-
result = Parsers::RemainingMessagesResponse.new(res.body)
|
|
106
|
-
result.success? ? result : handle_error(result.error)
|
|
79
|
+
res = make_post(endpoint_url, params)
|
|
80
|
+
parse_response(:RemainingMessagesResponse, res)
|
|
107
81
|
end
|
|
108
82
|
|
|
109
83
|
def download_audio_file(**options)
|
|
110
84
|
params = set_credentials(options)
|
|
111
|
-
res =
|
|
112
|
-
|
|
113
|
-
params
|
|
114
|
-
)
|
|
115
|
-
result = Parsers::RemainingMessagesResponse.new(res.body)
|
|
116
|
-
result.success? ? result : handle_error(result.error)
|
|
85
|
+
res = make_post(endpoint_url, params)
|
|
86
|
+
parse_response(:RemainingMessagesResponse, res)
|
|
117
87
|
end
|
|
118
88
|
|
|
119
89
|
def list_audio_files
|
|
120
90
|
params = set_credentials(c_method: 'get_audio_list')
|
|
121
|
-
res =
|
|
122
|
-
|
|
91
|
+
res = make_post(endpoint_url, params)
|
|
92
|
+
parse_response(:AudioFileListResponse, res)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
|
|
97
|
+
def make_post(url, params)
|
|
98
|
+
Net::HTTP.post_form(
|
|
99
|
+
url,
|
|
123
100
|
params
|
|
124
101
|
)
|
|
125
|
-
result = Parsers::AudioFileListResponse.new(res.body)
|
|
126
|
-
result.success? ? result : handle_error(result.error)
|
|
127
102
|
end
|
|
128
103
|
|
|
129
|
-
|
|
104
|
+
def parse_response(parser, response)
|
|
105
|
+
result = Parsers.const_get(parser).new(response.body)
|
|
106
|
+
result.success? ? result : handle_error(result.error)
|
|
107
|
+
end
|
|
130
108
|
|
|
131
109
|
def endpoint_url
|
|
132
110
|
method = caller_locations(1,1).first.label.to_sym
|
|
@@ -4,8 +4,6 @@ module Parsers
|
|
|
4
4
|
attr_accessor :error
|
|
5
5
|
attr_accessor :list
|
|
6
6
|
|
|
7
|
-
FIELDS = [:system_file_name, :audio_file_name, :created].freeze
|
|
8
|
-
|
|
9
7
|
def initialize(body)
|
|
10
8
|
@list = []
|
|
11
9
|
response_parse(body)
|
|
@@ -27,12 +25,12 @@ module Parsers
|
|
|
27
25
|
@error = response[1].strip unless success
|
|
28
26
|
|
|
29
27
|
@list = response.map do |line|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
system_file_name, audio_file_name, created = line.delete('\\"').split("|",3)
|
|
29
|
+
{
|
|
30
|
+
system_file_name: system_file_name,
|
|
31
|
+
audio_file_name: audio_file_name,
|
|
32
|
+
created: created
|
|
33
|
+
}
|
|
36
34
|
end
|
|
37
35
|
end
|
|
38
36
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Slybroadcast
|
|
2
|
+
module Utilities
|
|
3
|
+
extend self
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# Usage
|
|
7
|
+
#
|
|
8
|
+
# Slybroadcast::Utilities.callback_parser(body) do |session_id, phone_number, status, failure_reason, delivery_time, carrier|
|
|
9
|
+
# {
|
|
10
|
+
# session_id: session_id,
|
|
11
|
+
# phone_number: phone_number,
|
|
12
|
+
# status: status,
|
|
13
|
+
# failure_reason: failure_reason,
|
|
14
|
+
# delivery_time: delivery_time,
|
|
15
|
+
# carrier: carrier
|
|
16
|
+
# }
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
def callback_parser(body)
|
|
20
|
+
response = body.split("\n")
|
|
21
|
+
response.map do |line|
|
|
22
|
+
line.delete!('\\"')
|
|
23
|
+
cols = line.split("|",6)
|
|
24
|
+
cols.compact!
|
|
25
|
+
cols.insert(3,nil) if cols.size == 5
|
|
26
|
+
yield *cols
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/slybroadcast/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slybroadcast
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Aceto
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-05-
|
|
11
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A minimal Slybroadcast Ruby client implementation
|
|
14
14
|
email:
|
|
@@ -29,6 +29,7 @@ files:
|
|
|
29
29
|
- lib/slybroadcast/parsers/campaign_status_response.rb
|
|
30
30
|
- lib/slybroadcast/parsers/download_audio_file_response.rb
|
|
31
31
|
- lib/slybroadcast/parsers/remaining_messages_response.rb
|
|
32
|
+
- lib/slybroadcast/utilities.rb
|
|
32
33
|
- lib/slybroadcast/version.rb
|
|
33
34
|
- slybroadcast.gemspec
|
|
34
35
|
- test/client.rb
|