plivo 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/plivo.rb +6 -111
- metadata +4 -5
- data/lib/plivo_account.rb +0 -39
data/lib/plivo.rb
CHANGED
@@ -13,7 +13,7 @@ end
|
|
13
13
|
class RestAPI
|
14
14
|
attr_accessor :auth_id, :auth_token, :url, :version, :api, :headers, :rest
|
15
15
|
|
16
|
-
def initialize(auth_id, auth_token, url="
|
16
|
+
def initialize(auth_id, auth_token, url="https://api.plivo.com", version="v1")
|
17
17
|
@auth_id = auth_id
|
18
18
|
@auth_token = auth_token
|
19
19
|
@url = url.chomp('/')
|
@@ -118,34 +118,6 @@ class RestAPI
|
|
118
118
|
return request('DELETE', '/Application/#{app_id}/')
|
119
119
|
end
|
120
120
|
|
121
|
-
def get_subaccount_applications(params={})
|
122
|
-
subauth_id = params.delete("subauth_id")
|
123
|
-
return request('GET', '/Subaccount/#{subauth_id}/Application/')
|
124
|
-
end
|
125
|
-
|
126
|
-
def get_subaccount_application(params={})
|
127
|
-
subauth_id = params.delete("subauth_id")
|
128
|
-
app_id = params.delete("app_id")
|
129
|
-
return request('GET', '/Subaccount/#{subauth_id}/Application/#{app_id}/')
|
130
|
-
end
|
131
|
-
|
132
|
-
def create_subaccount_application(params={})
|
133
|
-
subauth_id = params.delete("subauth_id")
|
134
|
-
return request('POST', '/Subaccount/#{subauth_id}/Application/', params)
|
135
|
-
end
|
136
|
-
|
137
|
-
def modify_subaccount_application(params={})
|
138
|
-
subauth_id = params.delete("subauth_id")
|
139
|
-
app_id = params.delete("app_id")
|
140
|
-
return request('POST', '/Subaccount/#{subauth_id}/Application/#{app_id}/', params)
|
141
|
-
end
|
142
|
-
|
143
|
-
def delete_subaccount_application(params={})
|
144
|
-
subauth_id = params.delete("subauth_id")
|
145
|
-
app_id = params.delete("app_id")
|
146
|
-
return request('DELETE', '/Subaccount/#{subauth_id}/Application/#{app_id}/')
|
147
|
-
end
|
148
|
-
|
149
121
|
## Numbers ##
|
150
122
|
def get_numbers(params={})
|
151
123
|
return request('GET', '/Number/', params)
|
@@ -181,17 +153,6 @@ class RestAPI
|
|
181
153
|
return request('POST', '/Number/#{number}/', params)
|
182
154
|
end
|
183
155
|
|
184
|
-
def get_subaccount_numbers(params={})
|
185
|
-
subauth_id = params.delete("subauth_id")
|
186
|
-
return request('GET', '/Subaccount/#{subauth_id}/Number/', params)
|
187
|
-
end
|
188
|
-
|
189
|
-
def get_subaccount_number(params={})
|
190
|
-
subauth_id = params.delete("subauth_id")
|
191
|
-
number = params.delete("number")
|
192
|
-
return request('GET', '/Subaccount/#{subauth_id}/Number/#{number}/')
|
193
|
-
end
|
194
|
-
|
195
156
|
## Schedule ##
|
196
157
|
def get_scheduled_tasks(params={})
|
197
158
|
return request('GET', '/Schedule/')
|
@@ -269,17 +230,6 @@ class RestAPI
|
|
269
230
|
return request('POST', '/Call/#{call_uuid}/DTMF/', params)
|
270
231
|
end
|
271
232
|
|
272
|
-
def get_subaccount_cdrs(params={})
|
273
|
-
subauth_id = params.delete('subauth_id')
|
274
|
-
return request('GET', '/Subaccount/#{subauth_id}/Call/', params)
|
275
|
-
end
|
276
|
-
|
277
|
-
def get_subaccount_cdr(params={})
|
278
|
-
subauth_id = params.delete('subauth_id')
|
279
|
-
record_id = params.delete('record_id')
|
280
|
-
return request('GET', '/Subaccount/#{subauth_id}/Call/#{record_id}/')
|
281
|
-
end
|
282
|
-
|
283
233
|
## Calls requests ##
|
284
234
|
def hangup_request(params={})
|
285
235
|
request_uuid = params.delete('request_uuid')
|
@@ -379,17 +329,6 @@ class RestAPI
|
|
379
329
|
return request('GET', '/Recording/#{recording_id}/')
|
380
330
|
end
|
381
331
|
|
382
|
-
def get_subaccount_recordings(params={})
|
383
|
-
subauth_id = params.delete('subauth_id')
|
384
|
-
return request('GET', '/Subaccount/#{subauth_id}/Recording/')
|
385
|
-
end
|
386
|
-
|
387
|
-
def get_subaccount_recording(params={})
|
388
|
-
subauth_id = params.delete('subauth_id')
|
389
|
-
recording_id = params.delete('recording_id')
|
390
|
-
return request('GET', '/Subaccount/#{subauth_id}/Recording/#{recording_id}/')
|
391
|
-
end
|
392
|
-
|
393
332
|
## Endpoints ##
|
394
333
|
def get_endpoints(params={})
|
395
334
|
return request('GET', '/Endpoint/', params)
|
@@ -414,34 +353,6 @@ class RestAPI
|
|
414
353
|
return request('DELETE', '/Endpoint/#{endpoint_id}/')
|
415
354
|
end
|
416
355
|
|
417
|
-
def get_subaccount_endpoints(params={})
|
418
|
-
subauth_id = params.delete('subauth_id')
|
419
|
-
return request('GET', '/Subaccount/#{subauth_id}/Endpoint/')
|
420
|
-
end
|
421
|
-
|
422
|
-
def create_subaccount_endpoint(params={})
|
423
|
-
subauth_id = params.delete('subauth_id')
|
424
|
-
return request('POST', '/Subaccount/#{subauth_id}/Endpoint/', params)
|
425
|
-
end
|
426
|
-
|
427
|
-
def get_subaccount_endpoint(params={})
|
428
|
-
subauth_id = params.delete('subauth_id')
|
429
|
-
endpoint_id = params.delete('endpoint_id')
|
430
|
-
return request('GET', '/Subaccount/#{subauth_id}/Endpoint/#{endpoint_id}/')
|
431
|
-
end
|
432
|
-
|
433
|
-
def modify_subaccount_endpoint(params={})
|
434
|
-
subauth_id = params.delete('subauth_id')
|
435
|
-
endpoint_id = params.delete('endpoint_id')
|
436
|
-
return request('POST', '/Subaccount/#{subauth_id}/Endpoint/#{endpoint_id}/', params)
|
437
|
-
end
|
438
|
-
|
439
|
-
def delete_subaccount_endpoint(params={})
|
440
|
-
subauth_id = params.delete('subauth_id')
|
441
|
-
endpoint_id = params.delete('endpoint_id')
|
442
|
-
return request('DELETE', '/Subaccount/#{subauth_id}/Endpoint/#{endpoint_id}/')
|
443
|
-
end
|
444
|
-
|
445
356
|
## Carriers ##
|
446
357
|
def get_carriers(params={})
|
447
358
|
return request('GET', '/Carrier/', params)
|
@@ -634,7 +545,7 @@ class Speak < Element
|
|
634
545
|
@valid_attributes = ['voice', 'language', 'loop']
|
635
546
|
|
636
547
|
def initialize(body, attributes={})
|
637
|
-
if not body
|
548
|
+
if not body
|
638
549
|
raise PlivoError, 'No text set for ' + @name
|
639
550
|
end
|
640
551
|
super(body, attributes)
|
@@ -647,7 +558,7 @@ class Play < Element
|
|
647
558
|
@valid_attributes = ['loop']
|
648
559
|
|
649
560
|
def initialize(body, attributes={})
|
650
|
-
if not body
|
561
|
+
if not body
|
651
562
|
raise PlivoError 'No url set for ' + @name
|
652
563
|
end
|
653
564
|
super(body, attributes)
|
@@ -718,7 +629,7 @@ class User < Element
|
|
718
629
|
@valid_attributes = ['sendDigits', 'sendOnPreanswer']
|
719
630
|
|
720
631
|
def initialize(body, attributes={})
|
721
|
-
if not body
|
632
|
+
if not body
|
722
633
|
raise PlivoError, 'No user set for ' + @name
|
723
634
|
end
|
724
635
|
super(body, attributes)
|
@@ -749,7 +660,7 @@ class Conference < Element
|
|
749
660
|
'stayAlone', 'floorEvent']
|
750
661
|
|
751
662
|
def initialize(body, attributes={})
|
752
|
-
if not body
|
663
|
+
if not body
|
753
664
|
raise PlivoError, 'No conference name set for ' + @name
|
754
665
|
end
|
755
666
|
super(body, attributes)
|
@@ -784,7 +695,7 @@ class Message < Element
|
|
784
695
|
@valid_attributes = ['src', 'dst', 'type']
|
785
696
|
|
786
697
|
def initialize(body, attributes={})
|
787
|
-
if not body
|
698
|
+
if not body
|
788
699
|
raise PlivoError, 'No text set for ' + @name
|
789
700
|
end
|
790
701
|
super(body, attributes)
|
@@ -792,19 +703,3 @@ class Message < Element
|
|
792
703
|
end
|
793
704
|
|
794
705
|
|
795
|
-
#p = RestAPI.new('MAGWNTM3ZTK1M2YZMDYX', 'MThhNmRjZDFmY2I3MTg1NjAwODIxYWZiZWViNTQx',
|
796
|
-
# 'http://testapi.plivo.com', 'v1')
|
797
|
-
#require 'pp'
|
798
|
-
#pp p.get_live_calls()
|
799
|
-
#pp p.get_cdrs()
|
800
|
-
|
801
|
-
#pp p.modify_account({"name" => "Cloud test account"})
|
802
|
-
#pp p.get_account()
|
803
|
-
|
804
|
-
|
805
|
-
#r = Response.new
|
806
|
-
#s = r.addSpeak("hello world", {"voice" => "MAN"})
|
807
|
-
#s = r.addPlay("http://toto.com/toto.mp3")
|
808
|
-
#puts r.to_xml()
|
809
|
-
|
810
|
-
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plivo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 2
|
9
|
+
version: "0.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Plivo Inc
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-03
|
17
|
+
date: 2012-04-03 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,6 @@ extra_rdoc_files:
|
|
43
43
|
- README.rst
|
44
44
|
files:
|
45
45
|
- lib/plivo.rb
|
46
|
-
- lib/plivo_account.rb
|
47
46
|
- README.rst
|
48
47
|
has_rdoc: true
|
49
48
|
homepage: http://www.plivo.com
|
data/lib/plivo_account.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'plivo.rb'
|
2
|
-
|
3
|
-
|
4
|
-
AUTH_ID = "MAGWNTM3ZTK1M2YZMDF5"
|
5
|
-
AUTH_TOKEN = "MThhNmRjZDFmY2I3MTg1NjAwODIxYWZi1UViNTQx"
|
6
|
-
|
7
|
-
|
8
|
-
p = RestAPI.new(AUTH_ID, AUTH_TOKEN)
|
9
|
-
|
10
|
-
|
11
|
-
# Making a call
|
12
|
-
params = {'to' => '919986410895',
|
13
|
-
'from' => '919986410895',
|
14
|
-
'answer_url' => 'http://high-fire-9181.herokuapp.com/AnswerUrl',
|
15
|
-
'answer_method' => 'GET',
|
16
|
-
'hangup_url' => 'http://high-fire-9181.herokuapp.com/AnswerUrl',
|
17
|
-
}
|
18
|
-
response = p.make_call(params)
|
19
|
-
|
20
|
-
# Get live calls
|
21
|
-
response = p.get_live_calls()
|
22
|
-
|
23
|
-
|
24
|
-
# Get details of a live call
|
25
|
-
params = {'call_uuid' => 'XXXXXXXXXXXXXXXXXXXXXXX'}
|
26
|
-
response = p.get_live_call(params)
|
27
|
-
|
28
|
-
|
29
|
-
# Transfer calls
|
30
|
-
params = {'transfer_url' => 'http://example.com/TransferUrl'}
|
31
|
-
response = p.transfer_call(params)
|
32
|
-
|
33
|
-
|
34
|
-
# Hangup calls
|
35
|
-
params = {'call_uuid' => 'XXXXXXXXXXXXXXXXXXXXXXX'}
|
36
|
-
response = p.hangup_call(params)
|
37
|
-
|
38
|
-
|
39
|
-
|