plivo 4.16.0 → 4.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/unitTests.yml +32 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +225 -0
- data/Dockerfile +12 -0
- data/Gemfile +1 -0
- data/Makefile +18 -0
- data/README.md +389 -20
- data/docker-compose.yml +18 -0
- data/examples/tollfree_verification.rb +42 -0
- data/lib/plivo/base/resource.rb +30 -0
- data/lib/plivo/base/resource_interface.rb +18 -2
- data/lib/plivo/base.rb +3 -3
- data/lib/plivo/base_client.rb +9 -9
- data/lib/plivo/interactive.rb +139 -0
- data/lib/plivo/location.rb +22 -0
- data/lib/plivo/resources/brand.rb +98 -0
- data/lib/plivo/resources/call_feedback.rb +0 -1
- data/lib/plivo/resources/calls.rb +183 -29
- data/lib/plivo/resources/campaign.rb +168 -0
- data/lib/plivo/resources/messages.rb +392 -58
- data/lib/plivo/resources/multipartycalls.rb +637 -0
- data/lib/plivo/resources/numbers.rb +40 -7
- data/lib/plivo/resources/profile.rb +93 -0
- data/lib/plivo/resources/recordings.rb +29 -2
- data/lib/plivo/resources/token.rb +66 -0
- data/lib/plivo/resources/tollfree_verification.rb +178 -0
- data/lib/plivo/resources/verify_caller_id.rb +110 -0
- data/lib/plivo/resources/verify_session.rb +106 -0
- data/lib/plivo/resources.rb +8 -0
- data/lib/plivo/rest_client.rb +14 -1
- data/lib/plivo/template.rb +102 -0
- data/lib/plivo/utils.rb +112 -1
- data/lib/plivo/version.rb +1 -1
- data/lib/plivo/xml/cont.rb +13 -0
- data/lib/plivo/xml/dial.rb +1 -1
- data/lib/plivo/xml/element.rb +9 -2
- data/lib/plivo/xml/emphasis.rb +1 -1
- data/lib/plivo/xml/lang.rb +1 -1
- data/lib/plivo/xml/multipartycall.rb +216 -0
- data/lib/plivo/xml/p.rb +1 -1
- data/lib/plivo/xml/plivo_xml.rb +2 -2
- data/lib/plivo/xml/prosody.rb +1 -1
- data/lib/plivo/xml/response.rb +1 -1
- data/lib/plivo/xml/s.rb +1 -1
- data/lib/plivo/xml/speak.rb +1 -1
- data/lib/plivo/xml/stream.rb +27 -0
- data/lib/plivo/xml/w.rb +1 -1
- data/lib/plivo/xml.rb +3 -1
- data/plivo.gemspec +1 -2
- data/setup_sdk.sh +47 -0
- metadata +24 -19
- data/.travis.yml +0 -11
@@ -9,10 +9,11 @@ module Plivo
|
|
9
9
|
super
|
10
10
|
end
|
11
11
|
|
12
|
-
def buy(app_id = nil, verification_info = nil)
|
12
|
+
def buy(app_id = nil, verification_info = nil, cnam_lookup = nil)
|
13
13
|
params = {}
|
14
14
|
params[:app_id] = app_id unless app_id.nil?
|
15
15
|
params[:verification_info] = verification_info unless verification_info.nil?
|
16
|
+
params[:cnam_lookup] = cnam_lookup unless cnam_lookup.nil?
|
16
17
|
perform_action(nil, 'POST', params, true)
|
17
18
|
end
|
18
19
|
|
@@ -33,7 +34,12 @@ module Plivo
|
|
33
34
|
sms_enabled: @sms_enabled,
|
34
35
|
sms_rate: @sms_rate,
|
35
36
|
voice_enabled: @voice_enabled,
|
36
|
-
voice_rate: @voice_rate
|
37
|
+
voice_rate: @voice_rate,
|
38
|
+
tendlc_campaign_id: @tendlc_campaign_id,
|
39
|
+
tendlc_registration_status: @tendlc_registration_status,
|
40
|
+
toll_free_sms_verification: @toll_free_sms_verification,
|
41
|
+
toll_free_sms_verification_id: @toll_free_sms_verification_id,
|
42
|
+
toll_free_sms_verification_order_status: @toll_free_sms_verification_order_status
|
37
43
|
}.to_s
|
38
44
|
end
|
39
45
|
end
|
@@ -115,10 +121,10 @@ module Plivo
|
|
115
121
|
end
|
116
122
|
end
|
117
123
|
|
118
|
-
def buy(number, app_id = nil, verification_info = nil)
|
124
|
+
def buy(number, app_id = nil, verification_info = nil, cnam_lookup = nil)
|
119
125
|
valid_param?(:number, number, [Integer, String, Symbol], true)
|
120
126
|
PhoneNumber.new(@_client,
|
121
|
-
resource_id: number).buy(app_id, verification_info)
|
127
|
+
resource_id: number).buy(app_id, verification_info, cnam_lookup)
|
122
128
|
end
|
123
129
|
end
|
124
130
|
|
@@ -139,7 +145,7 @@ module Plivo
|
|
139
145
|
params[:subaccount] = options[:subaccount]
|
140
146
|
end
|
141
147
|
|
142
|
-
%i[alias app_id].each do |param|
|
148
|
+
%i[alias app_id cnam_lookup].each do |param|
|
143
149
|
if options.key?(param) &&
|
144
150
|
valid_param?(param, options[param], [String, Symbol], true)
|
145
151
|
params[param] = options[param]
|
@@ -176,7 +182,14 @@ module Plivo
|
|
176
182
|
sms_rate: @sms_rate,
|
177
183
|
sub_account: @sub_account,
|
178
184
|
voice_enabled: @voice_enabled,
|
179
|
-
voice_rate: @voice_rate
|
185
|
+
voice_rate: @voice_rate,
|
186
|
+
tendlc_campaign_id: @tendlc_campaign_id,
|
187
|
+
tendlc_registration_status: @tendlc_registration_status,
|
188
|
+
toll_free_sms_verification: @toll_free_sms_verification,
|
189
|
+
renewal_date: @renewal_date,
|
190
|
+
cnam_lookup: @cnam_lookup,
|
191
|
+
toll_free_sms_verification_id: @toll_free_sms_verification_id,
|
192
|
+
toll_free_sms_verification_order_status: @toll_free_sms_verification_order_status
|
180
193
|
}.to_s
|
181
194
|
end
|
182
195
|
end
|
@@ -205,6 +218,25 @@ module Plivo
|
|
205
218
|
# - sms - Returns a list of numbers that provide only 'sms' services.
|
206
219
|
# @option options [Int] :limit Used to display the number of results per page. The maximum number of results that can be fetched is 20.
|
207
220
|
# @option options [Int] :offset Denotes the number of value items by which the results should be offset. Eg:- If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results.
|
221
|
+
# @option options [String] :tendlc_campaign_id The 10DLC campaign that the number is currently linked with. You can filter US/CA local numbers linked to a specific campaign.
|
222
|
+
# @option options [String] :tendlc_registration_status Indicates the 10DLC registration status of a US/CA local number. The following values are valid:
|
223
|
+
# - unregistered - Returns a list of numbers that are not linked to any campaign
|
224
|
+
# - processing - Returns a list of numbers that are currently in the process of being linked to respective campaigns.
|
225
|
+
# - completed - Returns a list of numbers that are successfully linked to respective campaigns.
|
226
|
+
# @option options [String] :toll_free_sms_verification Indicates the toll-free SMS verification status of SMS-enabled US/CA toll-free number. The following values are valid:
|
227
|
+
# - unverified - Returns a list of SMS-enabled US/CA toll-free numbers that are not verified.
|
228
|
+
# - pending_verification - Returns a list of SMS-enabled US/CA toll-free numbers that are pending verification
|
229
|
+
# - verified - Returns a list of SMS-enabled US/CA toll-free numbers that are verified for enhanced outbound SMS limits.
|
230
|
+
# @option options [String] :renewal_date Returns phone numbers that will be renewed on the specified date. Format: YYYY-MM-DD
|
231
|
+
# @option options [String] :renewal_date__lt Returns phone numbers that will be renewed before the specified date. Format: YYYY-MM-DD
|
232
|
+
# @option options [String] :renewal_date__lte Returns phone numbers that will be renewed on or before the specified date. Format: YYYY-MM-DD
|
233
|
+
# @option options [String] :renewal_date__gt Returns phone numbers that will be renewed after the specified date. Format: YYYY-MM-DD
|
234
|
+
# @option options [String] :renewal_date__gte Returns phone numbers that will be renewed on or after the specified date. Format: YYYY-MM-DD
|
235
|
+
# @option options [String] :cnam_lookup The Cnam Lookup Configuration associated with that number. The following values are valid:
|
236
|
+
# - enabled - Returns the list of numbers for which Cnam Lookup configuration is enabled
|
237
|
+
# - disabled - Returns the list of numbers for which Cnam Lookup configuration is disabled
|
238
|
+
# @option options [String] :toll_free_sms_verification_id The id of tollfree verification that the number is currently linked with.
|
239
|
+
# @option options [String] :toll_free_sms_verification_order_status Indicates the tollfree verification status of a number.
|
208
240
|
def list(options = nil)
|
209
241
|
return perform_list if options.nil?
|
210
242
|
|
@@ -212,7 +244,7 @@ module Plivo
|
|
212
244
|
|
213
245
|
params = {}
|
214
246
|
|
215
|
-
%i[number_startswith subaccount alias].each do |param|
|
247
|
+
%i[number_startswith subaccount alias tendlc_campaign_id tendlc_registration_status toll_free_sms_verification renewal_date renewal_date__lt renewal_date__lte renewal_date__gt renewal_date__gte cnam_lookup toll_free_sms_verification_order_status].each do |param|
|
216
248
|
if options.key?(param) &&
|
217
249
|
valid_param?(param, options[param], [String, Symbol], true)
|
218
250
|
params[param] = options[param]
|
@@ -303,6 +335,7 @@ module Plivo
|
|
303
335
|
# @option options [String] :alias The textual name given to the number.
|
304
336
|
# @option options [String] :app_id The application id of the application that is to be linked.
|
305
337
|
# @option options [String] :subaccount The auth_id of the subaccount to which this number should be added. This can only be performed by a main account holder.
|
338
|
+
# @option options [String] :cnam_lookup The Cnam Lookup configuration to enable/disable Cnam Lookup
|
306
339
|
def update(number, options = nil)
|
307
340
|
valid_param?(:number, number, [String, Symbol], true)
|
308
341
|
Number.new(@_client,
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Plivo
|
2
|
+
module Resources
|
3
|
+
include Plivo::Utils
|
4
|
+
class Profile < Base::Resource
|
5
|
+
def initialize(client, options = nil)
|
6
|
+
@_name = 'Profile'
|
7
|
+
@_identifier_string = 'profile_uuid'
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
{
|
13
|
+
api_id: @api_id,
|
14
|
+
profile: @profile
|
15
|
+
}.to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
class ProfileInterface < Base::ResourceInterface
|
19
|
+
def initialize(client, resource_list_json = nil)
|
20
|
+
@_name = 'Profile'
|
21
|
+
@_resource_type = Profile
|
22
|
+
@_identifier_string = 'profile_uuid'
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Get an Profile
|
28
|
+
# @param [String] profile_uuid
|
29
|
+
# @return [Profile] Profile
|
30
|
+
def get(profile_uuid)
|
31
|
+
valid_param?(:profile_uuid, profile_uuid, [String, Symbol], true)
|
32
|
+
perform_get(profile_uuid)
|
33
|
+
end
|
34
|
+
|
35
|
+
# List all Profile
|
36
|
+
def list(options = nil)
|
37
|
+
return perform_list_without_object if options.nil?
|
38
|
+
params = {}
|
39
|
+
%i[offset limit].each do |param|
|
40
|
+
if options.key?(param) && valid_param?(param, options[param],
|
41
|
+
[Integer, Integer], true)
|
42
|
+
params[param] = options[param]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
|
46
|
+
raise_invalid_request('The maximum number of results that can be '\
|
47
|
+
"fetched is 20. limit can't be more than 20 or less than 1")
|
48
|
+
end
|
49
|
+
if options.key?(:offset) && options[:offset] < 0
|
50
|
+
raise_invalid_request("Offset can't be negative")
|
51
|
+
end
|
52
|
+
perform_list_without_object(params)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Delete an Profile
|
56
|
+
# @param [String] profile_uuid
|
57
|
+
def delete(profile_uuid)
|
58
|
+
valid_param?(:profile_uuid, profile_uuid, [String, Symbol], true)
|
59
|
+
perform_action_with_identifier(profile_uuid, 'DELETE', nil)
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Create a new Profile
|
64
|
+
def create(options = nil)
|
65
|
+
valid_param?(:options, options, Hash, true)
|
66
|
+
if not options[:profile_alias]
|
67
|
+
raise_invalid_request("profile_alias must be provided")
|
68
|
+
end
|
69
|
+
if not options[:customer_type]
|
70
|
+
raise_invalid_request("customer_type must be provided")
|
71
|
+
end
|
72
|
+
if not options[:entity_type]
|
73
|
+
raise_invalid_request("entity_type must be provided")
|
74
|
+
end
|
75
|
+
if not options[:company_name]
|
76
|
+
raise_invalid_request("company_name must be provided")
|
77
|
+
end
|
78
|
+
if not options[:vertical]
|
79
|
+
raise_invalid_request("vertical must be provided")
|
80
|
+
end
|
81
|
+
perform_create(options)
|
82
|
+
end
|
83
|
+
|
84
|
+
##
|
85
|
+
# Update a Profile
|
86
|
+
# {'address': {}, 'authorized_contact': {}, 'entity_type':'', 'vertical': '', 'company_name': '', 'website':''}
|
87
|
+
def update(profile_uuid, options = nil)
|
88
|
+
valid_param?(:options, options, Hash, true)
|
89
|
+
perform_action_with_identifier(profile_uuid, "POST", options)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -19,6 +19,8 @@ module Plivo
|
|
19
19
|
api_id: @api_id,
|
20
20
|
call_uuid: @call_uuid,
|
21
21
|
conference_name: @conference_name,
|
22
|
+
monthly_recording_storage_amount: @monthly_recording_storage_amount,
|
23
|
+
recording_storage_duration: @recording_storage_duration,
|
22
24
|
recording_duration_ms: @recording_duration_ms,
|
23
25
|
recording_end_ms: @recording_end_ms,
|
24
26
|
recording_format: @recording_format,
|
@@ -26,7 +28,14 @@ module Plivo
|
|
26
28
|
recording_start_ms: @recording_start_ms,
|
27
29
|
recording_type: @recording_type,
|
28
30
|
recording_url: @recording_url,
|
29
|
-
resource_uri: @resource_uri
|
31
|
+
resource_uri: @resource_uri,
|
32
|
+
rounded_recording_duration: @rounded_recording_duration,
|
33
|
+
recording_storage_rate: @recording_storage_rate,
|
34
|
+
from_number: @from_number,
|
35
|
+
to_number: @to_number,
|
36
|
+
mpc_name: @mpc_name,
|
37
|
+
conference_uuid: @conference_uuid,
|
38
|
+
mpc_uuid: @mpc_uuid
|
30
39
|
}.to_s
|
31
40
|
end
|
32
41
|
end
|
@@ -43,12 +52,25 @@ module Plivo
|
|
43
52
|
# @param [Hash] options
|
44
53
|
# @option options [String] :subaccount auth_id of the subaccount. Lists only those recordings of the main accounts which are tied to the specified subaccount.
|
45
54
|
# @option options [String] :call_uuid Used to filter recordings for a specific call.
|
55
|
+
# @option options [String] :from_number Used to filter recordings for a specific from_number.
|
56
|
+
# @option options [String] :to_number Used to filter recordings for a specific to_number.
|
57
|
+
# @option options [String] :conference_name Used to filter recordings for a specific conference_name.
|
58
|
+
# @option options [String] :mpc_name Used to filter recordings for a specific mpc_name.
|
59
|
+
# @option options [String] :conference_uuid Used to filter recordings for a specific conference_uuid.
|
60
|
+
# @option options [String] :mpc_uuid Used to filter recordings for a specific mpc_uuid.
|
46
61
|
# @option options [String] :add_time Used to filter out recordings according to the time they were added.The add_time filter is a comparative filter that can be used in the following four forms:
|
47
62
|
# - add_time\__gt: gt stands for greater than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all recordings that started after 2012-03-21 11:47, use add_time\__gt=2012-03-21 11:47
|
48
63
|
# - add_time\__gte: gte stands for greater than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all recordings that started after or exactly at 2012-03-21 11:47[:30], use add_time\__gte=2012-03-21 11:47[:30]
|
49
64
|
# - add_time\__lt: lt stands for lesser than. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all recordings that started before 2012-03-21 11:47, use add_time\__lt=2012-03-21 11:47
|
50
65
|
# - add_time\__gte: lte stands for lesser than or equal. The format expected is YYYY-MM-DD HH:MM[:ss[.uuuuuu]]. Eg:- To get all recordings that started before or exactly at 2012-03-21 11:47[:30], use add_time\__lte=2012-03-21 11:47[:30]
|
51
66
|
# - Note: The above filters can be combined to get recordings that started in a particular time range.
|
67
|
+
# @option options [Int] :recording_storage_duration - Used to filter out recordings according to the number of days they have been stored in the DB.The recording_storage_duration filter can be used in the following five forms:
|
68
|
+
# - recording_storage_duration: Takes an integer input and returns the recordings which are as old as that value.
|
69
|
+
# - recording_storage_duration\__gt: gt stands for greater than. The format expected is an integer value. Eg:- To get all recordings that are older than 100 days, use recording_storage_duration\__gt=100
|
70
|
+
# - recording_storage_duration\__gte: gte stands for greater than or equal. The format expected is an integer value. Eg:- To get all recordings that are older than or equal to 100 days old, use recording_storage_duration\__gte=100
|
71
|
+
# - recording_storage_duration\__lt: lt stands for lesser than. The format expected is an integer value. Eg:- To get all recordings that are newer than 100 days, use recording_storage_duration\__lt=100
|
72
|
+
# - recording_storage_duration\__lte: lte stands for lesser than or equal. The format expected is an integer value. Eg:- To get all recordings that are newer than or equal to 100 days old, use recording_storage_duration\__lte=100
|
73
|
+
# - Note: The above filters can be combined to get recordings that started in a particular time range.
|
52
74
|
# @option options [Int] :limit Used to display the number of results per page. The maximum number of results that can be fetched is 20.
|
53
75
|
# @option options [Int] :offset Denotes the number of value items by which the results should be offset. Eg:- If the result contains a 1000 values and limit is set to 10 and offset is set to 705, then values 706 through 715 are displayed in the results. This parameter is also used for pagination of the results.
|
54
76
|
def list(options = nil)
|
@@ -59,10 +81,15 @@ module Plivo
|
|
59
81
|
params_expected = %i[
|
60
82
|
call_uuid add_time__gt add_time__gte
|
61
83
|
add_time__lt add_time__lte
|
84
|
+
from_number to_number conference_uuid
|
85
|
+
conference_name mpc_name mpc_uuid
|
86
|
+
recording_storage_duration
|
87
|
+
recording_storage_duration__gt recording_storage_duration__gte
|
88
|
+
recording_storage_duration__lt recording_storage_duration__lte
|
62
89
|
]
|
63
90
|
|
64
91
|
params_expected.each do |param|
|
65
|
-
if options.key?(param) && valid_param?(param, options[param], [String, Symbol], true)
|
92
|
+
if options.key?(param) && valid_param?(param, options[param], [String, Symbol, Integer], true)
|
66
93
|
params[param] = options[param]
|
67
94
|
end
|
68
95
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Plivo
|
2
|
+
module Resources
|
3
|
+
include Plivo
|
4
|
+
include Plivo::Utils
|
5
|
+
class Token < Base::Resource
|
6
|
+
def initialize(client, options = nil)
|
7
|
+
@_name = 'JWT/Token'
|
8
|
+
super
|
9
|
+
@_is_voice_request = true
|
10
|
+
end
|
11
|
+
def to_s
|
12
|
+
{
|
13
|
+
api_id: @api_id,
|
14
|
+
token: @token
|
15
|
+
}.to_s
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class TokenInterface < Base::ResourceInterface
|
20
|
+
def initialize(client, resource_list_json = nil)
|
21
|
+
@_name = 'JWT/Token'
|
22
|
+
@_resource_type = Token
|
23
|
+
super
|
24
|
+
@_is_voice_request = true
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def create(iss , options = nil)
|
29
|
+
valid_param?(:iss, iss, [String, Symbol, Hash], true)
|
30
|
+
params = {}
|
31
|
+
params[:iss] = iss
|
32
|
+
|
33
|
+
return perform_create(params, false) if options.nil?
|
34
|
+
# return perform_action('Record', 'POST', nil, true) if options.nil?
|
35
|
+
valid_param?(:options, options, [Hash], false)
|
36
|
+
|
37
|
+
|
38
|
+
if options.key?("sub") && valid_param?("sub", options["sub"], [String, Symbol], false )
|
39
|
+
params[:sub] = options["sub"]
|
40
|
+
end
|
41
|
+
if options.key("nbf") && valid_param?("nbf", options["nbf"], [Integer, Symbol], false )
|
42
|
+
params[:nbf] = options["nbf"]
|
43
|
+
end
|
44
|
+
if options.key("exp") && valid_param?("exp", options["exp"], [Integer, Symbol], false )
|
45
|
+
params[:exp] = options["exp"]
|
46
|
+
end
|
47
|
+
if options.key?("incoming_allow") || options.key?("outgoing_allow")
|
48
|
+
params[:per] = {}
|
49
|
+
params[:per][:voice] = {}
|
50
|
+
if options.key?("incoming_allow") && valid_param?("incoming_allow", options["incoming_allow"], [TrueClass, FalseClass, String,Symbol], false)
|
51
|
+
params[:per][:voice][:incoming_allow] = options["incoming_allow"]
|
52
|
+
end
|
53
|
+
if options.key?("outgoing_allow") && valid_param?("outgoing_allow", options["outgoing_allow"], [TrueClass, FalseClass, String, Symbol], false)
|
54
|
+
params[:per][:voice][:outgoing_allow] = options["outgoing_allow"]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
if options.key?("app") && valid_param?("app", options["app"], [String, Symbol], false)
|
58
|
+
params[:app] = options["app"]
|
59
|
+
end
|
60
|
+
|
61
|
+
perform_create(params.merge(options), false)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,178 @@
|
|
1
|
+
module Plivo
|
2
|
+
module Resources
|
3
|
+
include Plivo::Utils
|
4
|
+
|
5
|
+
class TollfreeVerification < Base::Resource
|
6
|
+
def initialize(client, options = nil)
|
7
|
+
@_name = 'TollfreeVerification'
|
8
|
+
@_identifier_string = 'tollfree_verification'
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def update(options = nil)
|
13
|
+
return perform_update({}) if options.nil?
|
14
|
+
|
15
|
+
valid_param?(:options, options, Hash, true)
|
16
|
+
|
17
|
+
params = {}
|
18
|
+
params_expected = %i[ usecase usecase_summary profile_uuid optin_type optin_image_url volume message_sample callback_method callback_url extra_data additional_information ]
|
19
|
+
params_expected.each do |param|
|
20
|
+
if options.key?(param) &&
|
21
|
+
valid_param?(param, options[param], [String, Symbol], false)
|
22
|
+
params[param] = options[param]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
perform_update(params)
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete
|
30
|
+
perform_delete
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
{
|
35
|
+
api_id: @api_id,
|
36
|
+
uuid: @uuid,
|
37
|
+
number: @number,
|
38
|
+
created_at: @created_at,
|
39
|
+
updated_at: @updated_at,
|
40
|
+
callback_method: @callback_url,
|
41
|
+
callback_url: @callback_url,
|
42
|
+
extra_data: @extra_data,
|
43
|
+
additional_information: @additional_information,
|
44
|
+
message_sample: @message_sample,
|
45
|
+
optin_image_url: @optin_image_url,
|
46
|
+
optin_type: @optin_type,
|
47
|
+
profile_uuid: @profile_uuid,
|
48
|
+
rejection_reason: @rejection_reason,
|
49
|
+
status: @status,
|
50
|
+
usecase: @usecase,
|
51
|
+
usecase_summary: @usecase_summary,
|
52
|
+
volume: @volume
|
53
|
+
}.delete_if { |key, value| value.nil? }.to_s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class TollfreeVerificationsInterface < Base::ResourceInterface
|
58
|
+
def initialize(client, resource_list_json = nil)
|
59
|
+
@_name = 'TollfreeVerification'
|
60
|
+
@_resource_type = TollfreeVerification
|
61
|
+
@_identifier_string = 'tollfree_verification'
|
62
|
+
super
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# Get an TollfreeVerification
|
67
|
+
# @param [String] uuid
|
68
|
+
# return [TollfreeVerification]
|
69
|
+
def get(uuid)
|
70
|
+
valid_param?(:uuid, uuid, [String, Symbol], true)
|
71
|
+
perform_get(uuid)
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# List all TollfreeVerification
|
76
|
+
# @param [Hash] options
|
77
|
+
# @option options [Int] :offset
|
78
|
+
# @option options [Int] :limit
|
79
|
+
# @return [Hash]
|
80
|
+
def list(options = nil)
|
81
|
+
return perform_list if options.nil?
|
82
|
+
valid_param?(:options, options, Hash, true)
|
83
|
+
|
84
|
+
params = {}
|
85
|
+
params_expected = %i[ profile_uuid number status created__lt created__gt usecase created__lte created__gte ]
|
86
|
+
params_expected.each do |param|
|
87
|
+
if options.key?(param) &&
|
88
|
+
valid_param?(param, options[param], [String, Symbol], true)
|
89
|
+
params[param] = options[param]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
%i[offset limit].each do |param|
|
94
|
+
if options.key?(param) && valid_param?(param, options[param],
|
95
|
+
[Integer], true)
|
96
|
+
params[param] = options[param]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
|
101
|
+
|
102
|
+
if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
|
103
|
+
raise_invalid_request('The maximum number of results that can be '\
|
104
|
+
"fetched is 20. limit can't be more than 20 or less than 1")
|
105
|
+
end
|
106
|
+
|
107
|
+
perform_list(params)
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Create an TollfreeVerification
|
112
|
+
# @param [String] number
|
113
|
+
# @param [String] usecase
|
114
|
+
# @param [String] usecase_summary
|
115
|
+
# @param [String] profile_uuid
|
116
|
+
# @param [String] optin_type
|
117
|
+
# @param [String] optin_image_url
|
118
|
+
# @param [String] volume
|
119
|
+
# @param [String] message_sample
|
120
|
+
# @param [String] callback_url
|
121
|
+
# @param [String] callback_method
|
122
|
+
# @param [String] extra_data
|
123
|
+
# @param [String] additional_information
|
124
|
+
# return [TollfreeVerification] TollfreeVerification
|
125
|
+
def create(number, usecase, usecase_summary, profile_uuid, optin_type, optin_image_url, volume, message_sample, callback_url = nil, callback_method = nil, extra_data = nil, additional_information = nil)
|
126
|
+
valid_param?(:number, number, [String, Symbol], true)
|
127
|
+
valid_param?(:usecase, usecase, [String, Symbol], true)
|
128
|
+
valid_param?(:usecase_summary, usecase_summary, [String, Symbol], true)
|
129
|
+
valid_param?(:profile_uuid, profile_uuid, [String, Symbol], true)
|
130
|
+
valid_param?(:optin_type, optin_type, [String, Symbol], true)
|
131
|
+
valid_param?(:optin_image_url, optin_image_url, [String, Symbol], true)
|
132
|
+
valid_param?(:volume, volume, [String, Symbol], true)
|
133
|
+
valid_param?(:message_sample, message_sample, [String, Symbol], true)
|
134
|
+
valid_param?(:callback_url, callback_url, [String, Symbol], false)
|
135
|
+
valid_param?(:callback_method, callback_method, [String, Symbol], false)
|
136
|
+
valid_param?(:extra_data, extra_data, [String, Symbol], false)
|
137
|
+
valid_param?(:additional_information, additional_information, [String, Symbol], false)
|
138
|
+
|
139
|
+
params = {
|
140
|
+
number: number,
|
141
|
+
usecase: usecase,
|
142
|
+
usecase_summary: usecase_summary,
|
143
|
+
profile_uuid: profile_uuid,
|
144
|
+
optin_type: optin_type,
|
145
|
+
optin_image_url: optin_image_url,
|
146
|
+
volume: volume,
|
147
|
+
message_sample: message_sample,
|
148
|
+
callback_url: callback_url,
|
149
|
+
callback_method: callback_method,
|
150
|
+
extra_data: extra_data,
|
151
|
+
additional_information: additional_information
|
152
|
+
}.delete_if { |key, value| value.nil? }
|
153
|
+
|
154
|
+
return perform_create(params)
|
155
|
+
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# Update an TollfreeVerification
|
159
|
+
# @param [String] uuid
|
160
|
+
# @param [Hash] options
|
161
|
+
# return [TollfreeVerification]
|
162
|
+
def update(uuid, options = nil)
|
163
|
+
valid_param?(:uuid, uuid, [String, Symbol], true)
|
164
|
+
TollfreeVerification.new(@_client,
|
165
|
+
resource_id: uuid).update(options)
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# Delete an TollfreeVerification.
|
170
|
+
# @param [String] uuid
|
171
|
+
def delete(uuid)
|
172
|
+
valid_param?(:uuid, uuid, [String, Symbol], true)
|
173
|
+
TollfreeVerification.new(@_client,
|
174
|
+
resource_id: uuid).delete
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Plivo
|
2
|
+
module Resources
|
3
|
+
include Plivo::Utils
|
4
|
+
class Verify < Base::Resource
|
5
|
+
def initialize(client, options = nil)
|
6
|
+
@_name = 'Verify'
|
7
|
+
@_identifier_string = 'api_id'
|
8
|
+
super
|
9
|
+
end
|
10
|
+
def to_s
|
11
|
+
{
|
12
|
+
api_id: @api_id,
|
13
|
+
alias: @alias,
|
14
|
+
country: @country,
|
15
|
+
created_at: @created_at,
|
16
|
+
modified_at: @modified_at,
|
17
|
+
phone_number: @phone_number,
|
18
|
+
subaccount: @subaccount,
|
19
|
+
verification_uuid: @verification_uuid
|
20
|
+
}.to_s
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class VerifyCallerIdInterface < Base::ResourceInterface
|
25
|
+
def initialize(client, resource_list_json = nil)
|
26
|
+
@_name = 'VerifiedCallerId'
|
27
|
+
@_resource_type = Verify
|
28
|
+
@_identifier_string = 'api_id'
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def initiate(phone_number = nil, channel = nil, alias_ = nil, subaccount = nil)
|
33
|
+
valid_param?(:phone_number, phone_number, [String], true)
|
34
|
+
valid_param?(:channel, channel, [String], false)
|
35
|
+
valid_param?(:alias, alias_, [String], false)
|
36
|
+
valid_param?(:subaccount, subaccount, [String], false)
|
37
|
+
|
38
|
+
params = {
|
39
|
+
phone_number: phone_number,
|
40
|
+
channel: channel,
|
41
|
+
alias: alias_,
|
42
|
+
subaccount: subaccount
|
43
|
+
}
|
44
|
+
perform_create(params)
|
45
|
+
end
|
46
|
+
|
47
|
+
def verify(verification_uuid = nil, otp = nil)
|
48
|
+
valid_param?(:verification_uuid, verification_uuid, [String], true)
|
49
|
+
valid_param?(:otp, otp, [String], true)
|
50
|
+
id = 'Verification/' + verification_uuid
|
51
|
+
params = {
|
52
|
+
otp: otp
|
53
|
+
}
|
54
|
+
perform_action_with_identifier(id, 'POST', params)
|
55
|
+
end
|
56
|
+
|
57
|
+
def update(phone_number = nil, subaccount = nil, alias_ = nil)
|
58
|
+
valid_param?(:phone_number, phone_number, [String], true)
|
59
|
+
valid_param?(:subaccount, subaccount, [String], false)
|
60
|
+
valid_param?(:alias, alias_, [String], false)
|
61
|
+
params = {
|
62
|
+
subaccount: subaccount,
|
63
|
+
alias: alias_
|
64
|
+
}
|
65
|
+
perform_action_with_identifier(phone_number, 'POST', params)
|
66
|
+
end
|
67
|
+
|
68
|
+
def get(phone_number = nil)
|
69
|
+
valid_param?(:phone_number, phone_number, [String], true)
|
70
|
+
perform_get(phone_number)
|
71
|
+
end
|
72
|
+
|
73
|
+
def list(options = nil)
|
74
|
+
return perform_list_without_object if options.nil?
|
75
|
+
valid_param?(:options, options, Hash, false)
|
76
|
+
|
77
|
+
params = {}
|
78
|
+
params_expected = %i[subaccount country alias]
|
79
|
+
|
80
|
+
params_expected.each do |param|
|
81
|
+
if options.key?(param) &&
|
82
|
+
valid_param?(param, options[param], [String, Symbol], false)
|
83
|
+
params[param] = options[param]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
%i[offset limit].each do |param|
|
88
|
+
if options.key?(param) &&
|
89
|
+
valid_param?(param, options[param], [Integer, Integer], false)
|
90
|
+
params[param] = options[param]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
if options.key?(:limit) &&
|
95
|
+
(options[:limit] > 20 || options[:limit] <= 0)
|
96
|
+
raise_invalid_request('The maximum number of results that can be '\
|
97
|
+
"fetched is 20. limit can't be more than 20 or less than 1")
|
98
|
+
end
|
99
|
+
|
100
|
+
raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
|
101
|
+
|
102
|
+
perform_list_without_object(params)
|
103
|
+
end
|
104
|
+
|
105
|
+
def delete(phone_number)
|
106
|
+
perform_delete(phone_number, nil)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|