ruby-transmitsms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +49 -0
- data/LICENSE +22 -0
- data/README.md +62 -0
- data/Rakefile +7 -0
- data/fixtures/vcr_cassettes/account_api_get_balance.yml +49 -0
- data/fixtures/vcr_cassettes/email_sms_api_add_email.yml +49 -0
- data/fixtures/vcr_cassettes/email_sms_api_delete_email.yml +49 -0
- data/fixtures/vcr_cassettes/keywords_api_add_keyword.yml +49 -0
- data/fixtures/vcr_cassettes/keywords_api_edit_keyword.yml +49 -0
- data/fixtures/vcr_cassettes/keywords_api_get_keywords.yml +50 -0
- data/fixtures/vcr_cassettes/lists_api_add_list.yml +49 -0
- data/fixtures/vcr_cassettes/lists_api_add_to_list.yml +50 -0
- data/fixtures/vcr_cassettes/lists_api_delete_from_list.yml +49 -0
- data/fixtures/vcr_cassettes/lists_api_edit_list_member.yml +50 -0
- data/fixtures/vcr_cassettes/lists_api_get_list.yml +60 -0
- data/fixtures/vcr_cassettes/lists_api_get_lists.yml +61 -0
- data/fixtures/vcr_cassettes/lists_api_optout_list_member.yml +49 -0
- data/fixtures/vcr_cassettes/lists_api_remove_list.yml +49 -0
- data/fixtures/vcr_cassettes/numbers_api_get_number.yml +49 -0
- data/fixtures/vcr_cassettes/numbers_api_get_numbers.yml +49 -0
- data/fixtures/vcr_cassettes/numbers_api_lease_number.yml +50 -0
- data/fixtures/vcr_cassettes/resellers_api_add_client.yml +49 -0
- data/fixtures/vcr_cassettes/resellers_api_edit_client.yml +40 -0
- data/fixtures/vcr_cassettes/resellers_api_get_client.yml +50 -0
- data/fixtures/vcr_cassettes/resellers_api_get_clients.yml +59 -0
- data/fixtures/vcr_cassettes/resellers_api_get_transaction.yml +51 -0
- data/fixtures/vcr_cassettes/resellers_api_get_transactions.yml +61 -0
- data/fixtures/vcr_cassettes/sms_api_test_cancel_sms.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_format_number.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_format_number_fail_in_missing_msisdn.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_message_log.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_sms_info.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_sms_info_fail_for_not_existing_message_id.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_sms_responses.yml +53 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_sms_sent.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_get_user_sms_responses.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_message_reply.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_send.yml +49 -0
- data/fixtures/vcr_cassettes/sms_api_test_send_missing_to_and_list_id.yml +50 -0
- data/fixtures/vcr_cassettes/sms_api_test_send_with_list_id.yml +50 -0
- data/geminstall.sh +1 -0
- data/lib/account_api.rb +80 -0
- data/lib/email_api.rb +137 -0
- data/lib/keywords_api.rb +224 -0
- data/lib/lists_api.rb +523 -0
- data/lib/monkey.rb +90 -0
- data/lib/numbers_api.rb +188 -0
- data/lib/resellers_api.rb +379 -0
- data/lib/ruby-transmitsms.rb +16 -0
- data/lib/sms_api.rb +550 -0
- data/lib/swagger.rb +84 -0
- data/lib/swagger/configuration.rb +22 -0
- data/lib/swagger/request.rb +212 -0
- data/lib/swagger/response.rb +70 -0
- data/lib/swagger/version.rb +4 -0
- data/ruby-transmitsms.gemspec +33 -0
- data/runtest.sh +8 -0
- data/setup.sh +1 -0
- data/spec/.resellers_api_spec.rb.swp +0 -0
- data/spec/account_api_spec.rb +30 -0
- data/spec/email_sms_api_spec.rb +40 -0
- data/spec/keywords_api_spec.rb +56 -0
- data/spec/lists_api_spec.rb +117 -0
- data/spec/numbers_api_spec.rb +53 -0
- data/spec/resellers_api_spec.rb +85 -0
- data/spec/sms_api_spec.rb +174 -0
- data/spec/spec.opts +4 -0
- metadata +219 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
require "uri"
|
2
|
+
require "base64"
|
3
|
+
|
4
|
+
require "swagger"
|
5
|
+
require "swagger/configuration"
|
6
|
+
require "swagger/request"
|
7
|
+
require "swagger/response"
|
8
|
+
require "swagger/version"
|
9
|
+
|
10
|
+
require "sms_api"
|
11
|
+
require "numbers_api"
|
12
|
+
require "email_api"
|
13
|
+
require "account_api"
|
14
|
+
require "keywords_api"
|
15
|
+
require "lists_api"
|
16
|
+
require "resellers_api"
|
data/lib/sms_api.rb
ADDED
@@ -0,0 +1,550 @@
|
|
1
|
+
require "uri"
|
2
|
+
|
3
|
+
class SmsApi
|
4
|
+
basePath = "http://api.burst.dev.local/"
|
5
|
+
# apiInvoker = APIInvoker
|
6
|
+
|
7
|
+
def initialize(api_key, api_secret)
|
8
|
+
@api_key = api_key
|
9
|
+
@api_secret = api_secret
|
10
|
+
@sms_api = SmsApi
|
11
|
+
|
12
|
+
@api_key_secret = create_api_key_secret()
|
13
|
+
|
14
|
+
config_swagger()
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_api_key_secret()
|
18
|
+
api_key_secret = Base64.encode64("#{@api_key}:#{@api_secret}")
|
19
|
+
"Basic #{api_key_secret}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def config_swagger()
|
23
|
+
Swagger.configure do |config|
|
24
|
+
config.host = "http://api.burst.dev.local/".gsub("http://", "").gsub("/", "")
|
25
|
+
config.base_path = "/"
|
26
|
+
config.format = "x-www-form-urlencoded"
|
27
|
+
config.camelize_params = false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
# Update an existing sms
|
33
|
+
#
|
34
|
+
# @param id Message ID
|
35
|
+
# @return void
|
36
|
+
def cancel_sms (id = nil, opts={})
|
37
|
+
query_param_keys = [:id]
|
38
|
+
headerParams = {}
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
# set default values and merge with input
|
43
|
+
options = {
|
44
|
+
:'id' => id
|
45
|
+
|
46
|
+
}.merge(opts)
|
47
|
+
|
48
|
+
#resource path
|
49
|
+
path = "/cancel-sms.json".sub('{format}','json')
|
50
|
+
|
51
|
+
# pull querystring keys from options
|
52
|
+
queryopts = options.select do |key,value|
|
53
|
+
query_param_keys.include? key
|
54
|
+
end
|
55
|
+
|
56
|
+
# header parameters
|
57
|
+
headers = {}
|
58
|
+
|
59
|
+
_header_accept = 'application/json'
|
60
|
+
if _header_accept != ''
|
61
|
+
headerParams['Accept'] = _header_accept
|
62
|
+
end
|
63
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
64
|
+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
headers[:'Authorization'] = @api_key_secret
|
69
|
+
|
70
|
+
# http body (model)
|
71
|
+
post_body = nil
|
72
|
+
|
73
|
+
# form parameters
|
74
|
+
form_parameter_hash = {}
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
79
|
+
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
# format-number
|
84
|
+
# Format and validate a given number.
|
85
|
+
# @param msisdn The number to check
|
86
|
+
# @param countrycode 2 Letter countrycode to validate number against
|
87
|
+
# @return void
|
88
|
+
def format_number (msisdn = nil, countrycode = nil, opts={})
|
89
|
+
query_param_keys = [:msisdn,:countrycode]
|
90
|
+
headerParams = {}
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
# set default values and merge with input
|
95
|
+
options = {
|
96
|
+
:'msisdn' => msisdn,
|
97
|
+
:'countrycode' => countrycode
|
98
|
+
|
99
|
+
}.merge(opts)
|
100
|
+
|
101
|
+
#resource path
|
102
|
+
path = "/format-number.json".sub('{format}','json')
|
103
|
+
|
104
|
+
# pull querystring keys from options
|
105
|
+
queryopts = options.select do |key,value|
|
106
|
+
query_param_keys.include? key
|
107
|
+
end
|
108
|
+
|
109
|
+
# header parameters
|
110
|
+
headers = {}
|
111
|
+
|
112
|
+
_header_accept = 'application/json'
|
113
|
+
if _header_accept != ''
|
114
|
+
headerParams['Accept'] = _header_accept
|
115
|
+
end
|
116
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
117
|
+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
headers[:'Authorization'] = @api_key_secret
|
122
|
+
|
123
|
+
# http body (model)
|
124
|
+
post_body = nil
|
125
|
+
|
126
|
+
# form parameters
|
127
|
+
form_parameter_hash = {}
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
132
|
+
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
# get-message-log
|
137
|
+
# Format and validate a given number.
|
138
|
+
# @param message_id The message to retrieve
|
139
|
+
# @param mobile The mobile used in message
|
140
|
+
# @return void
|
141
|
+
def get_message_log (message_id = nil, mobile = nil, opts={})
|
142
|
+
query_param_keys = [:message_id,:mobile]
|
143
|
+
headerParams = {}
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
# set default values and merge with input
|
148
|
+
options = {
|
149
|
+
:'message_id' => message_id,
|
150
|
+
:'mobile' => mobile
|
151
|
+
|
152
|
+
}.merge(opts)
|
153
|
+
|
154
|
+
#resource path
|
155
|
+
path = "/get-message-log.json".sub('{format}','json')
|
156
|
+
|
157
|
+
# pull querystring keys from options
|
158
|
+
queryopts = options.select do |key,value|
|
159
|
+
query_param_keys.include? key
|
160
|
+
end
|
161
|
+
|
162
|
+
# header parameters
|
163
|
+
headers = {}
|
164
|
+
|
165
|
+
_header_accept = 'application/json'
|
166
|
+
if _header_accept != ''
|
167
|
+
headerParams['Accept'] = _header_accept
|
168
|
+
end
|
169
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
170
|
+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
headers[:'Authorization'] = @api_key_secret
|
175
|
+
|
176
|
+
# http body (model)
|
177
|
+
post_body = nil
|
178
|
+
|
179
|
+
# form parameters
|
180
|
+
form_parameter_hash = {}
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
185
|
+
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
# Update an existing sms
|
190
|
+
#
|
191
|
+
# @param message_id Message ID
|
192
|
+
# @param keyword_id Keyword ID
|
193
|
+
# @param keyword Keyword
|
194
|
+
# @param number Filter results by response number
|
195
|
+
# @param msisdn Filter results by a particular mobile number
|
196
|
+
# @param page Page number, for pagination
|
197
|
+
# @param max Maximum results returned per page
|
198
|
+
# @param include_original include text of original message
|
199
|
+
# @return void
|
200
|
+
def get_sms_responses (message_id = nil, keyword_id = nil, keyword = nil, number = nil, msisdn = nil, page = nil, max = nil, include_original = nil, opts={})
|
201
|
+
query_param_keys = [:message_id,:keyword_id,:keyword,:number,:msisdn,:page,:max,:include_original]
|
202
|
+
headerParams = {}
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
# set default values and merge with input
|
207
|
+
options = {
|
208
|
+
:'message_id' => message_id,
|
209
|
+
:'keyword_id' => keyword_id,
|
210
|
+
:'keyword' => keyword,
|
211
|
+
:'number' => number,
|
212
|
+
:'msisdn' => msisdn,
|
213
|
+
:'page' => page,
|
214
|
+
:'max' => max,
|
215
|
+
:'include_original' => include_original
|
216
|
+
|
217
|
+
}.merge(opts)
|
218
|
+
|
219
|
+
#resource path
|
220
|
+
path = "/get-sms-responses.json".sub('{format}','json')
|
221
|
+
|
222
|
+
# pull querystring keys from options
|
223
|
+
queryopts = options.select do |key,value|
|
224
|
+
query_param_keys.include? key
|
225
|
+
end
|
226
|
+
|
227
|
+
# header parameters
|
228
|
+
headers = {}
|
229
|
+
|
230
|
+
_header_accept = 'application/json'
|
231
|
+
if _header_accept != ''
|
232
|
+
headerParams['Accept'] = _header_accept
|
233
|
+
end
|
234
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
235
|
+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
headers[:'Authorization'] = @api_key_secret
|
240
|
+
|
241
|
+
# http body (model)
|
242
|
+
post_body = nil
|
243
|
+
|
244
|
+
# form parameters
|
245
|
+
form_parameter_hash = {}
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
250
|
+
|
251
|
+
|
252
|
+
end
|
253
|
+
|
254
|
+
# Update an existing sms
|
255
|
+
#
|
256
|
+
# @param message_id Message ID's are made up of digits
|
257
|
+
# @param optouts Whether to include optouts. Valid options are: only - only get optouts, omit - do not get optouts, include - get all recipients including optouts (default)
|
258
|
+
# @param page Page number, for pagination
|
259
|
+
# @param max Maximum results returned per page
|
260
|
+
# @param delivery Only show messages with requested delivery status. Valid options are: delivered - only show delivered messages, failed - only show failed messages, pending - only show pending messages
|
261
|
+
# @return void
|
262
|
+
def get_sms_sent (message_id = nil, optouts = nil, page = nil, max = nil, delivery = nil, opts={})
|
263
|
+
query_param_keys = [:message_id,:optouts,:page,:max,:delivery]
|
264
|
+
headerParams = {}
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
# set default values and merge with input
|
269
|
+
options = {
|
270
|
+
:'message_id' => message_id,
|
271
|
+
:'optouts' => optouts,
|
272
|
+
:'page' => page,
|
273
|
+
:'max' => max,
|
274
|
+
:'delivery' => delivery
|
275
|
+
|
276
|
+
}.merge(opts)
|
277
|
+
|
278
|
+
#resource path
|
279
|
+
path = "/get-sms-sent.json".sub('{format}','json')
|
280
|
+
|
281
|
+
# pull querystring keys from options
|
282
|
+
queryopts = options.select do |key,value|
|
283
|
+
query_param_keys.include? key
|
284
|
+
end
|
285
|
+
|
286
|
+
# header parameters
|
287
|
+
headers = {}
|
288
|
+
|
289
|
+
_header_accept = 'application/json'
|
290
|
+
if _header_accept != ''
|
291
|
+
headerParams['Accept'] = _header_accept
|
292
|
+
end
|
293
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
294
|
+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
headers[:'Authorization'] = @api_key_secret
|
299
|
+
|
300
|
+
# http body (model)
|
301
|
+
post_body = nil
|
302
|
+
|
303
|
+
# form parameters
|
304
|
+
form_parameter_hash = {}
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
309
|
+
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
# Update an existing sms
|
314
|
+
#
|
315
|
+
# @param message_id Message ID
|
316
|
+
# @return void
|
317
|
+
def get_sms (message_id = nil, opts={})
|
318
|
+
query_param_keys = [:message_id]
|
319
|
+
headerParams = {}
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
# set default values and merge with input
|
324
|
+
options = {
|
325
|
+
:'message_id' => message_id
|
326
|
+
|
327
|
+
}.merge(opts)
|
328
|
+
|
329
|
+
#resource path
|
330
|
+
path = "/get-sms.json".sub('{format}','json')
|
331
|
+
|
332
|
+
# pull querystring keys from options
|
333
|
+
queryopts = options.select do |key,value|
|
334
|
+
query_param_keys.include? key
|
335
|
+
end
|
336
|
+
|
337
|
+
# header parameters
|
338
|
+
headers = {}
|
339
|
+
|
340
|
+
_header_accept = 'application/json'
|
341
|
+
if _header_accept != ''
|
342
|
+
headerParams['Accept'] = _header_accept
|
343
|
+
end
|
344
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
345
|
+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
headers[:'Authorization'] = @api_key_secret
|
350
|
+
|
351
|
+
# http body (model)
|
352
|
+
post_body = nil
|
353
|
+
|
354
|
+
# form parameters
|
355
|
+
form_parameter_hash = {}
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
360
|
+
|
361
|
+
|
362
|
+
end
|
363
|
+
|
364
|
+
# Update an existing sms
|
365
|
+
#
|
366
|
+
# @param start A timestamp to start the report from
|
367
|
+
# @param enddate A timestamp to end the report at
|
368
|
+
# @param page Page number, for pagination
|
369
|
+
# @param max Maximum results returned per page
|
370
|
+
# @param keywords Filter if keyword responses should be included. Can be: ‘only’ - only keyword responses will be included‘omit’ - only regular campaign responses will be included. ‘both’ - both keyword and campaign responses will be included (default)
|
371
|
+
# @param include_original include text of original message
|
372
|
+
# @return void
|
373
|
+
def get_user_sms_responses (start = nil, enddate = nil, page = nil, max = nil, keywords = nil, include_original = nil, opts={})
|
374
|
+
query_param_keys = [:start,:enddate,:page,:max,:keywords,:include_original]
|
375
|
+
headerParams = {}
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
# set default values and merge with input
|
380
|
+
options = {
|
381
|
+
:'start' => start,
|
382
|
+
:'enddate' => enddate,
|
383
|
+
:'page' => page,
|
384
|
+
:'max' => max,
|
385
|
+
:'keywords' => keywords,
|
386
|
+
:'include_original' => include_original
|
387
|
+
|
388
|
+
}.merge(opts)
|
389
|
+
|
390
|
+
#resource path
|
391
|
+
path = "/get-user-sms-responses.json".sub('{format}','json')
|
392
|
+
|
393
|
+
# pull querystring keys from options
|
394
|
+
queryopts = options.select do |key,value|
|
395
|
+
query_param_keys.include? key
|
396
|
+
end
|
397
|
+
|
398
|
+
# header parameters
|
399
|
+
headers = {}
|
400
|
+
|
401
|
+
_header_accept = 'application/json'
|
402
|
+
if _header_accept != ''
|
403
|
+
headerParams['Accept'] = _header_accept
|
404
|
+
end
|
405
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
406
|
+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
headers[:'Authorization'] = @api_key_secret
|
411
|
+
|
412
|
+
# http body (model)
|
413
|
+
post_body = nil
|
414
|
+
|
415
|
+
# form parameters
|
416
|
+
form_parameter_hash = {}
|
417
|
+
|
418
|
+
|
419
|
+
|
420
|
+
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
421
|
+
|
422
|
+
|
423
|
+
end
|
424
|
+
|
425
|
+
# Reply to a message
|
426
|
+
# message-reply
|
427
|
+
# @param message Message text
|
428
|
+
# @param from Set the alphanumeric Caller ID
|
429
|
+
# @param to Number or set of up to 10,000 numbers to send the SMS to. If your number set has some invalid numbers, they won’t cause validation error, but will be returned as ‘fails’ parameter of the response (see example 3).
|
430
|
+
# @return void
|
431
|
+
def message_reply (message = nil, from = nil, to = nil, opts={})
|
432
|
+
query_param_keys = [:message,:from,:to]
|
433
|
+
headerParams = {}
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
# set default values and merge with input
|
438
|
+
options = {
|
439
|
+
:'message' => message,
|
440
|
+
:'from' => from,
|
441
|
+
:'to' => to
|
442
|
+
|
443
|
+
}.merge(opts)
|
444
|
+
|
445
|
+
#resource path
|
446
|
+
path = "/message-reply.json".sub('{format}','json')
|
447
|
+
|
448
|
+
# pull querystring keys from options
|
449
|
+
queryopts = options.select do |key,value|
|
450
|
+
query_param_keys.include? key
|
451
|
+
end
|
452
|
+
|
453
|
+
# header parameters
|
454
|
+
headers = {}
|
455
|
+
|
456
|
+
_header_accept = 'application/json'
|
457
|
+
if _header_accept != ''
|
458
|
+
headerParams['Accept'] = _header_accept
|
459
|
+
end
|
460
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
461
|
+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
headers[:'Authorization'] = @api_key_secret
|
466
|
+
|
467
|
+
# http body (model)
|
468
|
+
post_body = nil
|
469
|
+
|
470
|
+
# form parameters
|
471
|
+
form_parameter_hash = {}
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
476
|
+
|
477
|
+
|
478
|
+
end
|
479
|
+
|
480
|
+
# Update an existing sms
|
481
|
+
#
|
482
|
+
# @param message Message text
|
483
|
+
# @param to Number or set of up to 10,000 numbers to send the SMS to. If your number set has some invalid numbers, they won’t cause validation error, but will be returned as ‘fails’ parameter of the response (see example 3).
|
484
|
+
# @param from Set the alphanumeric Caller ID
|
485
|
+
# @param send_at A time in the future to send the message
|
486
|
+
# @param list_id This ID is the numerical reference to one of your recipient lists
|
487
|
+
# @param dlr_callback A URL on your system which we can call to notify you of Delivery Receipts. If required, this Parameter can be different for each message sent and will take precedence over the DLR Callback URL supplied by you in the API Settings.
|
488
|
+
# @param reply_callback A URL on your system which we can call to notify you of incoming messages. If required, this parameter can be different and will take precedence over the Reply Callback URL supplied by you on the API Settings.
|
489
|
+
# @param validity Specify the maximum time to attempt to deliver. In minutes, 0 (zero) implies no limit.
|
490
|
+
# @param replies_to_email Specify an email address to send responses to this message. NOTE: specified email must be authorised to send messages via add-email or in your account under the 'Email SMS' section.
|
491
|
+
# @param from_shared Forces sending via the shared number when you have virtual numbers
|
492
|
+
# @param countrycode Formats the numbers given in to as internation format for this 2 letter country code.
|
493
|
+
# @return void
|
494
|
+
def send (message = nil, to = nil, from = nil, send_at = nil, list_id = nil, dlr_callback = nil, reply_callback = nil, validity = nil, replies_to_email = nil, from_shared = nil, countrycode = nil, opts={})
|
495
|
+
query_param_keys = [:message,:to,:from,:send_at,:list_id,:dlr_callback,:reply_callback,:validity,:replies_to_email,:from_shared,:countrycode]
|
496
|
+
headerParams = {}
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
# set default values and merge with input
|
501
|
+
options = {
|
502
|
+
:'message' => message,
|
503
|
+
:'to' => to,
|
504
|
+
:'from' => from,
|
505
|
+
:'send_at' => send_at,
|
506
|
+
:'list_id' => list_id,
|
507
|
+
:'dlr_callback' => dlr_callback,
|
508
|
+
:'reply_callback' => reply_callback,
|
509
|
+
:'validity' => validity,
|
510
|
+
:'replies_to_email' => replies_to_email,
|
511
|
+
:'from_shared' => from_shared,
|
512
|
+
:'countrycode' => countrycode
|
513
|
+
|
514
|
+
}.merge(opts)
|
515
|
+
|
516
|
+
#resource path
|
517
|
+
path = "/send-sms.json".sub('{format}','json')
|
518
|
+
|
519
|
+
# pull querystring keys from options
|
520
|
+
queryopts = options.select do |key,value|
|
521
|
+
query_param_keys.include? key
|
522
|
+
end
|
523
|
+
|
524
|
+
# header parameters
|
525
|
+
headers = {}
|
526
|
+
|
527
|
+
_header_accept = 'application/json'
|
528
|
+
if _header_accept != ''
|
529
|
+
headerParams['Accept'] = _header_accept
|
530
|
+
end
|
531
|
+
_header_content_type = ['application/x-www-form-urlencoded']
|
532
|
+
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
533
|
+
|
534
|
+
|
535
|
+
|
536
|
+
headers[:'Authorization'] = @api_key_secret
|
537
|
+
|
538
|
+
# http body (model)
|
539
|
+
post_body = nil
|
540
|
+
|
541
|
+
# form parameters
|
542
|
+
form_parameter_hash = {}
|
543
|
+
|
544
|
+
|
545
|
+
|
546
|
+
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
547
|
+
|
548
|
+
|
549
|
+
end
|
550
|
+
end
|