twilio-ruby 7.1.0 → 7.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,169 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Marketplace
8
+ # This is the public Twilio REST API.
9
+ #
10
+ # NOTE: This class is auto generated by OpenAPI Generator.
11
+ # https://openapi-generator.tech
12
+ # Do not edit the class manually.
13
+ #
14
+
15
+
16
+ module Twilio
17
+ module REST
18
+ class Marketplace < MarketplaceBase
19
+ class V1 < Version
20
+ class InstalledAddOnContext < InstanceContext
21
+
22
+ class InstalledAddOnUsageList < ListResource
23
+
24
+ class CreateMarketplaceBillingUsageRequest
25
+ # @param [billable_items]: [Array<InstalledAddOnUsageList.CreateMarketplaceBillingUsageRequestBillableItems>]
26
+ attr_accessor :billable_items
27
+ def initialize(payload)
28
+ @billable_items = payload["billable_items"]
29
+ end
30
+ def to_json(options = {})
31
+ {
32
+ billable_items: @billable_items,
33
+ }.to_json(options)
34
+ end
35
+ end
36
+
37
+ class CreateMarketplaceBillingUsageRequestBillableItems
38
+ # @param [quantity]: [Float]
39
+ # @param [sid]: [String]
40
+ attr_accessor :quantity, :sid
41
+ def initialize(payload)
42
+ @quantity = payload["quantity"]
43
+ @sid = payload["sid"]
44
+ end
45
+ def to_json(options = {})
46
+ {
47
+ quantity: @quantity,
48
+ sid: @sid,
49
+ }.to_json(options)
50
+ end
51
+ end
52
+
53
+ ##
54
+ # Initialize the InstalledAddOnUsageList
55
+ # @param [Version] version Version that contains the resource
56
+ # @return [InstalledAddOnUsageList] InstalledAddOnUsageList
57
+ def initialize(version, installed_add_on_sid: nil)
58
+ super(version)
59
+ # Path Solution
60
+ @solution = { installed_add_on_sid: installed_add_on_sid }
61
+ @uri = "/InstalledAddOns/#{@solution[:installed_add_on_sid]}/Usage"
62
+
63
+ end
64
+ ##
65
+ # Create the InstalledAddOnUsageInstance
66
+ # @param [CreateMarketplaceBillingUsageRequest] create_marketplace_billing_usage_request
67
+ # @return [InstalledAddOnUsageInstance] Created InstalledAddOnUsageInstance
68
+ def create(create_marketplace_billing_usage_request: nil
69
+ )
70
+
71
+ headers = Twilio::Values.of({"Content-Type"=> "application/json"})
72
+ payload = @version.create('POST', @uri, data: create_marketplace_billing_usage_request.to_json, headers: headers)
73
+ InstalledAddOnUsageInstance.new(
74
+ @version,
75
+ payload,
76
+ installed_add_on_sid: @solution[:installed_add_on_sid],
77
+ )
78
+ end
79
+
80
+
81
+
82
+
83
+ # Provide a user friendly representation
84
+ def to_s
85
+ '#<Twilio.Marketplace.V1.InstalledAddOnUsageList>'
86
+ end
87
+ end
88
+
89
+ class InstalledAddOnUsagePage < Page
90
+ ##
91
+ # Initialize the InstalledAddOnUsagePage
92
+ # @param [Version] version Version that contains the resource
93
+ # @param [Response] response Response from the API
94
+ # @param [Hash] solution Path solution for the resource
95
+ # @return [InstalledAddOnUsagePage] InstalledAddOnUsagePage
96
+ def initialize(version, response, solution)
97
+ super(version, response)
98
+
99
+ # Path Solution
100
+ @solution = solution
101
+ end
102
+
103
+ ##
104
+ # Build an instance of InstalledAddOnUsageInstance
105
+ # @param [Hash] payload Payload response from the API
106
+ # @return [InstalledAddOnUsageInstance] InstalledAddOnUsageInstance
107
+ def get_instance(payload)
108
+ InstalledAddOnUsageInstance.new(@version, payload, installed_add_on_sid: @solution[:installed_add_on_sid])
109
+ end
110
+
111
+ ##
112
+ # Provide a user friendly representation
113
+ def to_s
114
+ '<Twilio.Marketplace.V1.InstalledAddOnUsagePage>'
115
+ end
116
+ end
117
+ class InstalledAddOnUsageInstance < InstanceResource
118
+ ##
119
+ # Initialize the InstalledAddOnUsageInstance
120
+ # @param [Version] version Version that contains the resource
121
+ # @param [Hash] payload payload that contains response from Twilio
122
+ # @param [String] account_sid The SID of the
123
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this InstalledAddOnUsage
124
+ # resource.
125
+ # @param [String] sid The SID of the Call resource to fetch.
126
+ # @return [InstalledAddOnUsageInstance] InstalledAddOnUsageInstance
127
+ def initialize(version, payload , installed_add_on_sid: nil)
128
+ super(version)
129
+
130
+ # Marshaled Properties
131
+ @properties = {
132
+ 'billable_items' => payload['billable_items'],
133
+ 'total_submitted' => payload['total_submitted'],
134
+ }
135
+ end
136
+
137
+
138
+ ##
139
+ # @return [Array<MarketplaceInstalledAddOnBillingUsageResponseBillableItems>]
140
+ def billable_items
141
+ @properties['billable_items']
142
+ end
143
+
144
+ ##
145
+ # @return [Float] Represents the total quantity submitted.
146
+ def total_submitted
147
+ @properties['total_submitted']
148
+ end
149
+
150
+ ##
151
+ # Provide a user friendly representation
152
+ def to_s
153
+ "<Twilio.Marketplace.V1.InstalledAddOnUsageInstance>"
154
+ end
155
+
156
+ ##
157
+ # Provide a detailed, user friendly representation
158
+ def inspect
159
+ "<Twilio.Marketplace.V1.InstalledAddOnUsageInstance>"
160
+ end
161
+ end
162
+
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
168
+
169
+
@@ -0,0 +1,461 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Marketplace
8
+ # This is the public Twilio REST API.
9
+ #
10
+ # NOTE: This class is auto generated by OpenAPI Generator.
11
+ # https://openapi-generator.tech
12
+ # Do not edit the class manually.
13
+ #
14
+
15
+
16
+ module Twilio
17
+ module REST
18
+ class Marketplace < MarketplaceBase
19
+ class V1 < Version
20
+ class InstalledAddOnList < ListResource
21
+
22
+ ##
23
+ # Initialize the InstalledAddOnList
24
+ # @param [Version] version Version that contains the resource
25
+ # @return [InstalledAddOnList] InstalledAddOnList
26
+ def initialize(version)
27
+ super(version)
28
+ # Path Solution
29
+ @solution = { }
30
+ @uri = "/InstalledAddOns"
31
+
32
+ end
33
+ ##
34
+ # Create the InstalledAddOnInstance
35
+ # @param [String] available_add_on_sid The SID of the AvaliableAddOn to install.
36
+ # @param [Boolean] accept_terms_of_service Whether the Terms of Service were accepted.
37
+ # @param [Object] configuration The JSON object that represents the configuration of the new Add-on being installed.
38
+ # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be unique within the Account.
39
+ # @return [InstalledAddOnInstance] Created InstalledAddOnInstance
40
+ def create(
41
+ available_add_on_sid: nil,
42
+ accept_terms_of_service: nil,
43
+ configuration: :unset,
44
+ unique_name: :unset
45
+ )
46
+
47
+ data = Twilio::Values.of({
48
+ 'AvailableAddOnSid' => available_add_on_sid,
49
+ 'AcceptTermsOfService' => accept_terms_of_service,
50
+ 'Configuration' => Twilio.serialize_object(configuration),
51
+ 'UniqueName' => unique_name,
52
+ })
53
+
54
+
55
+ payload = @version.create('POST', @uri, data: data)
56
+ InstalledAddOnInstance.new(
57
+ @version,
58
+ payload,
59
+ )
60
+ end
61
+
62
+
63
+ ##
64
+ # Lists InstalledAddOnInstance records from the API as a list.
65
+ # Unlike stream(), this operation is eager and will load `limit` records into
66
+ # memory before returning.
67
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
68
+ # guarantees to never return more than limit. Default is no limit
69
+ # @param [Integer] page_size Number of records to fetch per request, when
70
+ # not set will use the default value of 50 records. If no page_size is defined
71
+ # but a limit is defined, stream() will attempt to read the limit with the most
72
+ # efficient page size, i.e. min(limit, 1000)
73
+ # @return [Array] Array of up to limit results
74
+ def list(limit: nil, page_size: nil)
75
+ self.stream(
76
+ limit: limit,
77
+ page_size: page_size
78
+ ).entries
79
+ end
80
+
81
+ ##
82
+ # Streams Instance records from the API as an Enumerable.
83
+ # This operation lazily loads records as efficiently as possible until the limit
84
+ # is reached.
85
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
86
+ # guarantees to never return more than limit. Default is no limit
87
+ # @param [Integer] page_size Number of records to fetch per request, when
88
+ # not set will use the default value of 50 records. If no page_size is defined
89
+ # but a limit is defined, stream() will attempt to read the limit with the most
90
+ # efficient page size, i.e. min(limit, 1000)
91
+ # @return [Enumerable] Enumerable that will yield up to limit results
92
+ def stream(limit: nil, page_size: nil)
93
+ limits = @version.read_limits(limit, page_size)
94
+
95
+ page = self.page(
96
+ page_size: limits[:page_size], )
97
+
98
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
99
+ end
100
+
101
+ ##
102
+ # When passed a block, yields InstalledAddOnInstance records from the API.
103
+ # This operation lazily loads records as efficiently as possible until the limit
104
+ # is reached.
105
+ def each
106
+ limits = @version.read_limits
107
+
108
+ page = self.page(page_size: limits[:page_size], )
109
+
110
+ @version.stream(page,
111
+ limit: limits[:limit],
112
+ page_limit: limits[:page_limit]).each {|x| yield x}
113
+ end
114
+
115
+ ##
116
+ # Retrieve a single page of InstalledAddOnInstance records from the API.
117
+ # Request is executed immediately.
118
+ # @param [String] page_token PageToken provided by the API
119
+ # @param [Integer] page_number Page Number, this value is simply for client state
120
+ # @param [Integer] page_size Number of records to return, defaults to 50
121
+ # @return [Page] Page of InstalledAddOnInstance
122
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
123
+ params = Twilio::Values.of({
124
+ 'PageToken' => page_token,
125
+ 'Page' => page_number,
126
+ 'PageSize' => page_size,
127
+ })
128
+
129
+ response = @version.page('GET', @uri, params: params)
130
+
131
+ InstalledAddOnPage.new(@version, response, @solution)
132
+ end
133
+
134
+ ##
135
+ # Retrieve a single page of InstalledAddOnInstance records from the API.
136
+ # Request is executed immediately.
137
+ # @param [String] target_url API-generated URL for the requested results page
138
+ # @return [Page] Page of InstalledAddOnInstance
139
+ def get_page(target_url)
140
+ response = @version.domain.request(
141
+ 'GET',
142
+ target_url
143
+ )
144
+ InstalledAddOnPage.new(@version, response, @solution)
145
+ end
146
+
147
+
148
+
149
+ # Provide a user friendly representation
150
+ def to_s
151
+ '#<Twilio.Marketplace.V1.InstalledAddOnList>'
152
+ end
153
+ end
154
+
155
+
156
+ class InstalledAddOnContext < InstanceContext
157
+ ##
158
+ # Initialize the InstalledAddOnContext
159
+ # @param [Version] version Version that contains the resource
160
+ # @param [String] sid The SID of the InstalledAddOn resource to update.
161
+ # @return [InstalledAddOnContext] InstalledAddOnContext
162
+ def initialize(version, sid)
163
+ super(version)
164
+
165
+ # Path Solution
166
+ @solution = { sid: sid, }
167
+ @uri = "/InstalledAddOns/#{@solution[:sid]}"
168
+
169
+ # Dependents
170
+ @usage = nil
171
+ @extensions = nil
172
+ end
173
+ ##
174
+ # Delete the InstalledAddOnInstance
175
+ # @return [Boolean] True if delete succeeds, false otherwise
176
+ def delete
177
+
178
+
179
+ @version.delete('DELETE', @uri)
180
+ end
181
+
182
+ ##
183
+ # Fetch the InstalledAddOnInstance
184
+ # @return [InstalledAddOnInstance] Fetched InstalledAddOnInstance
185
+ def fetch
186
+
187
+
188
+ payload = @version.fetch('GET', @uri)
189
+ InstalledAddOnInstance.new(
190
+ @version,
191
+ payload,
192
+ sid: @solution[:sid],
193
+ )
194
+ end
195
+
196
+ ##
197
+ # Update the InstalledAddOnInstance
198
+ # @param [Object] configuration Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured
199
+ # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be unique within the Account.
200
+ # @return [InstalledAddOnInstance] Updated InstalledAddOnInstance
201
+ def update(
202
+ configuration: :unset,
203
+ unique_name: :unset
204
+ )
205
+
206
+ data = Twilio::Values.of({
207
+ 'Configuration' => Twilio.serialize_object(configuration),
208
+ 'UniqueName' => unique_name,
209
+ })
210
+
211
+
212
+ payload = @version.update('POST', @uri, data: data)
213
+ InstalledAddOnInstance.new(
214
+ @version,
215
+ payload,
216
+ sid: @solution[:sid],
217
+ )
218
+ end
219
+
220
+ ##
221
+ # Access the usage
222
+ # @return [InstalledAddOnUsageList]
223
+ # @return [InstalledAddOnUsageContext]
224
+ def usage
225
+ unless @usage
226
+ @usage = InstalledAddOnUsageList.new(
227
+ @version, installed_add_on_sid: @solution[:sid], )
228
+ end
229
+ @usage
230
+ end
231
+ ##
232
+ # Access the extensions
233
+ # @return [InstalledAddOnExtensionList]
234
+ # @return [InstalledAddOnExtensionContext] if sid was passed.
235
+ def extensions(sid=:unset)
236
+
237
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
238
+
239
+ if sid != :unset
240
+ return InstalledAddOnExtensionContext.new(@version, @solution[:sid],sid )
241
+ end
242
+
243
+ unless @extensions
244
+ @extensions = InstalledAddOnExtensionList.new(
245
+ @version, installed_add_on_sid: @solution[:sid], )
246
+ end
247
+
248
+ @extensions
249
+ end
250
+
251
+ ##
252
+ # Provide a user friendly representation
253
+ def to_s
254
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
255
+ "#<Twilio.Marketplace.V1.InstalledAddOnContext #{context}>"
256
+ end
257
+
258
+ ##
259
+ # Provide a detailed, user friendly representation
260
+ def inspect
261
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
262
+ "#<Twilio.Marketplace.V1.InstalledAddOnContext #{context}>"
263
+ end
264
+ end
265
+
266
+ class InstalledAddOnPage < Page
267
+ ##
268
+ # Initialize the InstalledAddOnPage
269
+ # @param [Version] version Version that contains the resource
270
+ # @param [Response] response Response from the API
271
+ # @param [Hash] solution Path solution for the resource
272
+ # @return [InstalledAddOnPage] InstalledAddOnPage
273
+ def initialize(version, response, solution)
274
+ super(version, response)
275
+
276
+ # Path Solution
277
+ @solution = solution
278
+ end
279
+
280
+ ##
281
+ # Build an instance of InstalledAddOnInstance
282
+ # @param [Hash] payload Payload response from the API
283
+ # @return [InstalledAddOnInstance] InstalledAddOnInstance
284
+ def get_instance(payload)
285
+ InstalledAddOnInstance.new(@version, payload)
286
+ end
287
+
288
+ ##
289
+ # Provide a user friendly representation
290
+ def to_s
291
+ '<Twilio.Marketplace.V1.InstalledAddOnPage>'
292
+ end
293
+ end
294
+ class InstalledAddOnInstance < InstanceResource
295
+ ##
296
+ # Initialize the InstalledAddOnInstance
297
+ # @param [Version] version Version that contains the resource
298
+ # @param [Hash] payload payload that contains response from Twilio
299
+ # @param [String] account_sid The SID of the
300
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this InstalledAddOn
301
+ # resource.
302
+ # @param [String] sid The SID of the Call resource to fetch.
303
+ # @return [InstalledAddOnInstance] InstalledAddOnInstance
304
+ def initialize(version, payload , sid: nil)
305
+ super(version)
306
+
307
+ # Marshaled Properties
308
+ @properties = {
309
+ 'sid' => payload['sid'],
310
+ 'account_sid' => payload['account_sid'],
311
+ 'friendly_name' => payload['friendly_name'],
312
+ 'description' => payload['description'],
313
+ 'configuration' => payload['configuration'],
314
+ 'unique_name' => payload['unique_name'],
315
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
316
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
317
+ 'url' => payload['url'],
318
+ 'links' => payload['links'],
319
+ }
320
+
321
+ # Context
322
+ @instance_context = nil
323
+ @params = { 'sid' => sid || @properties['sid'] , }
324
+ end
325
+
326
+ ##
327
+ # Generate an instance context for the instance, the context is capable of
328
+ # performing various actions. All instance actions are proxied to the context
329
+ # @return [InstalledAddOnContext] CallContext for this CallInstance
330
+ def context
331
+ unless @instance_context
332
+ @instance_context = InstalledAddOnContext.new(@version , @params['sid'])
333
+ end
334
+ @instance_context
335
+ end
336
+
337
+ ##
338
+ # @return [String] The unique string that we created to identify the InstalledAddOn resource. This Sid can also be found in the Console on that specific Add-ons page as the 'Available Add-on Sid'.
339
+ def sid
340
+ @properties['sid']
341
+ end
342
+
343
+ ##
344
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the InstalledAddOn resource.
345
+ def account_sid
346
+ @properties['account_sid']
347
+ end
348
+
349
+ ##
350
+ # @return [String] The string that you assigned to describe the resource.
351
+ def friendly_name
352
+ @properties['friendly_name']
353
+ end
354
+
355
+ ##
356
+ # @return [String] A short description of the Add-on's functionality.
357
+ def description
358
+ @properties['description']
359
+ end
360
+
361
+ ##
362
+ # @return [Hash] The JSON object that represents the current configuration of installed Add-on.
363
+ def configuration
364
+ @properties['configuration']
365
+ end
366
+
367
+ ##
368
+ # @return [String] An application-defined string that uniquely identifies the resource.
369
+ def unique_name
370
+ @properties['unique_name']
371
+ end
372
+
373
+ ##
374
+ # @return [Time] The date and time in GMT when the resource was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
375
+ def date_created
376
+ @properties['date_created']
377
+ end
378
+
379
+ ##
380
+ # @return [Time] The date and time in GMT when the resource was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
381
+ def date_updated
382
+ @properties['date_updated']
383
+ end
384
+
385
+ ##
386
+ # @return [String] The absolute URL of the resource.
387
+ def url
388
+ @properties['url']
389
+ end
390
+
391
+ ##
392
+ # @return [Hash] The URLs of related resources.
393
+ def links
394
+ @properties['links']
395
+ end
396
+
397
+ ##
398
+ # Delete the InstalledAddOnInstance
399
+ # @return [Boolean] True if delete succeeds, false otherwise
400
+ def delete
401
+
402
+ context.delete
403
+ end
404
+
405
+ ##
406
+ # Fetch the InstalledAddOnInstance
407
+ # @return [InstalledAddOnInstance] Fetched InstalledAddOnInstance
408
+ def fetch
409
+
410
+ context.fetch
411
+ end
412
+
413
+ ##
414
+ # Update the InstalledAddOnInstance
415
+ # @param [Object] configuration Valid JSON object that conform to the configuration schema exposed by the associated AvailableAddOn resource. This is only required by Add-ons that need to be configured
416
+ # @param [String] unique_name An application-defined string that uniquely identifies the resource. This value must be unique within the Account.
417
+ # @return [InstalledAddOnInstance] Updated InstalledAddOnInstance
418
+ def update(
419
+ configuration: :unset,
420
+ unique_name: :unset
421
+ )
422
+
423
+ context.update(
424
+ configuration: configuration,
425
+ unique_name: unique_name,
426
+ )
427
+ end
428
+
429
+ ##
430
+ # Access the usage
431
+ # @return [usage] usage
432
+ def usage
433
+ context.usage
434
+ end
435
+
436
+ ##
437
+ # Access the extensions
438
+ # @return [extensions] extensions
439
+ def extensions
440
+ context.extensions
441
+ end
442
+
443
+ ##
444
+ # Provide a user friendly representation
445
+ def to_s
446
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
447
+ "<Twilio.Marketplace.V1.InstalledAddOnInstance #{values}>"
448
+ end
449
+
450
+ ##
451
+ # Provide a detailed, user friendly representation
452
+ def inspect
453
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
454
+ "<Twilio.Marketplace.V1.InstalledAddOnInstance #{values}>"
455
+ end
456
+ end
457
+
458
+ end
459
+ end
460
+ end
461
+ end