plivo 0.3.1 → 0.3.4
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 +7 -0
- data/README.md +3 -1
- data/lib/plivo.rb +665 -661
- metadata +29 -22
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: fd4f31bca07333c3cf77f6bd7aa1b988de85024b
|
|
4
|
+
data.tar.gz: 53061907e16f4ba4d74f4c2234b847bd350ede43
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 752ed143859ba4e7463b3be6feb44d216f95b89cbc29c8516f6ce953990fe1083c545e2b4decf2e54da3dff291d79866234f0518bb099243180a16760bd01241
|
|
7
|
+
data.tar.gz: d5249f4ae0ad9ca35b1572818798c38e2828b0173f3d9d5cd58b31493a5387c37e798e445e5d07eb7d6f81242a4766c893e37e9c633cc93d0df5d5a9bd99ef87
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Plivo Ruby Library
|
|
2
2
|
---------------------------
|
|
3
3
|
|
|
4
|
+
[](http://badge.fury.io/rb/plivo)
|
|
5
|
+
|
|
4
6
|
Description
|
|
5
7
|
~~~~~~~~~~~
|
|
6
8
|
|
|
@@ -29,7 +31,7 @@ Requirements
|
|
|
29
31
|
~~~~~~~~~~~~
|
|
30
32
|
gem "rest-client", "~> 1.6.7"
|
|
31
33
|
gem "json", "~> 1.6.6"
|
|
32
|
-
|
|
34
|
+
gem "htmlentities", "~> 4.3.1"
|
|
33
35
|
|
|
34
36
|
Usage
|
|
35
37
|
~~~~~
|
data/lib/plivo.rb
CHANGED
|
@@ -2,750 +2,754 @@ require 'rubygems'
|
|
|
2
2
|
require 'restclient'
|
|
3
3
|
require 'json'
|
|
4
4
|
require 'rexml/document'
|
|
5
|
+
require 'htmlentities'
|
|
5
6
|
|
|
6
7
|
module Plivo
|
|
7
8
|
class PlivoError < Exception
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
class RestAPI
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
12
|
+
attr_accessor :auth_id, :auth_token, :url, :version, :api, :headers, :rest
|
|
13
|
+
|
|
14
|
+
def initialize(auth_id, auth_token, url="https://api.plivo.com", version="v1")
|
|
15
|
+
@auth_id = auth_id
|
|
16
|
+
@auth_token = auth_token
|
|
17
|
+
@url = url.chomp('/')
|
|
18
|
+
@version = version
|
|
19
|
+
@api = @url + '/' + @version + '/Account/' + @auth_id
|
|
20
|
+
@headers = {"User-Agent" => "RubyPlivo"}
|
|
21
|
+
@rest = RestClient::Resource.new(@api, @auth_id, @auth_token)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def hash_to_params(myhash)
|
|
25
|
+
return myhash.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join("&")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def request(method, path, params=nil)
|
|
29
|
+
coder = HTMLEntities.new(:html4)
|
|
30
|
+
params.each{ |key,value| value.replace(coder.encode(value, :decimal)) }
|
|
31
|
+
if method == "POST"
|
|
32
|
+
if not params
|
|
33
|
+
params = {}
|
|
34
|
+
end
|
|
35
|
+
begin
|
|
36
|
+
r = @rest[path].post params.to_json, :content_type => 'application/json'
|
|
37
|
+
rescue => e
|
|
38
|
+
response = e
|
|
39
|
+
end
|
|
40
|
+
if not response
|
|
41
|
+
code = r.code
|
|
42
|
+
raw = r.to_str
|
|
43
|
+
response = JSON.parse(raw)
|
|
44
|
+
end
|
|
45
|
+
return [code, response]
|
|
46
|
+
elsif method == "GET"
|
|
47
|
+
if params
|
|
48
|
+
path = path + '?' + hash_to_params(params)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
begin
|
|
52
|
+
r = @rest[path].get
|
|
53
|
+
rescue => e
|
|
54
|
+
response = e
|
|
55
|
+
end
|
|
56
|
+
if not response
|
|
57
|
+
code = r.code
|
|
58
|
+
raw = r.to_str
|
|
59
|
+
response = JSON.parse(raw)
|
|
60
|
+
end
|
|
61
|
+
return [code, response]
|
|
62
|
+
elsif method == "DELETE"
|
|
63
|
+
if params
|
|
64
|
+
path = path + '?' + hash_to_params(params)
|
|
65
|
+
end
|
|
66
|
+
begin
|
|
67
|
+
r = @rest[path].delete
|
|
68
|
+
rescue => e
|
|
69
|
+
response = e
|
|
70
|
+
end
|
|
71
|
+
if not response
|
|
72
|
+
code = r.code
|
|
73
|
+
end
|
|
74
|
+
return [code, ""]
|
|
75
|
+
end
|
|
76
|
+
return [405, 'Method Not Supported']
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
## Accounts ##
|
|
80
|
+
def get_account(params={})
|
|
81
|
+
return request('GET', "/", params)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def modify_account(params={})
|
|
85
|
+
return request('POST', "/", params)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def get_subaccounts(params={})
|
|
89
|
+
return request('GET', "/Subaccount/", params)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def create_subaccount(params={})
|
|
93
|
+
return request('POST', "/Subaccount/", params)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def get_subaccount(params={})
|
|
97
|
+
subauth_id = params.delete("subauth_id")
|
|
98
|
+
return request('GET', "/Subaccount/#{subauth_id}/", params)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def modify_subaccount(params={})
|
|
102
|
+
subauth_id = params.delete("subauth_id")
|
|
103
|
+
return request('POST', "/Subaccount/#{subauth_id}/", params)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def delete_subaccount(params={})
|
|
107
|
+
subauth_id = params.delete("subauth_id")
|
|
108
|
+
return request('DELETE', "/Subaccount/#{subauth_id}/", params)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
## Applications ##
|
|
112
|
+
def get_applications(params={})
|
|
113
|
+
return request('GET', "/Application/", params)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def create_application(params={})
|
|
117
|
+
return request('POST', "/Application/", params)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def get_application(params={})
|
|
121
|
+
app_id = params.delete("app_id")
|
|
122
|
+
return request('GET', "/Application/#{app_id}/", params)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def modify_application(params={})
|
|
126
|
+
app_id = params.delete("app_id")
|
|
127
|
+
return request('POST', "/Application/#{app_id}/", params)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def delete_application(params={})
|
|
131
|
+
app_id = params.delete("app_id")
|
|
132
|
+
return request('DELETE', "/Application/#{app_id}/", params)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
## Numbers ##
|
|
136
|
+
def get_numbers(params={})
|
|
137
|
+
return request('GET', "/Number/", params)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def search_numbers(params={})
|
|
141
|
+
return request('GET', "/AvailableNumber/", params)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def get_number(params={})
|
|
145
|
+
number = params.delete("number")
|
|
146
|
+
return request('GET', "/Number/#{number}/", params)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def rent_number(params={})
|
|
150
|
+
number = params.delete("number")
|
|
151
|
+
return request('POST', "/AvailableNumber/#{number}/", params)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def unrent_number(params={})
|
|
155
|
+
number = params.delete("number")
|
|
156
|
+
return request('DELETE', "/Number/#{number}/", params)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def link_application_number(params={})
|
|
160
|
+
number = params.delete("number")
|
|
161
|
+
return request('POST', "/Number/#{number}/", params)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def unlink_application_number(params={})
|
|
165
|
+
number = params.delete("number")
|
|
166
|
+
params = {"app_id" => ""}
|
|
167
|
+
return request('POST', "/Number/#{number}/", params)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def get_number_group(params={})
|
|
171
|
+
return request('GET', "/AvailableNumberGroup/", params)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def get_number_group_details(params={})
|
|
175
|
+
group_id = params.delete('group_id')
|
|
176
|
+
return request('GET', "/AvailableNumberGroup/#{group_id}/", params)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def rent_from_number_group(params={})
|
|
180
|
+
group_id = params.delete('group_id')
|
|
181
|
+
return request('POST', "/AvailableNumberGroup/#{group_id}/", params)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
## Calls ##
|
|
185
|
+
def get_cdrs(params={})
|
|
186
|
+
return request('GET', "/Call/", params)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def get_cdr(params={})
|
|
190
|
+
record_id = params.delete('record_id')
|
|
191
|
+
return request('GET', "/Call/#{record_id}/", params)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def get_live_calls(params={})
|
|
195
|
+
params["status"] = "live"
|
|
196
|
+
return request('GET', "/Call/", params)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def get_live_call(params={})
|
|
200
|
+
call_uuid = params.delete('call_uuid')
|
|
201
|
+
params["status"] = "live"
|
|
202
|
+
return request('GET', "/Call/#{call_uuid}/", params)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def make_call(params={})
|
|
206
|
+
return request('POST', "/Call/", params)
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def hangup_all_calls(params={})
|
|
210
|
+
return request('DELETE', "/Call/", params)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def transfer_call(params={})
|
|
214
|
+
call_uuid = params.delete('call_uuid')
|
|
215
|
+
return request('POST', "/Call/#{call_uuid}/", params)
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def hangup_call(params={})
|
|
219
|
+
call_uuid = params.delete('call_uuid')
|
|
220
|
+
return request('DELETE', "/Call/#{call_uuid}/", params)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def record(params={})
|
|
224
|
+
call_uuid = params.delete('call_uuid')
|
|
225
|
+
return request('POST', "/Call/#{call_uuid}/Record/", params)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def stop_record(params={})
|
|
229
|
+
call_uuid = params.delete('call_uuid')
|
|
230
|
+
return request('DELETE', "/Call/#{call_uuid}/Record/", params)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
def play(params={})
|
|
234
|
+
call_uuid = params.delete('call_uuid')
|
|
235
|
+
return request('POST', "/Call/#{call_uuid}/Play/", params)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def stop_play(params={})
|
|
239
|
+
call_uuid = params.delete('call_uuid')
|
|
240
|
+
return request('DELETE', "/Call/#{call_uuid}/Play/", params)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def speak(params={})
|
|
244
|
+
call_uuid = params.delete('call_uuid')
|
|
245
|
+
return request('POST', "/Call/#{call_uuid}/Speak/", params)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def send_digits(params={})
|
|
249
|
+
call_uuid = params.delete('call_uuid')
|
|
250
|
+
return request('POST', "/Call/#{call_uuid}/DTMF/", params)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
## Calls requests ##
|
|
254
|
+
def hangup_request(params={})
|
|
255
|
+
request_uuid = params.delete('request_uuid')
|
|
256
|
+
return request('DELETE', "/Request/#{request_uuid}/", params)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
## Conferences ##
|
|
260
|
+
def get_live_conferences(params={})
|
|
261
|
+
return request('GET', "/Conference/", params)
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def hangup_all_conferences(params={})
|
|
265
|
+
return request('DELETE', "/Conference/", params)
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def get_live_conference(params={})
|
|
269
|
+
conference_name = params.delete('conference_name')
|
|
270
|
+
return request('GET', "/Conference/#{conference_name}/", params)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
def hangup_conference(params={})
|
|
274
|
+
conference_name = params.delete('conference_name')
|
|
275
|
+
return request('DELETE', "/Conference/#{conference_name}/", params)
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def hangup_member(params={})
|
|
279
|
+
conference_name = params.delete('conference_name')
|
|
280
|
+
member_id = params.delete('member_id')
|
|
281
|
+
return request('DELETE', "/Conference/#{conference_name}/Member/#{member_id}/", params)
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def play_member(params={})
|
|
285
|
+
conference_name = params.delete('conference_name')
|
|
286
|
+
member_id = params.delete('member_id')
|
|
287
|
+
return request('POST', "/Conference/#{conference_name}/Member/#{member_id}/Play/", params)
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def stop_play_member(params={})
|
|
291
|
+
conference_name = params.delete('conference_name')
|
|
292
|
+
member_id = params.delete('member_id')
|
|
293
|
+
return request('DELETE', "/Conference/#{conference_name}/Member/#{member_id}/Play/", params)
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def speak_member(params={})
|
|
297
|
+
conference_name = params.delete('conference_name')
|
|
298
|
+
member_id = params.delete('member_id')
|
|
299
|
+
return request('POST', "/Conference/#{conference_name}/Member/#{member_id}/Speak/", params)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def deaf_member(params={})
|
|
303
|
+
conference_name = params.delete('conference_name')
|
|
304
|
+
member_id = params.delete('member_id')
|
|
305
|
+
return request('POST', "/Conference/#{conference_name}/Member/#{member_id}/Deaf/", params)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def undeaf_member(params={})
|
|
309
|
+
conference_name = params.delete('conference_name')
|
|
310
|
+
member_id = params.delete('member_id')
|
|
311
|
+
return request('DELETE', "/Conference/#{conference_name}/Member/#{member_id}/Deaf/", params)
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def mute_member(params={})
|
|
315
|
+
conference_name = params.delete('conference_name')
|
|
316
|
+
member_id = params.delete('member_id')
|
|
317
|
+
return request('POST', "/Conference/#{conference_name}/Member/#{member_id}/Mute/", params)
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def unmute_member(params={})
|
|
321
|
+
conference_name = params.delete('conference_name')
|
|
322
|
+
member_id = params.delete('member_id')
|
|
323
|
+
return request('DELETE', "/Conference/#{conference_name}/Member/#{member_id}/Mute/", params)
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
def kick_member(params={})
|
|
327
|
+
conference_name = params.delete('conference_name')
|
|
328
|
+
member_id = params.delete('member_id')
|
|
329
|
+
return request('POST', "/Conference/#{conference_name}/Member/#{member_id}/Kick/", params)
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def record_conference(params={})
|
|
333
|
+
conference_name = params.delete('conference_name')
|
|
334
|
+
return request('POST', "/Conference/#{conference_name}/Record/", params)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
def stop_record_conference(params={})
|
|
338
|
+
conference_name = params.delete('conference_name')
|
|
339
|
+
return request('DELETE', "/Conference/#{conference_name}/Record/", params)
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
## Recordings ##
|
|
343
|
+
def get_recordings(params={})
|
|
344
|
+
return request('GET', "/Recording/", params)
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
def get_recording(params={})
|
|
348
|
+
recording_id = params.delete('recording_id')
|
|
349
|
+
return request('GET', "/Recording/#{recording_id}/", params)
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
## Endpoints ##
|
|
353
|
+
def get_endpoints(params={})
|
|
354
|
+
return request('GET', "/Endpoint/", params)
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
def create_endpoint(params={})
|
|
358
|
+
return request('POST', "/Endpoint/", params)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def get_endpoint(params={})
|
|
362
|
+
endpoint_id = params.delete('endpoint_id')
|
|
363
|
+
return request('GET', "/Endpoint/#{endpoint_id}/", params)
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
def modify_endpoint(params={})
|
|
367
|
+
endpoint_id = params.delete('endpoint_id')
|
|
368
|
+
return request('POST', "/Endpoint/#{endpoint_id}/", params)
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def delete_endpoint(params={})
|
|
372
|
+
endpoint_id = params.delete('endpoint_id')
|
|
373
|
+
return request('DELETE', "/Endpoint/#{endpoint_id}/", params)
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
## Incoming Carriers ##
|
|
377
|
+
def get_incoming_carriers(params={})
|
|
378
|
+
return request('GET', "/IncomingCarrier/", params)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def create_incoming_carrier(params={})
|
|
382
|
+
return request('POST', "/IncomingCarrier/", params)
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
def get_incoming_carrier(params={})
|
|
386
|
+
carrier_id = params.delete('carrier_id')
|
|
387
|
+
return request('GET', "/IncomingCarrier/#{carrier_id}/", params)
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def modify_incoming_carrier(params={})
|
|
391
|
+
carrier_id = params.delete('carrier_id')
|
|
392
|
+
return request('POST', "/IncomingCarrier/#{carrier_id}/", params)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
def delete_incoming_carrier(params={})
|
|
396
|
+
carrier_id = params.delete('carrier_id')
|
|
397
|
+
return request('DELETE', "/IncomingCarrier/#{carrier_id}/", params)
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
## Outgoing Carriers ##
|
|
401
|
+
def get_outgoing_carriers(params={})
|
|
402
|
+
return request('GET', "/OutgoingCarrier/", params)
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def create_outgoing_carrier(params={})
|
|
406
|
+
return request('POST', "/OutgoingCarrier/", params)
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
def get_outgoing_carrier(params={})
|
|
410
|
+
carrier_id = params.delete('carrier_id')
|
|
411
|
+
return request('GET', "/OutgoingCarrier/#{carrier_id}/", params)
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
def modify_outgoing_carrier(params={})
|
|
415
|
+
carrier_id = params.delete('carrier_id')
|
|
416
|
+
return request('POST', "/OutgoingCarrier/#{carrier_id}/", params)
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
def delete_outgoing_carrier(params={})
|
|
420
|
+
carrier_id = params.delete('carrier_id')
|
|
421
|
+
return request('DELETE', "/OutgoingCarrier/#{carrier_id}/", params)
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
## Outgoing Carrier Routings ##
|
|
425
|
+
def get_outgoing_carrier_routings(params={})
|
|
426
|
+
return request('GET', "/OutgoingCarrierRouting/", params)
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
def create_outgoing_carrier_routing(params={})
|
|
430
|
+
return request('POST', "/OutgoingCarrierRouting/", params)
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
def get_outgoing_carrier_routing(params={})
|
|
434
|
+
routing_id = params.delete('routing_id')
|
|
435
|
+
return request('GET', "/OutgoingCarrierRouting/#{routing_id}/", params)
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
def modify_outgoing_carrier_routing(params={})
|
|
439
|
+
routing_id = params.delete('routing_id')
|
|
440
|
+
return request('POST', "/OutgoingCarrierRouting/#{routing_id}/", params)
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
def delete_outgoing_carrier_routing(params={})
|
|
444
|
+
routing_id = params.delete('routing_id')
|
|
445
|
+
return request('DELETE', "/OutgoingCarrierRouting/#{routing_id}/", params)
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
## Pricing ##
|
|
449
|
+
def pricing(params={})
|
|
450
|
+
return request('GET', "/Pricing/", params)
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
## Outgoing Carrier ##
|
|
454
|
+
|
|
455
|
+
## To be added here ##
|
|
456
|
+
|
|
457
|
+
## Message ##
|
|
458
|
+
def send_message(params={})
|
|
459
|
+
return request('POST', "/Message/", params)
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
def get_messages(params={})
|
|
463
|
+
return request('POST', "/Message/", params)
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
def get_message(params={})
|
|
467
|
+
record_id = params.delete('record_id')
|
|
468
|
+
return request('POST', "/Message/#{record_id}/", params)
|
|
469
|
+
end
|
|
467
470
|
end
|
|
468
471
|
|
|
469
472
|
|
|
470
473
|
|
|
471
474
|
class Element
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
475
|
+
class << self
|
|
476
|
+
attr_accessor :valid_attributes, :nestables
|
|
477
|
+
end
|
|
478
|
+
@nestables = []
|
|
479
|
+
@valid_attributes = []
|
|
480
|
+
|
|
481
|
+
attr_accessor :node, :name
|
|
482
|
+
|
|
483
|
+
def initialize(body=nil, attributes={}, &block)
|
|
484
|
+
@name = self.class.name.split('::')[1]
|
|
485
|
+
@body = body
|
|
486
|
+
@node = REXML::Element.new @name
|
|
487
|
+
attributes.each do |k, v|
|
|
488
|
+
if self.class.valid_attributes.include?(k.to_s)
|
|
489
|
+
@node.attributes[k.to_s] = convert_value(v)
|
|
490
|
+
else
|
|
491
|
+
raise PlivoError, "invalid attribute #{k.to_s} for #{@name}"
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
if @body
|
|
495
|
+
coder = HTMLEntities.new(:html4)
|
|
496
|
+
@node.text = coder.encode(@body, :decimal)
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
# Allow for nested "nestable" elements using a code block
|
|
500
|
+
# ie
|
|
501
|
+
# Plivo::Response.new do |r|
|
|
502
|
+
# r.Dial do |n|
|
|
503
|
+
# n.Number '+15557779999'
|
|
504
|
+
# end
|
|
505
|
+
# end
|
|
506
|
+
yield(self) if block_given?
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
def method_missing(method, *args, &block)
|
|
510
|
+
# Handle the addElement methods
|
|
511
|
+
method = $1.to_sym if method.to_s =~ /^add(.*)/
|
|
512
|
+
# Add the element
|
|
513
|
+
add(Plivo.const_get(method).new(*args, &block))
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
def convert_value(v)
|
|
518
|
+
if v == true
|
|
519
|
+
return "true"
|
|
520
|
+
elsif v == false
|
|
521
|
+
return "false"
|
|
522
|
+
elsif v == nil
|
|
523
|
+
return "none"
|
|
524
|
+
elsif v == "get"
|
|
525
|
+
return "GET"
|
|
526
|
+
elsif v == "post"
|
|
527
|
+
return "POST"
|
|
528
|
+
else
|
|
529
|
+
return v
|
|
530
|
+
end
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
def add(element)
|
|
534
|
+
if not element
|
|
535
|
+
raise PlivoError, "invalid element"
|
|
536
|
+
end
|
|
537
|
+
if self.class.nestables.include?(element.name)
|
|
538
|
+
@node.elements << element.node
|
|
539
|
+
return element
|
|
540
|
+
else
|
|
541
|
+
raise PlivoError, "#{element.name} not nestable in #{@name}"
|
|
542
|
+
end
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
def to_xml
|
|
546
|
+
return @node.to_s
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
def to_s
|
|
550
|
+
return @node.to_s
|
|
551
|
+
end
|
|
548
552
|
end
|
|
549
553
|
|
|
550
554
|
|
|
551
555
|
class Response < Element
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
556
|
+
@nestables = ['Speak', 'Play', 'GetDigits', 'Record', 'Dial', 'Message',
|
|
557
|
+
'Redirect', 'Wait', 'Hangup', 'PreAnswer', 'Conference', 'DTMF']
|
|
558
|
+
@valid_attributes = []
|
|
555
559
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
560
|
+
def initialize()
|
|
561
|
+
super(nil, {})
|
|
562
|
+
end
|
|
559
563
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
564
|
+
def to_xml()
|
|
565
|
+
return '<?xml version="1.0" encoding="utf-8" ?>' + super()
|
|
566
|
+
end
|
|
563
567
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
568
|
+
def to_s()
|
|
569
|
+
return '<?xml version="1.0" encoding="utf-8" ?>' + super()
|
|
570
|
+
end
|
|
567
571
|
end
|
|
568
572
|
|
|
569
573
|
|
|
570
574
|
class Speak < Element
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
end
|
|
578
|
-
super(body, attributes)
|
|
575
|
+
@nestables = []
|
|
576
|
+
@valid_attributes = ['voice', 'language', 'loop']
|
|
577
|
+
|
|
578
|
+
def initialize(body, attributes={})
|
|
579
|
+
if not body
|
|
580
|
+
raise PlivoError, 'No text set for Speak'
|
|
579
581
|
end
|
|
582
|
+
super(body, attributes)
|
|
583
|
+
end
|
|
580
584
|
end
|
|
581
585
|
|
|
582
586
|
|
|
583
587
|
class Play < Element
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
end
|
|
591
|
-
super(body, attributes)
|
|
588
|
+
@nestables = []
|
|
589
|
+
@valid_attributes = ['loop']
|
|
590
|
+
|
|
591
|
+
def initialize(body, attributes={})
|
|
592
|
+
if not body
|
|
593
|
+
raise PlivoError 'No url set for Play'
|
|
592
594
|
end
|
|
595
|
+
super(body, attributes)
|
|
596
|
+
end
|
|
593
597
|
end
|
|
594
598
|
|
|
595
599
|
|
|
596
600
|
class Wait < Element
|
|
597
|
-
|
|
598
|
-
|
|
601
|
+
@nestables = []
|
|
602
|
+
@valid_attributes = ['length', 'silence', 'min_silence']
|
|
599
603
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
604
|
+
def initialize(attributes={})
|
|
605
|
+
super(nil, attributes)
|
|
606
|
+
end
|
|
603
607
|
end
|
|
604
608
|
|
|
605
609
|
|
|
606
610
|
class Redirect < Element
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
end
|
|
614
|
-
super(body, attributes)
|
|
611
|
+
@nestables = []
|
|
612
|
+
@valid_attributes = ['method']
|
|
613
|
+
|
|
614
|
+
def initialize(body, attributes={})
|
|
615
|
+
if not body
|
|
616
|
+
raise PlivoError 'No url set for Redirect'
|
|
615
617
|
end
|
|
618
|
+
super(body, attributes)
|
|
619
|
+
end
|
|
616
620
|
end
|
|
617
621
|
|
|
618
622
|
|
|
619
623
|
class Hangup < Element
|
|
620
|
-
|
|
621
|
-
|
|
624
|
+
@nestables = []
|
|
625
|
+
@valid_attributes = ['schedule', 'reason']
|
|
622
626
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
627
|
+
def initialize(attributes={})
|
|
628
|
+
super(nil, attributes)
|
|
629
|
+
end
|
|
626
630
|
end
|
|
627
631
|
|
|
628
632
|
|
|
629
633
|
class GetDigits < Element
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
634
|
+
@nestables = ['Speak', 'Play', 'Wait']
|
|
635
|
+
@valid_attributes = ['action', 'method', 'timeout', 'digitTimeout',
|
|
636
|
+
'numDigits', 'retries', 'invalidDigitsSound',
|
|
637
|
+
'validDigits', 'playBeep', 'redirect', "finishOnKey",
|
|
638
|
+
'digitTimeout']
|
|
639
|
+
|
|
640
|
+
def initialize(attributes={}, &block)
|
|
641
|
+
super(nil, attributes, &block)
|
|
642
|
+
end
|
|
639
643
|
end
|
|
640
644
|
|
|
641
645
|
|
|
642
646
|
class Number < Element
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
end
|
|
650
|
-
super(body, attributes)
|
|
647
|
+
@nestables = []
|
|
648
|
+
@valid_attributes = ['sendDigits', 'sendOnPreanswer']
|
|
649
|
+
|
|
650
|
+
def initialize(body, attributes={})
|
|
651
|
+
if not body
|
|
652
|
+
raise PlivoError, 'No number set for Number'
|
|
651
653
|
end
|
|
654
|
+
super(body, attributes)
|
|
655
|
+
end
|
|
652
656
|
end
|
|
653
657
|
|
|
654
658
|
|
|
655
659
|
class User < Element
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
end
|
|
663
|
-
super(body, attributes)
|
|
660
|
+
@nestables = []
|
|
661
|
+
@valid_attributes = ['sendDigits', 'sendOnPreanswer', 'sipHeaders']
|
|
662
|
+
|
|
663
|
+
def initialize(body, attributes={})
|
|
664
|
+
if not body
|
|
665
|
+
raise PlivoError, 'No user set for User'
|
|
664
666
|
end
|
|
667
|
+
super(body, attributes)
|
|
668
|
+
end
|
|
665
669
|
end
|
|
666
670
|
|
|
667
671
|
|
|
668
672
|
class Dial < Element
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
673
|
+
@nestables = ['Number', 'User']
|
|
674
|
+
@valid_attributes = ['action','method','timeout','hangupOnStar',
|
|
675
|
+
'timeLimit','callerId', 'callerName', 'confirmSound',
|
|
676
|
+
'dialMusic', 'confirmKey', 'redirect',
|
|
677
|
+
'callbackUrl', 'callbackMethod', 'digitsMatch',
|
|
678
|
+
'sipHeaders']
|
|
679
|
+
|
|
680
|
+
def initialize(attributes={}, &block)
|
|
681
|
+
super(nil, attributes, &block)
|
|
682
|
+
end
|
|
679
683
|
end
|
|
680
684
|
|
|
681
685
|
|
|
682
686
|
class Conference < Element
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
687
|
+
@nestables = []
|
|
688
|
+
@valid_attributes = ['muted','beep','startConferenceOnEnter',
|
|
689
|
+
'endConferenceOnExit','waitSound','enterSound', 'exitSound',
|
|
690
|
+
'timeLimit', 'hangupOnStar', 'maxMembers',
|
|
691
|
+
'record', 'recordFileFormat', 'action', 'method', 'redirect',
|
|
692
|
+
'digitsMatch', 'callbackUrl', 'callbackMethod',
|
|
693
|
+
'stayAlone', 'floorEvent',
|
|
694
|
+
'transcriptionType', 'transcriptionUrl',
|
|
695
|
+
'transcriptionMethod', 'recordWhenAlone']
|
|
696
|
+
|
|
697
|
+
def initialize(body, attributes={})
|
|
698
|
+
if not body
|
|
699
|
+
raise PlivoError, 'No conference name set for Conference'
|
|
700
|
+
end
|
|
701
|
+
super(body, attributes)
|
|
702
|
+
end
|
|
699
703
|
end
|
|
700
704
|
|
|
701
705
|
|
|
702
706
|
class Record < Element
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
707
|
+
@nestables = []
|
|
708
|
+
@valid_attributes = ['action', 'method', 'timeout','finishOnKey',
|
|
709
|
+
'maxLength', 'playBeep', 'recordSession',
|
|
710
|
+
'startOnDialAnswer', 'redirect', 'fileFormat',
|
|
711
|
+
'callbackUrl', 'callbackMethod',
|
|
712
|
+
'transcriptionType', 'transcriptionUrl',
|
|
713
|
+
'transcriptionMethod']
|
|
714
|
+
|
|
715
|
+
def initialize(attributes={})
|
|
716
|
+
super(nil, attributes)
|
|
717
|
+
end
|
|
714
718
|
end
|
|
715
719
|
|
|
716
720
|
|
|
717
721
|
class PreAnswer < Element
|
|
718
|
-
|
|
719
|
-
|
|
722
|
+
@nestables = ['Play', 'Speak', 'GetDigits', 'Wait', 'Redirect', 'Message', 'DTMF']
|
|
723
|
+
@valid_attributes = []
|
|
720
724
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
725
|
+
def initialize(attributes={}, &block)
|
|
726
|
+
super(nil, attributes, &block)
|
|
727
|
+
end
|
|
724
728
|
end
|
|
725
729
|
|
|
726
730
|
|
|
727
731
|
class Message < Element
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
end
|
|
735
|
-
super(body, attributes)
|
|
732
|
+
@nestables = []
|
|
733
|
+
@valid_attributes = ['src', 'dst', 'type', 'callbackUrl', 'callbackMethod']
|
|
734
|
+
|
|
735
|
+
def initialize(body, attributes={})
|
|
736
|
+
if not body
|
|
737
|
+
raise PlivoError, 'No text set for Message'
|
|
736
738
|
end
|
|
739
|
+
super(body, attributes)
|
|
740
|
+
end
|
|
737
741
|
end
|
|
738
742
|
|
|
739
743
|
class DTMF < Element
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
end
|
|
747
|
-
super(body, attributes)
|
|
744
|
+
@nestables = []
|
|
745
|
+
@valid_attributes = []
|
|
746
|
+
|
|
747
|
+
def initialize(body, attributes={})
|
|
748
|
+
if not body
|
|
749
|
+
raise PlivoError, 'No digits set for DTMF'
|
|
748
750
|
end
|
|
751
|
+
super(body, attributes)
|
|
752
|
+
end
|
|
749
753
|
end
|
|
750
754
|
|
|
751
755
|
end
|