plivo 0.3.19 → 4.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/AUTHORS.md +4 -0
- data/CHANGELOG.md +158 -0
- data/Gemfile +10 -0
- data/Jenkinsfile +7 -0
- data/LICENSE.txt +19 -0
- data/README.md +155 -24
- data/Rakefile +9 -0
- data/ci/config.yml +7 -0
- data/examples/conference_bridge.rb +108 -0
- data/examples/jwt.rb +32 -0
- data/examples/lookup.rb +24 -0
- data/examples/multi_party_call.rb +295 -0
- data/examples/phlos.rb +55 -0
- data/examples/regulatory_compliance.rb +167 -0
- data/lib/plivo/base/resource.rb +148 -0
- data/lib/plivo/base/resource_interface.rb +108 -0
- data/lib/plivo/base/response.rb +38 -0
- data/lib/plivo/base.rb +17 -0
- data/lib/plivo/base_client.rb +393 -0
- data/lib/plivo/exceptions.rb +50 -0
- data/lib/plivo/jwt.rb +120 -0
- data/lib/plivo/phlo_client.rb +29 -0
- data/lib/plivo/resources/accounts.rb +181 -0
- data/lib/plivo/resources/addresses.rb +302 -0
- data/lib/plivo/resources/applications.rb +258 -0
- data/lib/plivo/resources/call_feedback.rb +55 -0
- data/lib/plivo/resources/calls.rb +559 -0
- data/lib/plivo/resources/conferences.rb +367 -0
- data/lib/plivo/resources/endpoints.rb +132 -0
- data/lib/plivo/resources/identities.rb +319 -0
- data/lib/plivo/resources/lookup.rb +88 -0
- data/lib/plivo/resources/media.rb +97 -0
- data/lib/plivo/resources/messages.rb +215 -0
- data/lib/plivo/resources/multipartycalls.rb +554 -0
- data/lib/plivo/resources/nodes.rb +83 -0
- data/lib/plivo/resources/numbers.rb +319 -0
- data/lib/plivo/resources/phlo_member.rb +64 -0
- data/lib/plivo/resources/phlos.rb +55 -0
- data/lib/plivo/resources/powerpacks.rb +717 -0
- data/lib/plivo/resources/pricings.rb +43 -0
- data/lib/plivo/resources/recordings.rb +116 -0
- data/lib/plivo/resources/regulatory_compliance.rb +610 -0
- data/lib/plivo/resources.rb +25 -0
- data/lib/plivo/rest_client.rb +63 -0
- data/lib/plivo/utils.rb +294 -0
- data/lib/plivo/version.rb +3 -0
- data/lib/plivo/xml/break.rb +31 -0
- data/lib/plivo/xml/conference.rb +20 -0
- data/lib/plivo/xml/cont.rb +13 -0
- data/lib/plivo/xml/dial.rb +16 -0
- data/lib/plivo/xml/dtmf.rb +13 -0
- data/lib/plivo/xml/element.rb +106 -0
- data/lib/plivo/xml/emphasis.rb +17 -0
- data/lib/plivo/xml/get_digits.rb +15 -0
- data/lib/plivo/xml/get_input.rb +16 -0
- data/lib/plivo/xml/hangup.rb +12 -0
- data/lib/plivo/xml/lang.rb +29 -0
- data/lib/plivo/xml/message.rb +13 -0
- data/lib/plivo/xml/multipartycall.rb +188 -0
- data/lib/plivo/xml/number.rb +13 -0
- data/lib/plivo/xml/p.rb +12 -0
- data/lib/plivo/xml/phoneme.rb +20 -0
- data/lib/plivo/xml/play.rb +13 -0
- data/lib/plivo/xml/plivo_xml.rb +19 -0
- data/lib/plivo/xml/pre_answer.rb +12 -0
- data/lib/plivo/xml/prosody.rb +28 -0
- data/lib/plivo/xml/record.rb +17 -0
- data/lib/plivo/xml/redirect.rb +13 -0
- data/lib/plivo/xml/response.rb +21 -0
- data/lib/plivo/xml/s.rb +12 -0
- data/lib/plivo/xml/say_as.rb +24 -0
- data/lib/plivo/xml/speak.rb +28 -0
- data/lib/plivo/xml/sub.rb +16 -0
- data/lib/plivo/xml/user.rb +13 -0
- data/lib/plivo/xml/w.rb +17 -0
- data/lib/plivo/xml/wait.rb +12 -0
- data/lib/plivo/xml.rb +39 -0
- data/lib/plivo.rb +12 -815
- data/plivo.gemspec +44 -0
- metadata +181 -41
- data/ext/mkrf_conf.rb +0 -9
@@ -0,0 +1,295 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'plivo'
|
3
|
+
|
4
|
+
include Plivo
|
5
|
+
|
6
|
+
AUTH_ID = 'AUTH_ID'
|
7
|
+
AUTH_TOKEN = 'AUTH_TOKEN'
|
8
|
+
|
9
|
+
client = Phlo.new(AUTH_ID, AUTH_TOKEN)
|
10
|
+
|
11
|
+
# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
|
12
|
+
# then initialize client as:
|
13
|
+
# client = Phlo.new
|
14
|
+
|
15
|
+
# provide the phlo_id in params
|
16
|
+
phlo = client.phlo.get('phlo_id')
|
17
|
+
|
18
|
+
# provide multi_party_call node id in params:
|
19
|
+
begin
|
20
|
+
multi_party_call = phlo.multi_party_call('node_id')
|
21
|
+
puts multi_party_call
|
22
|
+
rescue PlivoRESTError => e
|
23
|
+
puts 'Exception: ' + e.message
|
24
|
+
end
|
25
|
+
|
26
|
+
# Response:
|
27
|
+
# {
|
28
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
29
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
30
|
+
# "name": "Multi-Party Call_1",
|
31
|
+
# "node_type": "multi_party_call",
|
32
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
33
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
34
|
+
# }
|
35
|
+
#------------------------------------------------------------------------
|
36
|
+
|
37
|
+
# 1. Agent makes outbound call to customer:
|
38
|
+
#
|
39
|
+
# 'trigger_source' => Caller Id to be set when an outbound call is made to the users to be added to the multi-party call
|
40
|
+
# 'to' => 'phone number/SIP endpoint to which an outbound call should be initiated'
|
41
|
+
# 'role' => 'customer'/'agent'/'supervisor'
|
42
|
+
# multi_party_call.call(<trigger_source>, <to>, <role>)
|
43
|
+
|
44
|
+
begin
|
45
|
+
response = multi_party_call.call('9999999999', '0000000000', 'customer')
|
46
|
+
puts response
|
47
|
+
rescue PlivoRESTError => e
|
48
|
+
puts 'Exception: ' + e.message
|
49
|
+
end
|
50
|
+
|
51
|
+
# Response:
|
52
|
+
# {
|
53
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
54
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
55
|
+
# "name": "Multi-Party Call_1",
|
56
|
+
# "node_type": "multi_party_call",
|
57
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
58
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
59
|
+
# }
|
60
|
+
|
61
|
+
|
62
|
+
# 2. Agent initiates warm transfer:
|
63
|
+
#
|
64
|
+
# 'trigger_source' => number of the agent initiating warm transfer
|
65
|
+
# 'to' => number of another agent to be added to the multi-party call
|
66
|
+
#
|
67
|
+
# multi_party_call.warm_transfer(<trigger_source>, <to>)
|
68
|
+
|
69
|
+
begin
|
70
|
+
response = multi_party_call.warm_transfer('9999999999', '0000000000')
|
71
|
+
puts response
|
72
|
+
rescue PlivoRESTError => e
|
73
|
+
puts 'Exception: ' + e.message
|
74
|
+
end
|
75
|
+
|
76
|
+
# Response:
|
77
|
+
# {
|
78
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
79
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
80
|
+
# "name": "Multi-Party Call_1",
|
81
|
+
# "node_type": "multi_party_call",
|
82
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
83
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
84
|
+
# }
|
85
|
+
|
86
|
+
|
87
|
+
# 3. Agent initiates cold transfer:
|
88
|
+
#
|
89
|
+
# 'trigger_source' => number of the agent initiating cold transfer
|
90
|
+
# 'to' => number of another agent to be added to the multi-party call
|
91
|
+
#
|
92
|
+
# multi_party_call.cold_transfer(<trigger_source>, <to>)
|
93
|
+
|
94
|
+
begin
|
95
|
+
response = multi_party_call.cold_transfer('9999999999', '0000000000')
|
96
|
+
puts response
|
97
|
+
rescue PlivoRESTError => e
|
98
|
+
puts 'Exception: ' + e.message
|
99
|
+
end
|
100
|
+
|
101
|
+
# Response:
|
102
|
+
# {
|
103
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
104
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
105
|
+
# "name": "Multi-Party Call_1",
|
106
|
+
# "node_type": "multi_party_call",
|
107
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
108
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
109
|
+
# }
|
110
|
+
|
111
|
+
|
112
|
+
# 4. Agent abort transfer:
|
113
|
+
#
|
114
|
+
# agent_address => number of the agent
|
115
|
+
#
|
116
|
+
# multi_party_call.member(<agent_address>).abort_transfer
|
117
|
+
|
118
|
+
|
119
|
+
begin
|
120
|
+
response = multi_party_call.member('0000000000').abort_transfer
|
121
|
+
puts response
|
122
|
+
rescue PlivoRESTError => e
|
123
|
+
puts 'Exception: ' + e.message
|
124
|
+
end
|
125
|
+
|
126
|
+
# Response:
|
127
|
+
# {
|
128
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
129
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
130
|
+
# "node_type": "multi_party_call",
|
131
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
132
|
+
# "member_address": '0000000000',
|
133
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
134
|
+
# }
|
135
|
+
|
136
|
+
|
137
|
+
# 5. Agent places customer on hold:
|
138
|
+
#
|
139
|
+
# member_address => phone number of the member who is being put on hold
|
140
|
+
#
|
141
|
+
# multi_party_call.member(<member_address>).hold
|
142
|
+
|
143
|
+
begin
|
144
|
+
response = multi_party_call.member('9999999999').hold
|
145
|
+
puts response
|
146
|
+
rescue PlivoRESTError => e
|
147
|
+
puts 'Exception: ' + e.message
|
148
|
+
end
|
149
|
+
|
150
|
+
# Response:
|
151
|
+
# {
|
152
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
153
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
154
|
+
# "node_type": "multi_party_call",
|
155
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
156
|
+
# "member_address": '9999999999',
|
157
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
158
|
+
# }
|
159
|
+
|
160
|
+
|
161
|
+
# 6. Resume call after hold:
|
162
|
+
#
|
163
|
+
# member_address => phone number of the member
|
164
|
+
#
|
165
|
+
# multi_party_call.member(<member_address>).unhold
|
166
|
+
|
167
|
+
begin
|
168
|
+
response = multi_party_call.member('9999999999').unhold
|
169
|
+
puts response
|
170
|
+
rescue PlivoRESTError => e
|
171
|
+
puts 'Exception: ' + e.message
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
# Response:
|
176
|
+
# {
|
177
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
178
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
179
|
+
# "node_type": "multi_party_call",
|
180
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
181
|
+
# "member_address": '9999999999',
|
182
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
183
|
+
# }
|
184
|
+
|
185
|
+
|
186
|
+
# 7. Agent initiates voicemail drop:
|
187
|
+
#
|
188
|
+
# member_address => customer's number/endpoint
|
189
|
+
#
|
190
|
+
# multi_party_call.member(<member_address>).voicemail_drop
|
191
|
+
|
192
|
+
begin
|
193
|
+
response = multi_party_call.member('9999999999').voicemail_drop
|
194
|
+
puts response
|
195
|
+
rescue PlivoRESTError => e
|
196
|
+
puts 'Exception: ' + e.message
|
197
|
+
end
|
198
|
+
|
199
|
+
|
200
|
+
# Response:
|
201
|
+
# {
|
202
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
203
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
204
|
+
# "node_type": "multi_party_call",
|
205
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
206
|
+
# "member_address": '9999999999',
|
207
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
208
|
+
# }
|
209
|
+
|
210
|
+
|
211
|
+
# 8. Rejoin call on warm transfer:
|
212
|
+
#
|
213
|
+
# agent_address => number of the agent to be added to the original conference on completion of call between agents
|
214
|
+
#
|
215
|
+
# multi_party_call.member(<agent_address>).resume_call
|
216
|
+
|
217
|
+
begin
|
218
|
+
response = multi_party_call.member('0000000000').resume_call
|
219
|
+
puts response
|
220
|
+
rescue PlivoRESTError => e
|
221
|
+
puts 'Exception: ' + e.message
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
# Response:
|
226
|
+
# {
|
227
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
228
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
229
|
+
# "node_type": "multi_party_call",
|
230
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
231
|
+
# "member_address": '9999999999',
|
232
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
233
|
+
# }
|
234
|
+
|
235
|
+
|
236
|
+
# 9. Agent leaves of the call [HANGUP]:
|
237
|
+
#
|
238
|
+
# agent_address => phone number of the agent
|
239
|
+
#
|
240
|
+
# multi_party_call.member(<agent_address>).hangup
|
241
|
+
|
242
|
+
begin
|
243
|
+
response = multi_party_call.member('0000000000').hangup
|
244
|
+
puts response
|
245
|
+
rescue PlivoRESTError => e
|
246
|
+
puts 'Exception: ' + e.message
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
# Response:
|
251
|
+
# {
|
252
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
253
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
254
|
+
# "node_type": "multi_party_call",
|
255
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
256
|
+
# "member_address": '9999999999',
|
257
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
258
|
+
# }
|
259
|
+
|
260
|
+
|
261
|
+
# 10. Customer is removed from the conference call [HANGUP]:
|
262
|
+
#
|
263
|
+
# customer_address => phone number of the customer
|
264
|
+
#
|
265
|
+
# multi_party_call.member(<customer_address>).hangup
|
266
|
+
|
267
|
+
# Response:
|
268
|
+
# {
|
269
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
270
|
+
# "node_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
271
|
+
# "node_type": "multi_party_call",
|
272
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
273
|
+
# "member_address": '9999999999',
|
274
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
275
|
+
# }
|
276
|
+
|
277
|
+
|
278
|
+
# 11. Remove a member from the multi-party call:
|
279
|
+
#
|
280
|
+
# member_address => phone number of the member
|
281
|
+
#
|
282
|
+
# multi_party_call.member(<member_address>).remove
|
283
|
+
|
284
|
+
begin
|
285
|
+
response = multi_party_call.member('9999999999').remove
|
286
|
+
puts response
|
287
|
+
rescue PlivoRESTError => e
|
288
|
+
puts 'Exception: ' + e.message
|
289
|
+
end
|
290
|
+
|
291
|
+
# Response:
|
292
|
+
# {
|
293
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
294
|
+
# "id": "9999999999"
|
295
|
+
# }
|
data/examples/phlos.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'plivo'
|
3
|
+
|
4
|
+
include Plivo
|
5
|
+
|
6
|
+
AUTH_ID = 'AUTH_ID'
|
7
|
+
AUTH_TOKEN = 'AUTH_TOKEN'
|
8
|
+
|
9
|
+
client = Phlo.new(AUTH_ID, AUTH_TOKEN)
|
10
|
+
|
11
|
+
# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
|
12
|
+
# then initialize client as:
|
13
|
+
# client = Phlo.new
|
14
|
+
#
|
15
|
+
|
16
|
+
# provide the phlo_id in params
|
17
|
+
begin
|
18
|
+
phlo = client.phlo.get('phlo_id')
|
19
|
+
puts phlo
|
20
|
+
rescue PlivoRESTError => e
|
21
|
+
puts 'Exception: ' + e.message
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# Sample Response:
|
26
|
+
# {
|
27
|
+
# "api_id": '36989807-a76f-4555-84d1-9dfdccca7a80',
|
28
|
+
# "phlo_id": 'e564a84a-7910-4447-b16f-65c541dd552c',
|
29
|
+
# "name": 'assignment_mpc',
|
30
|
+
# "created_on": '2018-11-03 19:32:33.240504+00:00'
|
31
|
+
# }
|
32
|
+
|
33
|
+
|
34
|
+
# initiate phlo via API request:
|
35
|
+
begin
|
36
|
+
#optional parameter - params
|
37
|
+
params = {
|
38
|
+
from: '9999999999',
|
39
|
+
to: '0000000000'
|
40
|
+
}
|
41
|
+
response = phlo.run(params)
|
42
|
+
puts response
|
43
|
+
rescue PlivoRESTError => e
|
44
|
+
puts 'Exception: ' + e.message
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
# Sample Response:
|
49
|
+
# {
|
50
|
+
# :api_id=>"ff25223a-1c9f-11e4-80aa-12313f048015",
|
51
|
+
# :phlo_id=>"ff25223a-1c9f-11e4-80aa-12313f048015",
|
52
|
+
# :name=>"assignment_mpc",
|
53
|
+
# :created_on=>"2018-11-03 19:32:33.210714+00:00",
|
54
|
+
# :phlo_run_id=>"ff25223a-1c9f-11e4-80aa-12313f048015"
|
55
|
+
# }
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "plivo"
|
3
|
+
|
4
|
+
include Plivo
|
5
|
+
include Plivo::Exceptions
|
6
|
+
|
7
|
+
AUTH_ID = ""
|
8
|
+
AUTH_TOKEN = ""
|
9
|
+
|
10
|
+
client = RestClient.new(AUTH_ID, AUTH_TOKEN)
|
11
|
+
|
12
|
+
# if credentials are stored in the PLIVO_AUTH_ID and the PLIVO_AUTH_TOKEN environment variables
|
13
|
+
# then initialize client as:
|
14
|
+
# client = RestClient.new
|
15
|
+
|
16
|
+
# 1. EndUSers
|
17
|
+
begin
|
18
|
+
resp = client.end_users.create('Sample First Name',
|
19
|
+
'Sample last name',
|
20
|
+
'individual')
|
21
|
+
puts resp
|
22
|
+
rescue PlivoRESTError => e
|
23
|
+
puts "Exception: " + e.message
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
# Response:
|
28
|
+
# {
|
29
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
30
|
+
# "end_user_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
31
|
+
# "name": "Sample First Name",
|
32
|
+
# "last_name": 'Sample last name',
|
33
|
+
# "end_user_type": 'individual',
|
34
|
+
# "created_on": '2021-02-08T05:28:49.238152984Z',
|
35
|
+
# "message": "created"
|
36
|
+
# }
|
37
|
+
|
38
|
+
# 2. Compliance Document Type
|
39
|
+
begin
|
40
|
+
resp = client.compliance_document_types.get('6264e9ee-5826-4f9a-80ce-00b00f7a6c0c')
|
41
|
+
puts resp
|
42
|
+
rescue PlivoRESTError => e
|
43
|
+
puts "Exception: " + e.message
|
44
|
+
end
|
45
|
+
|
46
|
+
# Response:
|
47
|
+
# {
|
48
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
49
|
+
# "document_type_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
50
|
+
# "document_name": "Address Information",
|
51
|
+
# "description": 'End User Residential Address information',
|
52
|
+
# "information": [
|
53
|
+
# {
|
54
|
+
# "enums": [
|
55
|
+
# "Water",
|
56
|
+
# "Electricity",
|
57
|
+
# "Gas",
|
58
|
+
# "Property Rental",
|
59
|
+
# "Others"
|
60
|
+
# ],
|
61
|
+
# "field_name": "type_of_utility",
|
62
|
+
# "field_type": "enum",
|
63
|
+
# "friendly_name": "Type of Utility"
|
64
|
+
# }
|
65
|
+
# ],
|
66
|
+
# "proof_required": "Scanned copy of the Bill",
|
67
|
+
# "created_at": '2018-11-03 19:32:33.240504+00:00'
|
68
|
+
# }
|
69
|
+
|
70
|
+
# 3. Compliance Documents
|
71
|
+
begin
|
72
|
+
resp = client.compliance_documents.list(
|
73
|
+
limit: 5,
|
74
|
+
offset: 0,
|
75
|
+
document_type_id: '15d48097-6fd6-4bbc-97ee-0c3dd0a8fe1a',
|
76
|
+
end_user_id: '4493840308')
|
77
|
+
puts resp
|
78
|
+
rescue PlivoRESTError => e
|
79
|
+
puts "Exception: " + e.message
|
80
|
+
end
|
81
|
+
|
82
|
+
# Response
|
83
|
+
# {
|
84
|
+
# "alias": "test alias",
|
85
|
+
# "api_id": "3cfabf1a-6579-11eb-b408-0242ac110005",
|
86
|
+
# "created_at": "2021-02-02 08:08:10.312992 +0000 UTC",
|
87
|
+
# "document_id": "4a9599cc-c58c-4804-8c04-1d4918cb6df7",
|
88
|
+
# "document_type_id": "be903190-cc96-4fd8-b3cd-97832fe7c086",
|
89
|
+
# "end_user_id": "652e1445-1657-4a80-972f-6dbd467b00b5",
|
90
|
+
# "meta_information": {
|
91
|
+
# "use_case_description": "test"
|
92
|
+
# }
|
93
|
+
#}
|
94
|
+
|
95
|
+
# 4. Compliance Requirements
|
96
|
+
begin
|
97
|
+
resp = client.compliance_requirements.list(
|
98
|
+
country_iso2: 'ES',
|
99
|
+
end_user_type: 'business',
|
100
|
+
number_type: 'local')
|
101
|
+
puts resp
|
102
|
+
rescue PlivoRESTError => e
|
103
|
+
puts "Exception: " + e.message
|
104
|
+
end
|
105
|
+
|
106
|
+
# Response:
|
107
|
+
#{
|
108
|
+
# "acceptable_document_types": [
|
109
|
+
# {
|
110
|
+
# "acceptable_documents": [
|
111
|
+
# {
|
112
|
+
# "document_type_id": "e68cf5fe-cea0-4b6c-a2b1-bef1d9add467",
|
113
|
+
# "document_type_name": "Address Information"
|
114
|
+
# }
|
115
|
+
# ],
|
116
|
+
# "name": "End User Address Details",
|
117
|
+
# "scope": "local"
|
118
|
+
# },
|
119
|
+
# {
|
120
|
+
# "acceptable_documents": [
|
121
|
+
# {
|
122
|
+
# "document_type_id": "e9b0b6fb-fd2f-44c1-9428-ee69afbd808b",
|
123
|
+
# "document_type_name": "Utility Bill"
|
124
|
+
# }
|
125
|
+
# ],
|
126
|
+
# "name": "Proof of Address ",
|
127
|
+
# "scope": "local"
|
128
|
+
# }
|
129
|
+
# ],
|
130
|
+
# "api_id": "75ea8886-6499-11eb-ad59-0242ac110005",
|
131
|
+
# "compliance_requirement_id": "4ae473b0-f154-41a4-aba8-ab76be12f27f",
|
132
|
+
# "country_iso2": "ES",
|
133
|
+
# "end_user_type": "individual",
|
134
|
+
# "number_type": "local"
|
135
|
+
#}
|
136
|
+
|
137
|
+
# 5. Compliance Applications
|
138
|
+
begin
|
139
|
+
resp = client.compliance_applications.create(
|
140
|
+
alias_: 'test',
|
141
|
+
compliance_requirement_id: '4ae473b0-f154-41a4-aba8-ab76be12f27f',
|
142
|
+
end_user_type: 'individual'
|
143
|
+
end_user_id: 'f7ba78e0-1d31-4f75-842c-cd2f91334d9f',
|
144
|
+
document_ids: ["a663bc92-5c8e-4e95-80d5-ba75d3569a98","4a9599cc-c58c-4804-8c04-1d4918cb6df7"],
|
145
|
+
country_iso2: 'FR',
|
146
|
+
number_type: 'mobile'
|
147
|
+
)
|
148
|
+
puts resp
|
149
|
+
rescue PlivoRESTError => e
|
150
|
+
puts "Exception: " + e.message
|
151
|
+
end
|
152
|
+
|
153
|
+
# Response:
|
154
|
+
# {
|
155
|
+
# "api_id": "36989807-a76f-4555-84d1-9dfdccca7a80",
|
156
|
+
# "alias": "test",
|
157
|
+
# "compliance_application_id": "7c83fd87-fb5d-4a88-bde0-7c96da35f1e6",
|
158
|
+
# "compliance_requirement_id": "4ae473b0-f154-41a4-aba8-ab76be12f27f",
|
159
|
+
# "country_iso2": "FR",
|
160
|
+
# "documents": [],
|
161
|
+
# "end_user_id": "f7ba78e0-1d31-4f75-842c-cd2f91334d9f",
|
162
|
+
# "end_user_type": "individual",
|
163
|
+
# "message": "created",
|
164
|
+
# "number_type": "local",
|
165
|
+
# "status": "draft",
|
166
|
+
# "created_at": '2021-02-08T19:32:33.240504+00:00'
|
167
|
+
# }
|
@@ -0,0 +1,148 @@
|
|
1
|
+
module Plivo
|
2
|
+
module Base
|
3
|
+
class Resource
|
4
|
+
attr_reader :id
|
5
|
+
include Plivo::Utils
|
6
|
+
|
7
|
+
def initialize(client, options = nil)
|
8
|
+
configure_client(client)
|
9
|
+
configure_options(options) if options
|
10
|
+
configure_resource_uri
|
11
|
+
@_is_voice_request = false
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def configure_client(client)
|
17
|
+
valid_param?(:client, client, [RestClient, Phlo], true)
|
18
|
+
@_client = client
|
19
|
+
end
|
20
|
+
|
21
|
+
def configure_options(options)
|
22
|
+
valid_param?(:options, options, Hash, false)
|
23
|
+
@id = options[:resource_id] if options.key?(:resource_id)
|
24
|
+
parse_and_set(options[:resource_json]) if options.key?(:resource_json)
|
25
|
+
end
|
26
|
+
|
27
|
+
def configure_resource_uri
|
28
|
+
to_join = @id ? [@_client.auth_id, @_name, @id] : [@_client.auth_id, @_name]
|
29
|
+
to_join = ['', 'v1', 'Account'] << to_join
|
30
|
+
|
31
|
+
if @_name == 'Account'
|
32
|
+
@id = @_client.auth_id
|
33
|
+
to_join = ['', 'v1', 'Account', @id]
|
34
|
+
end
|
35
|
+
|
36
|
+
to_join << ''
|
37
|
+
@_resource_uri = to_join.join('/')
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse_and_set(resource_json)
|
41
|
+
return unless resource_json
|
42
|
+
|
43
|
+
valid_param?(:resource_json, resource_json, Hash, true)
|
44
|
+
|
45
|
+
resource_json.each do |k, v|
|
46
|
+
instance_variable_set("@#{k}", v)
|
47
|
+
self.class.send(:attr_reader, k)
|
48
|
+
end
|
49
|
+
|
50
|
+
return unless @_identifier_string && (resource_json.key? @_identifier_string)
|
51
|
+
@id = resource_json[@_identifier_string]
|
52
|
+
end
|
53
|
+
|
54
|
+
def perform_update(params, use_multipart_conn = false)
|
55
|
+
unless @id
|
56
|
+
raise_invalid_request("Cannot update a #{@_name} resource "\
|
57
|
+
'without an identifier')
|
58
|
+
end
|
59
|
+
|
60
|
+
response_json = @_client.send_request(@_resource_uri, 'POST', params, nil, use_multipart_conn, is_voice_request: @_is_voice_request)
|
61
|
+
|
62
|
+
parse_and_set(params)
|
63
|
+
parse_and_set(response_json)
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
def perform_action(action = nil, method = 'GET', params = nil, parse = false)
|
68
|
+
resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
|
69
|
+
response = @_client.send_request(resource_path, method, params,nil,false,is_voice_request: @_is_voice_request)
|
70
|
+
parse ? parse_and_set(response) : self
|
71
|
+
method == 'POST' ? parse_and_set(params) : self
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
def perform_custome_action(action = nil, method = 'GET', params = nil, parse = false)
|
76
|
+
resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
|
77
|
+
response = @_client.send_request(resource_path, method, params,nil,false,is_voice_request: @_is_voice_request)
|
78
|
+
parse ? parse_and_set(response) : self
|
79
|
+
method == 'POST' ? parse_and_set(params) : self
|
80
|
+
self
|
81
|
+
end
|
82
|
+
|
83
|
+
def perform_action_apiresponse(action = nil, method = 'GET', params = nil, parse = false)
|
84
|
+
resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
|
85
|
+
response = @_client.send_request(resource_path, method, params,nil,false,is_voice_request: @_is_voice_request)
|
86
|
+
parse ? parse_and_set(response) : self
|
87
|
+
method == 'POST' ? parse_and_set(params) : self
|
88
|
+
method == 'DELETE' ? parse_and_set(params) : self
|
89
|
+
return response
|
90
|
+
end
|
91
|
+
|
92
|
+
def perform_custom_action_apiresponse(action = nil, method = 'GET', params = nil, parse = false)
|
93
|
+
resource_path = action ? '/v1/Account/' + @_client.auth_id + '/'+ action + '/' : @_resource_uri
|
94
|
+
response = @_client.send_request(resource_path, method, params,nil,false,is_voice_request: @_is_voice_request)
|
95
|
+
parse ? parse_and_set(response) : self
|
96
|
+
method == 'POST' ? parse_and_set(params) : self
|
97
|
+
method == 'DELETE' ? parse_and_set(params) : self
|
98
|
+
return response
|
99
|
+
end
|
100
|
+
|
101
|
+
def perform_delete(params=nil)
|
102
|
+
unless @id
|
103
|
+
raise_invalid_request("Cannot delete a #{@_name} resource "\
|
104
|
+
'without an identifier')
|
105
|
+
end
|
106
|
+
|
107
|
+
Response.new(@_client.send_request(@_resource_uri, 'DELETE', params, nil, false, is_voice_request: @_is_voice_request),
|
108
|
+
@_identifier_string)
|
109
|
+
end
|
110
|
+
|
111
|
+
def perform_run(params)
|
112
|
+
response_json = @_client.send_request(@_resource_uri, 'POST', params, nil,false,is_voice_request: @_is_voice_request)
|
113
|
+
parse_and_set(response_json)
|
114
|
+
Response.new(response_json, @_identifier_string)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
class SecondaryResource < Resource
|
119
|
+
attr_reader :secondary_id
|
120
|
+
def initialize(client, options = nil)
|
121
|
+
super
|
122
|
+
configure_secondary_options(options) if options
|
123
|
+
configure_secondary_resource_uri
|
124
|
+
end
|
125
|
+
|
126
|
+
def configure_secondary_options(options)
|
127
|
+
valid_param?(:options, options, Hash, false)
|
128
|
+
@secondary_id = options[:member_id] if options.key?(:member_id)
|
129
|
+
secondary_parse_and_set(options[:resource_json]) if options.key?(:resource_json)
|
130
|
+
end
|
131
|
+
|
132
|
+
def secondary_parse_and_set(resource_json)
|
133
|
+
return unless resource_json
|
134
|
+
|
135
|
+
valid_param?(:resource_json, resource_json, Hash, true)
|
136
|
+
return unless @_secondary_identifier_string && (resource_json.key? @_secondary_identifier_string)
|
137
|
+
@secondary_id = resource_json[@_secondary_identifier_string]
|
138
|
+
end
|
139
|
+
|
140
|
+
def configure_secondary_resource_uri
|
141
|
+
to_join = @secondary_id ? [@_client.auth_id, @_name, @id, @_secondary_name, @secondary_id] : [@_client.auth_id, @_name, @id]
|
142
|
+
to_join = ['', 'v1', 'Account'] << to_join
|
143
|
+
to_join << ''
|
144
|
+
@_resource_uri = to_join.join('/')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|