plivo 4.15.2 → 4.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9623fb2c4baf69935048acfa538cb061326de346
4
- data.tar.gz: 30629da34bc63fed7092e9c264c34cd41a496870
3
+ metadata.gz: e6a3db3d74dfd421dc5abd1ff8d789461c2af629
4
+ data.tar.gz: ceb2c8debfa9704d378f59a920f9edbe4f1809e1
5
5
  SHA512:
6
- metadata.gz: 69b585a499ec727dbc3f615d654b429f39a3f699028994de89cb79298b333e0a2d54501697644f579f4266fadc7bc0bb4fd4a43d50f021722e2defda30d8f979
7
- data.tar.gz: 843e1f620186e4c8e6153f8a2cac6793c666e49479382622e9d24fa2452801fe99c7240480b2b04495e45d939d4731f11910607617e0b1eee815f73ebf5fd43f
6
+ metadata.gz: 7c579fb2504706df20e2d56dfa5856fffb69f6a024f005eeeb44f2c54b700c4f52f1749675c7fc4554fa4a61dcc9d905114f8e0648ddb5e51a2567d35be820c6
7
+ data.tar.gz: f567d3806d6ba132efed4dcdab2fed7b16290f9bcc2c8b73322bf67908aabbf7658ab424b30ec473720d0f99989f997713631d3489695377fd1ea92f44243615
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.18.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.18.0) (2021-07-13)
4
+ - Power pack ID has been included to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message).
5
+ - Support for filtering messages by Power pack ID has been added to the [list all messages API](https://www.plivo.com/docs/sms/api/message#list-all-messages).
6
+
7
+ ## [4.17.1](https://github.com/plivo/plivo-ruby/releases/tag/v4.17.1) (2021-06-18)
8
+ - **WARNING**: Remove total_count field from meta data for list MDR response
9
+
10
+ ## [4.17.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.17.0) (2021-06-15)
11
+ - Added stir verification param as part of Get CDR and live call APIs response.
12
+
13
+ ## [4.16.0](https://github.com/plivo/plivo-ruby/releases/tag/v4.16.0) (2021-02-08)
14
+ - Add support for Regulatory Compliance APIs.
15
+
3
16
  ## [4.15.2](https://github.com/plivo/plivo-ruby/releases/tag/v4.15.2) (2021-01-27)
4
17
  - Fix Call API resource - Set answer_method as Optional param.
5
18
 
data/README.md CHANGED
@@ -8,7 +8,9 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'plivo', '>= 4.15.2'
11
+
12
+ gem 'plivo', '>= 4.18.0'
13
+
12
14
  ```
13
15
 
14
16
  And then execute:
@@ -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
+ # }
@@ -59,6 +59,12 @@ module Plivo
59
59
  )
60
60
  end
61
61
 
62
+ def perform_submit(identifier, params = nil)
63
+ valid_param?(:identifier, identifier, [String, Symbol], true)
64
+ response_json = @_client.send_request(@_resource_uri + identifier.to_s + '/Submit/', 'POST', params, nil, false, is_voice_request: @_is_voice_request)
65
+ @_resource_type.new(@_client, resource_json: response_json)
66
+ end
67
+
62
68
  def perform_post(params)
63
69
  response_json = @_client.send_request(@_resource_uri, 'POST', params, nil, false, is_voice_request: @_is_voice_request)
64
70
 
@@ -16,6 +16,7 @@ require_relative 'resources/phlo_member'
16
16
  require_relative 'resources/call_feedback'
17
17
  require_relative 'resources/media'
18
18
  require_relative 'resources/lookup'
19
+ require_relative 'resources/regulatory_compliance'
19
20
 
20
21
  module Plivo
21
22
  module Resources
@@ -230,7 +230,8 @@ module Plivo
230
230
  from: @from,
231
231
  request_uuid: @request_uuid,
232
232
  direction: @direction,
233
- caller_name: @caller_name
233
+ caller_name: @caller_name,
234
+ stir_verification: @stir_verification
234
235
  }
235
236
  call_details = call_details.select {|k, v| !v.nil? }
236
237
  call_details.to_s
@@ -29,6 +29,7 @@ module Plivo
29
29
  to_number: @to_number,
30
30
  total_amount: @total_amount,
31
31
  total_rate: @total_rate,
32
+ powerpack_id: @powerpack_id,
32
33
  units: @units
33
34
  }.to_s
34
35
  end
@@ -152,8 +153,7 @@ module Plivo
152
153
  # @option options [Int] :limit Used to display the number of results per page. The maximum number of results that can be fetched is 20.
153
154
  # @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.
154
155
  # @option options [String] :error_code Delivery Response code returned by the carrier attempting the delivery. See Supported error codes {https://www.plivo.com/docs/api/message/#standard-plivo-error-codes}.
155
- #@option options[List]: media_urls Minimum one media url should be present in Media urls list to send mms. Maximum allowd 10 media urls inside the list (e.g, media_urls : ['https//example.com/test.jpg', 'https://example.com/abcd.gif'])
156
- #@option options[List]: media_ids Minimum one media ids should be present in Media ids list to send mms. Maximum allowd 10 media ids inside the list (e.g, media_ids : ['1fs211ba-355b-11ea-bbc9-02121c1190q7'])
156
+ # @option options [String] :powerpack_id Filter the results by powerpack id.
157
157
  def list(options = nil)
158
158
  return perform_list if options.nil?
159
159
  valid_param?(:options, options, Hash, true)
@@ -161,7 +161,7 @@ module Plivo
161
161
  params = {}
162
162
  params_expected = %i[
163
163
  subaccount message_time message_time__gt message_time__gte
164
- message_time__lt message_time__lte error_code
164
+ message_time__lt message_time__lte error_code powerpack_id
165
165
  ]
166
166
  params_expected.each do |param|
167
167
  if options.key?(param) &&
@@ -0,0 +1,610 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+
5
+ class EndUser < Base::Resource
6
+ def initialize(client, options = nil)
7
+ @_name = 'EndUser'
8
+ @_identifier_string = 'end_user'
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[ name last_name ]
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
+ if options.key?(:end_user_type) &&
27
+ valid_param?(:end_user_type, options[:end_user_type].capitalize,[String, Symbol], false, %w[Business Individual])
28
+ params[:end_user_type] = options[:end_user_type].capitalize
29
+ end
30
+
31
+ perform_update(params)
32
+ end
33
+
34
+ def delete
35
+ perform_delete
36
+ end
37
+
38
+ def to_s
39
+ {
40
+ api_id: @api_id,
41
+ end_user_id: @end_user_id,
42
+ end_user_type: @end_user_type,
43
+ name: @name,
44
+ last_name: @last_name,
45
+ created_at: @created_at
46
+ }.delete_if { |key, value| value.nil? }.to_s
47
+ end
48
+ end
49
+
50
+ class EndUsersInterface < Base::ResourceInterface
51
+ def initialize(client, resource_list_json = nil)
52
+ @_name = 'EndUser'
53
+ @_resource_type = EndUser
54
+ @_identifier_string = 'end_user'
55
+ super
56
+ end
57
+
58
+ ##
59
+ # Get an EndUser
60
+ # @param [String] end_user_id
61
+ # return [EndUser]
62
+ def get(end_user_id)
63
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
64
+ perform_get(end_user_id)
65
+ end
66
+
67
+ ##
68
+ # List all EndUser
69
+ # @param [Hash] options
70
+ # @option options [Int] :offset
71
+ # @option options [Int] :limit
72
+ # @return [Hash]
73
+ def list(options = nil)
74
+ return perform_list if options.nil?
75
+ valid_param?(:options, options, Hash, true)
76
+
77
+ params = {}
78
+ params_expected = %i[ name last_name ]
79
+ params_expected.each do |param|
80
+ if options.key?(param) &&
81
+ valid_param?(param, options[param], [String, Symbol], false)
82
+ params[param] = options[param]
83
+ end
84
+ end
85
+
86
+ if options.key?(:end_user_type) &&
87
+ valid_param?(:end_user_type, options[:end_user_type].capitalize,[String, Symbol], false, %w[Business Individual])
88
+ params[:end_user_type] = options[:end_user_type].capitalize
89
+ end
90
+
91
+ %i[offset limit].each do |param|
92
+ if options.key?(param) && valid_param?(param, options[param],
93
+ [Integer], true)
94
+ params[param] = options[param]
95
+ end
96
+ end
97
+
98
+ raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
99
+
100
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
101
+ raise_invalid_request('The maximum number of results that can be '\
102
+ "fetched is 20. limit can't be more than 20 or less than 1")
103
+ end
104
+
105
+ perform_list(params)
106
+ end
107
+
108
+ ##
109
+ # Create an EndUser
110
+ # @param [String] name
111
+ # @param [String] last_name
112
+ # @param [String] end_user_type
113
+ # return [EndUser] EndUser
114
+ def create(name, last_name = nil , end_user_type)
115
+ valid_param?(:name, name, [String, Symbol], true)
116
+ valid_param?(:last_name, last_name, [String, Symbol], false)
117
+ valid_param?(:end_user_type, end_user_type.capitalize, [String, Symbol], true, %w[Business Individual])
118
+
119
+ params = {
120
+ name: name,
121
+ last_name: last_name,
122
+ end_user_type: end_user_type.capitalize
123
+ }
124
+
125
+ return perform_create(params)
126
+ end
127
+
128
+ ##
129
+ # Update an EndUser
130
+ # @param [String] end_user_id
131
+ # @param [Hash] options
132
+ # return [EndUser]
133
+ def update(end_user_id, options = nil)
134
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
135
+ EndUser.new(@_client,
136
+ resource_id: end_user_id).update(options)
137
+ end
138
+
139
+ ##
140
+ # Delete an EndUser.
141
+ # @param [String] end_user_id
142
+ def delete(end_user_id)
143
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
144
+ EndUser.new(@_client,
145
+ resource_id: end_user_id).delete
146
+ end
147
+ end
148
+
149
+ class ComplianceDocumentType < Base::Resource
150
+ def initialize(client, options = nil)
151
+ @_name = 'ComplianceDocumentType'
152
+ @_identifier_string = 'compliance_document_type'
153
+ super
154
+ end
155
+
156
+ def to_s
157
+ {
158
+ api_id: @api_id,
159
+ document_type_id: @document_type_id,
160
+ document_name: @document_name,
161
+ description: @description,
162
+ information: @information,
163
+ proof_required: @proof_required,
164
+ created_at: @created_at
165
+ }.delete_if { |key, value| key==:api_id && value.nil? }.to_s
166
+ end
167
+ end
168
+
169
+ class ComplianceDocumentTypesInterface < Base::ResourceInterface
170
+ def initialize(client, resource_list_json = nil)
171
+ @_name = 'ComplianceDocumentType'
172
+ @_resource_type = ComplianceDocumentType
173
+ @_identifier_string = 'compliance_document_type'
174
+ super
175
+ end
176
+
177
+ # Get a ComplianceDocumentType
178
+ # @param [String] document_type_id
179
+ # @return [ComplianceDocumentType] ComplianceDocumentType
180
+ def get(document_type_id)
181
+ valid_param?(:document_type_id, document_type_id, [String, Symbol], true)
182
+ perform_get(document_type_id)
183
+ end
184
+
185
+ ##
186
+ # List all ComplianceDocumentTypes
187
+ # @option options [Int] :offset
188
+ # @option options [Int] :limit
189
+ # @return [Hash]
190
+ def list(options = nil)
191
+ return perform_list if options.nil?
192
+ valid_param?(:options, options, Hash, false)
193
+
194
+ params = {}
195
+ %i[offset limit].each do |param|
196
+ if options.key?(param) && valid_param?(param, options[param],
197
+ [Integer], false)
198
+ params[param] = options[param]
199
+ end
200
+ end
201
+
202
+ raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
203
+
204
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
205
+ raise_invalid_request('The maximum number of results that can be '\
206
+ "fetched is 20. limit can't be more than 20 or less than 1")
207
+ end
208
+
209
+ perform_list(params)
210
+ end
211
+ end
212
+
213
+ class ComplianceDocument < Base::Resource
214
+ def initialize(client, options = nil)
215
+ @_name = 'ComplianceDocument'
216
+ @_identifier_string = 'compliance_document'
217
+ super
218
+ end
219
+
220
+ def delete
221
+ perform_delete
222
+ end
223
+
224
+ def update(params)
225
+ perform_update(params, use_multipart_conn: true)
226
+ end
227
+
228
+ def to_s
229
+ {
230
+ api_id: @api_id,
231
+ end_user_id: @end_user_id,
232
+ document_type_id: @document_type_id,
233
+ compliance_document_id: @compliance_document_id,
234
+ document_id: @document_id,
235
+ alias: @alias,
236
+ meta_information: @meta_information,
237
+ file: @file,
238
+ file_name: @file_name,
239
+ created_at: @created_at
240
+ }.delete_if { |key, value| value.nil? }.to_s
241
+ end
242
+ end
243
+
244
+ class ComplianceDocumentsInterface < Base::ResourceInterface
245
+ def initialize(client, resource_list_json = nil)
246
+ @_name = 'ComplianceDocument'
247
+ @_resource_type = ComplianceDocument
248
+ @_identifier_string = 'compliance_document'
249
+ super
250
+ end
251
+
252
+ # Get a ComplianceDocument
253
+ # @param [String] compliance_document_id
254
+ # @return [ComplianceDocument] ComplianceDocument
255
+ def get(compliance_document_id)
256
+ valid_param?(:compliance_document_id, compliance_document_id, [String, Symbol], true)
257
+ perform_get(compliance_document_id)
258
+ end
259
+
260
+ # List all ComplianceDocuments
261
+ # @option options [Hash] :options
262
+ # @option options [Int] :offset
263
+ # @option options [Int] :limit
264
+ # @return [Hash]
265
+ def list(options = nil)
266
+ return perform_list if options.nil?
267
+ valid_param?(:options, options, Hash, false)
268
+
269
+ params = {}
270
+
271
+ params_expected = %i[ end_user_id document_type_id ]
272
+ params_expected.each do |param|
273
+ if options.key?(param) &&
274
+ valid_param?(param, options[param], [String, Symbol], false)
275
+ params[param] = options[param]
276
+ end
277
+ end
278
+
279
+ if options.key?(:alias) && valid_param?(:alias, options[:alias],[String, Symbol], false)
280
+ params[:alias] = options[:alias]
281
+ end
282
+
283
+ %i[offset limit].each do |param|
284
+ if options.key?(param) && valid_param?(param, options[param],
285
+ [Integer], true)
286
+ params[param] = options[param]
287
+ end
288
+ end
289
+
290
+ raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
291
+
292
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
293
+ raise_invalid_request('The maximum number of results that can be '\
294
+ "fetched is 20. limit can't be more than 20 or less than 1")
295
+ end
296
+
297
+ perform_list(params)
298
+ end
299
+
300
+ # Create a ComplianceDocument
301
+ # @param [String] end_user_id
302
+ # @param [String] document_type_id
303
+ # @param [String] alias_
304
+ # @param [String] file
305
+ # @param [Hash] options
306
+ # @return [ComplianceDocument] ComplianceDocument
307
+ def create(end_user_id: nil , document_type_id: nil, alias_: nil, file: nil, **options)
308
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
309
+ valid_param?(:document_type_id, document_type_id, [String, Symbol], true)
310
+ valid_param?(:alias, :alias_, [String, Symbol], true)
311
+
312
+ params = {
313
+ end_user_id: end_user_id,
314
+ document_type_id: document_type_id,
315
+ alias: alias_
316
+ }
317
+
318
+ if !options.nil?
319
+ valid_param?(:options, options, Hash, false)
320
+ options.each do |key, value|
321
+ if valid_param?(key, value, [String, Symbol], false)
322
+ params[key] = value
323
+ end
324
+ end
325
+ end
326
+
327
+ upload(file, params) if !file.nil?
328
+
329
+ perform_create(params, use_multipart_conn: true)
330
+ end
331
+
332
+ # Update a ComplianceDocument
333
+ # @param [String] compliance_document_id
334
+ # @param [Hash] options
335
+ # return [ComplianceDocument] ComplianceDocument
336
+ def update(compliance_document_id, options = nil)
337
+ valid_param?(:compliance_document_id, compliance_document_id, [String, Symbol], true)
338
+ valid_param?(:options, options, Hash, true) if !options.nil?
339
+ params = {}
340
+
341
+ options.each do |key, value|
342
+ params[key] = value
343
+ end
344
+
345
+ upload(params[:file], params) if params.key?(:file)
346
+
347
+ ComplianceDocument.new(@_client, resource_id: compliance_document_id).update(params)
348
+ end
349
+
350
+ # Delete a ComplianceDocument
351
+ # @param [String] compliance_document_id
352
+ def delete(compliance_document_id)
353
+ valid_param?(:compliance_document_id, compliance_document_id, [String, Symbol], true)
354
+ ComplianceDocument.new(@_client, resource_id: compliance_document_id).delete
355
+ end
356
+
357
+ private
358
+
359
+ def upload(filepath, params)
360
+ file_extension = filepath.split('.')[-1]
361
+
362
+ content_type = case file_extension
363
+ when 'jpeg' then 'image/jpeg'
364
+ when 'jpg' then 'image/jpeg'
365
+ when 'png' then 'image/png'
366
+ when 'pdf' then 'application/pdf'
367
+ else raise_invalid_request("#{file_extension} is not supported for upload")
368
+ end
369
+
370
+ params[:file] = Faraday::UploadIO.new(filepath, content_type)
371
+ end
372
+ end
373
+
374
+ class ComplianceRequirement < Base::Resource
375
+ def initialize(client, options = nil)
376
+ @_name = 'ComplianceRequirement'
377
+ @_identifier_string = 'compliance_requirement'
378
+ super
379
+ end
380
+
381
+ def to_s
382
+ {
383
+ api_id: @api_id,
384
+ compliance_requirement_id: @compliance_requirement_id,
385
+ country_iso2: @country_iso2,
386
+ number_type: @number_type,
387
+ end_user_type: @end_user_type,
388
+ acceptable_document_types: @acceptable_document_types
389
+ }.delete_if { |key, value| value.nil? }.to_s
390
+ end
391
+ end
392
+
393
+ class ComplianceRequirementsInterface < Base::ResourceInterface
394
+ def initialize(client, resource_list_json = nil)
395
+ @_name = 'ComplianceRequirement'
396
+ @_resource_type = ComplianceRequirement
397
+ @_identifier_string = 'compliance_requirement'
398
+ super
399
+ end
400
+
401
+ # Get a ComplianceRequirement
402
+ # @param [String] compliance_requirement_id
403
+ # @return [ComplianceRequirement] ComplianceRequirement
404
+ def get(compliance_requirement_id)
405
+ valid_param?(:compliance_requirement_id, compliance_requirement_id, [String, Symbol], true)
406
+ perform_get(compliance_requirement_id)
407
+ end
408
+
409
+ # List all ComplianceRequirements
410
+ # @option options [String] :country_iso2
411
+ # @option options [String] :number_type
412
+ # @option options [String] :phone_number
413
+ # @option options [String] :end_user_type
414
+ # A combination of country_iso2, number_type, end_user_type OR
415
+ # phone_number, end_user_type can be used to fetch compliance requirements.
416
+ def list(options = nil)
417
+ valid_param?(:options, options, Hash, true)
418
+
419
+ params = {}
420
+ params_expected = %i[ country_iso2 number_type phone_number ]
421
+ params_expected.each do |param|
422
+ if options.key?(param) &&
423
+ valid_param?(param, options[param], [String, Symbol], false)
424
+ params[param] = options[param]
425
+ end
426
+ end
427
+
428
+ if options.key?(:end_user_type) &&
429
+ valid_param?(:end_user_type, options[:end_user_type].capitalize, [String, Symbol], false, %w[Business Individual])
430
+ params[:end_user_type] = options[:end_user_type].capitalize
431
+ end
432
+
433
+ perform_get_without_identifier(params)
434
+ end
435
+ end
436
+
437
+ class ComplianceApplication < Base::Resource
438
+ def initialize(client, options = nil)
439
+ @_name = 'ComplianceApplication'
440
+ @_identifier_string = 'compliance_application'
441
+ super
442
+ end
443
+
444
+ def to_s
445
+ {
446
+ api_id: @api_id,
447
+ created_at: @created_at,
448
+ compliance_application_id: @compliance_application_id,
449
+ alias: @alias,
450
+ status: @status,
451
+ end_user_id: @end_user_id,
452
+ end_user_type: @end_user_type,
453
+ country_iso2: @country_iso2,
454
+ number_type: @number_type,
455
+ compliance_requirement_id: @compliance_requirement_id,
456
+ documents: @documents,
457
+ }.delete_if { |key, value| value.nil? }.to_s
458
+ end
459
+
460
+ def update(params)
461
+ perform_update(params)
462
+ end
463
+
464
+ def delete
465
+ perform_delete
466
+ end
467
+ end
468
+
469
+ class ComplianceApplicationsInterface < Base::ResourceInterface
470
+ def initialize(client, resource_list_json = nil)
471
+ @_name = 'ComplianceApplication'
472
+ @_resource_type = ComplianceApplication
473
+ @_identifier_string = 'compliance_application'
474
+ super
475
+ end
476
+
477
+ # Get a ComplianceApplication
478
+ # @param [String] compliance_application_id
479
+ # @return [ComplianceApplication] ComplianceApplication
480
+ def get(compliance_application_id)
481
+ valid_param?(:compliance_application_id, compliance_application_id, [String, Symbol], true)
482
+ perform_get(compliance_application_id)
483
+ end
484
+
485
+ # List all ComplianceApplications
486
+ # @option options [Hash] :options
487
+ # @option options [Int] :offset
488
+ # @option options [Int] :limit
489
+ # @return [Hash]
490
+ def list(options = nil)
491
+ return perform_list if options.nil?
492
+ valid_param?(:options, options, Hash, true)
493
+
494
+ params = {}
495
+ params_expected = %i[ end_user_id country_iso2 number_type status ]
496
+ params_expected.each do |param|
497
+ if options.key?(param) &&
498
+ valid_param?(param, options[param], [String, Symbol], false)
499
+ params[param] = options[param]
500
+ end
501
+ end
502
+
503
+ if options.key?(:end_user_type) &&
504
+ valid_param?(:end_user_type, options[:end_user_type].capitalize, [String, Symbol], false, %w[Business Individual])
505
+ params[:end_user_type] = options[:end_user_type].capitalize
506
+ end
507
+
508
+ if options.key?(:alias) && valid_param?(:alias, options[:alias],[String, Symbol], false)
509
+ params[:alias] = options[:alias]
510
+ end
511
+
512
+ %i[offset limit].each do |param|
513
+ if options.key?(param) && valid_param?(param, options[param],
514
+ [Integer], true)
515
+ params[param] = options[param]
516
+ end
517
+ end
518
+
519
+ raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
520
+
521
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
522
+ raise_invalid_request('The maximum number of results that can be '\
523
+ "fetched is 20. limit can't be more than 20 or less than 1")
524
+ end
525
+
526
+ perform_list(params)
527
+ end
528
+
529
+ # Create a ComplianceApplication
530
+ # @param [String] compliance_requirement_id
531
+ # @param [String] end_user_id
532
+ # @param [String] alias_
533
+ # @param [Array] document_ids
534
+ # @param [String] end_user_type
535
+ # @param [String] country_iso2
536
+ # @param [String] number_type
537
+ # @return [ComplianceApplication] ComplianceApplication
538
+ def create(compliance_requirement_id: nil, end_user_id: nil, alias_: nil,
539
+ document_ids: nil,
540
+ end_user_type: nil,
541
+ country_iso2: nil,
542
+ number_type: nil
543
+ )
544
+ valid_param?(:compliance_requirement_id, compliance_requirement_id, [String, Symbol], false)
545
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], false)
546
+ valid_param?(:alias_, alias_, [String, Symbol], false)
547
+ valid_param?(:country_iso2, country_iso2, [String, Symbol], false)
548
+ valid_param?(:number_type, number_type, [String, Symbol], false)
549
+ valid_param?(:document_ids, document_ids, [Array], false)
550
+ if !document_ids.nil?
551
+ document_ids.each do |document_id|
552
+ valid_param?(:document_id, document_id, [String, Symbol], true)
553
+ end
554
+ end
555
+
556
+ if !end_user_type.nil?
557
+ end_user_type = end_user_type.downcase
558
+ valid_param?(:end_user_type, end_user_type, [String, Symbol], false, %w[business individual])
559
+ end
560
+
561
+ params = {
562
+ compliance_requirement_id: compliance_requirement_id,
563
+ end_user_id: end_user_id,
564
+ end_user_type: end_user_type,
565
+ country_iso2: country_iso2,
566
+ number_type: number_type,
567
+ document_ids: document_ids,
568
+ alias: alias_
569
+ }.delete_if { |key, value| value.nil? }
570
+
571
+ perform_create(params, false)
572
+ end
573
+
574
+ # Update a ComplianceApplication
575
+ # @param [String] compliance_application_id
576
+ # @param [Array] document_ids
577
+ # @return [ComplianceApplication] ComplianceApplication
578
+ def update(compliance_application_id, document_ids)
579
+ valid_param?(:compliance_application_id, compliance_application_id, [String, Symbol], true)
580
+ valid_param?(:document_ids, document_ids, [Array], true)
581
+ document_ids.each do |document_id|
582
+ valid_param?(:document_id, document_id, [String, Symbol], true)
583
+ end
584
+
585
+ params = {
586
+ compliance_application_id: compliance_application_id,
587
+ document_ids: document_ids
588
+ }
589
+
590
+ ComplianceApplication.new(@_client,
591
+ resource_id: compliance_application_id).update(params)
592
+ end
593
+
594
+ # Delete a ComplianceApplication
595
+ # @param [String] compliance_application_id
596
+ def delete(compliance_application_id)
597
+ valid_param?(:compliance_application_id, compliance_application_id, [String, Symbol], true)
598
+ ComplianceApplication.new(@_client,
599
+ resource_id: compliance_application_id).delete
600
+ end
601
+
602
+ # Submit a ComplianceApplication
603
+ # @param [String] compliance_application_id
604
+ def submit(compliance_application_id)
605
+ valid_param?(:compliance_application_id, compliance_application_id, [String, Symbol], true)
606
+ perform_submit(compliance_application_id)
607
+ end
608
+ end
609
+ end
610
+ end
@@ -14,6 +14,8 @@ module Plivo
14
14
  attr_reader :powerpacks
15
15
  attr_reader :powerpacks, :media
16
16
  attr_reader :lookup
17
+ attr_reader :end_users
18
+ attr_reader :compliance_document_types, :compliance_documents, :compliance_requirements, :compliance_applications
17
19
 
18
20
  def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout = 5)
19
21
  configure_base_uri
@@ -50,6 +52,11 @@ module Plivo
50
52
  @identities = Resources::IdentityInterface.new(self)
51
53
  @call_feedback = Resources::CallFeedbackInterface.new(self)
52
54
  @lookup = Resources::LookupInterface.new(self)
55
+ @end_users = Resources::EndUsersInterface.new(self)
56
+ @compliance_document_types = Resources::ComplianceDocumentTypesInterface.new(self)
57
+ @compliance_documents = Resources::ComplianceDocumentsInterface.new(self)
58
+ @compliance_requirements = Resources::ComplianceRequirementsInterface.new(self)
59
+ @compliance_applications = Resources::ComplianceApplicationsInterface.new(self)
53
60
  end
54
61
  end
55
62
  end
data/lib/plivo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = "4.15.2".freeze
2
+ VERSION = "4.18.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.15.2
4
+ version: 4.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Plivo SDKs Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-27 00:00:00.000000000 Z
11
+ date: 2021-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -168,6 +168,7 @@ files:
168
168
  - examples/lookup.rb
169
169
  - examples/multi_party_call.rb
170
170
  - examples/phlos.rb
171
+ - examples/regulatory_compliance.rb
171
172
  - lib/plivo.rb
172
173
  - lib/plivo/base.rb
173
174
  - lib/plivo/base/resource.rb
@@ -196,6 +197,7 @@ files:
196
197
  - lib/plivo/resources/powerpacks.rb
197
198
  - lib/plivo/resources/pricings.rb
198
199
  - lib/plivo/resources/recordings.rb
200
+ - lib/plivo/resources/regulatory_compliance.rb
199
201
  - lib/plivo/rest_client.rb
200
202
  - lib/plivo/utils.rb
201
203
  - lib/plivo/version.rb