twilio-ruby 6.0.2 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,403 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Numbers
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 Numbers < NumbersBase
19
+ class V2 < Version
20
+ class AuthorizationDocumentList < ListResource
21
+ ##
22
+ # Initialize the AuthorizationDocumentList
23
+ # @param [Version] version Version that contains the resource
24
+ # @return [AuthorizationDocumentList] AuthorizationDocumentList
25
+ def initialize(version)
26
+ super(version)
27
+ # Path Solution
28
+ @solution = { }
29
+ @uri = "/HostedNumber/AuthorizationDocuments"
30
+
31
+ end
32
+ ##
33
+ # Create the AuthorizationDocumentInstance
34
+ # @param [String] address_sid A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument.
35
+ # @param [String] email Email that this AuthorizationDocument will be sent to for signing.
36
+ # @param [String] contact_phone_number The contact phone number of the person authorized to sign the Authorization Document.
37
+ # @param [String] contact_title The title of the person authorized to sign the Authorization Document for this phone number.
38
+ # @param [Array[String]] cc_emails Email recipients who will be informed when an Authorization Document has been sent and signed.
39
+ # @return [AuthorizationDocumentInstance] Created AuthorizationDocumentInstance
40
+ def create(
41
+ address_sid: nil,
42
+ email: nil,
43
+ contact_phone_number: nil,
44
+ contact_title: :unset,
45
+ cc_emails: :unset
46
+ )
47
+
48
+ data = Twilio::Values.of({
49
+ 'AddressSid' => address_sid,
50
+ 'Email' => email,
51
+ 'ContactPhoneNumber' => contact_phone_number,
52
+ 'ContactTitle' => contact_title,
53
+ 'CcEmails' => Twilio.serialize_list(cc_emails) { |e| e },
54
+ })
55
+
56
+ payload = @version.create('POST', @uri, data: data)
57
+ AuthorizationDocumentInstance.new(
58
+ @version,
59
+ payload,
60
+ )
61
+ end
62
+
63
+
64
+ ##
65
+ # Lists AuthorizationDocumentInstance records from the API as a list.
66
+ # Unlike stream(), this operation is eager and will load `limit` records into
67
+ # memory before returning.
68
+ # @param [String] email Email that this AuthorizationDocument will be sent to for signing.
69
+ # @param [Status] status Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses.
70
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
71
+ # guarantees to never return more than limit. Default is no limit
72
+ # @param [Integer] page_size Number of records to fetch per request, when
73
+ # not set will use the default value of 50 records. If no page_size is defined
74
+ # but a limit is defined, stream() will attempt to read the limit with the most
75
+ # efficient page size, i.e. min(limit, 1000)
76
+ # @return [Array] Array of up to limit results
77
+ def list(email: :unset, status: :unset, limit: nil, page_size: nil)
78
+ self.stream(
79
+ email: email,
80
+ status: status,
81
+ limit: limit,
82
+ page_size: page_size
83
+ ).entries
84
+ end
85
+
86
+ ##
87
+ # Streams Instance records from the API as an Enumerable.
88
+ # This operation lazily loads records as efficiently as possible until the limit
89
+ # is reached.
90
+ # @param [String] email Email that this AuthorizationDocument will be sent to for signing.
91
+ # @param [Status] status Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses.
92
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
93
+ # guarantees to never return more than limit. Default is no limit
94
+ # @param [Integer] page_size Number of records to fetch per request, when
95
+ # not set will use the default value of 50 records. If no page_size is defined
96
+ # but a limit is defined, stream() will attempt to read the limit with the most
97
+ # efficient page size, i.e. min(limit, 1000)
98
+ # @return [Enumerable] Enumerable that will yield up to limit results
99
+ def stream(email: :unset, status: :unset, limit: nil, page_size: nil)
100
+ limits = @version.read_limits(limit, page_size)
101
+
102
+ page = self.page(
103
+ email: email,
104
+ status: status,
105
+ page_size: limits[:page_size], )
106
+
107
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
108
+ end
109
+
110
+ ##
111
+ # When passed a block, yields AuthorizationDocumentInstance records from the API.
112
+ # This operation lazily loads records as efficiently as possible until the limit
113
+ # is reached.
114
+ def each
115
+ limits = @version.read_limits
116
+
117
+ page = self.page(page_size: limits[:page_size], )
118
+
119
+ @version.stream(page,
120
+ limit: limits[:limit],
121
+ page_limit: limits[:page_limit]).each {|x| yield x}
122
+ end
123
+
124
+ ##
125
+ # Retrieve a single page of AuthorizationDocumentInstance records from the API.
126
+ # Request is executed immediately.
127
+ # @param [String] email Email that this AuthorizationDocument will be sent to for signing.
128
+ # @param [Status] status Status of an instance resource. It can hold one of the values: 1. opened 2. signing, 3. signed LOA, 4. canceled, 5. failed. See the section entitled [Status Values](https://www.twilio.com/docs/api/phone-numbers/hosted-number-authorization-documents#status-values) for more information on each of these statuses.
129
+ # @param [String] page_token PageToken provided by the API
130
+ # @param [Integer] page_number Page Number, this value is simply for client state
131
+ # @param [Integer] page_size Number of records to return, defaults to 50
132
+ # @return [Page] Page of AuthorizationDocumentInstance
133
+ def page(email: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
134
+ params = Twilio::Values.of({
135
+
136
+ 'Email' => email,
137
+
138
+ 'Status' => status,
139
+
140
+ 'PageToken' => page_token,
141
+ 'Page' => page_number,
142
+ 'PageSize' => page_size,
143
+ })
144
+
145
+ response = @version.page('GET', @uri, params: params)
146
+
147
+ AuthorizationDocumentPage.new(@version, response, @solution)
148
+ end
149
+
150
+ ##
151
+ # Retrieve a single page of AuthorizationDocumentInstance records from the API.
152
+ # Request is executed immediately.
153
+ # @param [String] target_url API-generated URL for the requested results page
154
+ # @return [Page] Page of AuthorizationDocumentInstance
155
+ def get_page(target_url)
156
+ response = @version.domain.request(
157
+ 'GET',
158
+ target_url
159
+ )
160
+ AuthorizationDocumentPage.new(@version, response, @solution)
161
+ end
162
+
163
+
164
+
165
+ # Provide a user friendly representation
166
+ def to_s
167
+ '#<Twilio.Numbers.V2.AuthorizationDocumentList>'
168
+ end
169
+ end
170
+
171
+
172
+ ##
173
+ #PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
174
+ class AuthorizationDocumentContext < InstanceContext
175
+ ##
176
+ # Initialize the AuthorizationDocumentContext
177
+ # @param [Version] version Version that contains the resource
178
+ # @param [String] sid A 34 character string that uniquely identifies this AuthorizationDocument.
179
+ # @return [AuthorizationDocumentContext] AuthorizationDocumentContext
180
+ def initialize(version, sid)
181
+ super(version)
182
+
183
+ # Path Solution
184
+ @solution = { sid: sid, }
185
+ @uri = "/HostedNumber/AuthorizationDocuments/#{@solution[:sid]}"
186
+
187
+ # Dependents
188
+ @dependent_hosted_number_orders = nil
189
+ end
190
+ ##
191
+ # Delete the AuthorizationDocumentInstance
192
+ # @return [Boolean] True if delete succeeds, false otherwise
193
+ def delete
194
+
195
+ @version.delete('DELETE', @uri)
196
+ end
197
+
198
+ ##
199
+ # Fetch the AuthorizationDocumentInstance
200
+ # @return [AuthorizationDocumentInstance] Fetched AuthorizationDocumentInstance
201
+ def fetch
202
+
203
+ payload = @version.fetch('GET', @uri)
204
+ AuthorizationDocumentInstance.new(
205
+ @version,
206
+ payload,
207
+ sid: @solution[:sid],
208
+ )
209
+ end
210
+
211
+ ##
212
+ # Access the dependent_hosted_number_orders
213
+ # @return [DependentHostedNumberOrderList]
214
+ # @return [DependentHostedNumberOrderContext]
215
+ def dependent_hosted_number_orders
216
+ unless @dependent_hosted_number_orders
217
+ @dependent_hosted_number_orders = DependentHostedNumberOrderList.new(
218
+ @version, signing_document_sid: @solution[:sid], )
219
+ end
220
+ @dependent_hosted_number_orders
221
+ end
222
+
223
+ ##
224
+ # Provide a user friendly representation
225
+ def to_s
226
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
227
+ "#<Twilio.Numbers.V2.AuthorizationDocumentContext #{context}>"
228
+ end
229
+
230
+ ##
231
+ # Provide a detailed, user friendly representation
232
+ def inspect
233
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
234
+ "#<Twilio.Numbers.V2.AuthorizationDocumentContext #{context}>"
235
+ end
236
+ end
237
+
238
+ class AuthorizationDocumentPage < Page
239
+ ##
240
+ # Initialize the AuthorizationDocumentPage
241
+ # @param [Version] version Version that contains the resource
242
+ # @param [Response] response Response from the API
243
+ # @param [Hash] solution Path solution for the resource
244
+ # @return [AuthorizationDocumentPage] AuthorizationDocumentPage
245
+ def initialize(version, response, solution)
246
+ super(version, response)
247
+
248
+ # Path Solution
249
+ @solution = solution
250
+ end
251
+
252
+ ##
253
+ # Build an instance of AuthorizationDocumentInstance
254
+ # @param [Hash] payload Payload response from the API
255
+ # @return [AuthorizationDocumentInstance] AuthorizationDocumentInstance
256
+ def get_instance(payload)
257
+ AuthorizationDocumentInstance.new(@version, payload)
258
+ end
259
+
260
+ ##
261
+ # Provide a user friendly representation
262
+ def to_s
263
+ '<Twilio.Numbers.V2.AuthorizationDocumentPage>'
264
+ end
265
+ end
266
+ class AuthorizationDocumentInstance < InstanceResource
267
+ ##
268
+ # Initialize the AuthorizationDocumentInstance
269
+ # @param [Version] version Version that contains the resource
270
+ # @param [Hash] payload payload that contains response from Twilio
271
+ # @param [String] account_sid The SID of the
272
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this AuthorizationDocument
273
+ # resource.
274
+ # @param [String] sid The SID of the Call resource to fetch.
275
+ # @return [AuthorizationDocumentInstance] AuthorizationDocumentInstance
276
+ def initialize(version, payload , sid: nil)
277
+ super(version)
278
+
279
+ # Marshaled Properties
280
+ @properties = {
281
+ 'sid' => payload['sid'],
282
+ 'address_sid' => payload['address_sid'],
283
+ 'status' => payload['status'],
284
+ 'email' => payload['email'],
285
+ 'cc_emails' => payload['cc_emails'],
286
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
287
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
288
+ 'url' => payload['url'],
289
+ 'links' => payload['links'],
290
+ }
291
+
292
+ # Context
293
+ @instance_context = nil
294
+ @params = { 'sid' => sid || @properties['sid'] , }
295
+ end
296
+
297
+ ##
298
+ # Generate an instance context for the instance, the context is capable of
299
+ # performing various actions. All instance actions are proxied to the context
300
+ # @return [AuthorizationDocumentContext] CallContext for this CallInstance
301
+ def context
302
+ unless @instance_context
303
+ @instance_context = AuthorizationDocumentContext.new(@version , @params['sid'])
304
+ end
305
+ @instance_context
306
+ end
307
+
308
+ ##
309
+ # @return [String] A 34 character string that uniquely identifies this AuthorizationDocument.
310
+ def sid
311
+ @properties['sid']
312
+ end
313
+
314
+ ##
315
+ # @return [String] A 34 character string that uniquely identifies the Address resource that is associated with this AuthorizationDocument.
316
+ def address_sid
317
+ @properties['address_sid']
318
+ end
319
+
320
+ ##
321
+ # @return [Status]
322
+ def status
323
+ @properties['status']
324
+ end
325
+
326
+ ##
327
+ # @return [String] Email that this AuthorizationDocument will be sent to for signing.
328
+ def email
329
+ @properties['email']
330
+ end
331
+
332
+ ##
333
+ # @return [Array<String>] Email recipients who will be informed when an Authorization Document has been sent and signed.
334
+ def cc_emails
335
+ @properties['cc_emails']
336
+ end
337
+
338
+ ##
339
+ # @return [Time] The date this resource was created, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
340
+ def date_created
341
+ @properties['date_created']
342
+ end
343
+
344
+ ##
345
+ # @return [Time] The date that this resource was updated, given as [GMT RFC 2822](http://www.ietf.org/rfc/rfc2822.txt) format.
346
+ def date_updated
347
+ @properties['date_updated']
348
+ end
349
+
350
+ ##
351
+ # @return [String]
352
+ def url
353
+ @properties['url']
354
+ end
355
+
356
+ ##
357
+ # @return [Hash]
358
+ def links
359
+ @properties['links']
360
+ end
361
+
362
+ ##
363
+ # Delete the AuthorizationDocumentInstance
364
+ # @return [Boolean] True if delete succeeds, false otherwise
365
+ def delete
366
+
367
+ context.delete
368
+ end
369
+
370
+ ##
371
+ # Fetch the AuthorizationDocumentInstance
372
+ # @return [AuthorizationDocumentInstance] Fetched AuthorizationDocumentInstance
373
+ def fetch
374
+
375
+ context.fetch
376
+ end
377
+
378
+ ##
379
+ # Access the dependent_hosted_number_orders
380
+ # @return [dependent_hosted_number_orders] dependent_hosted_number_orders
381
+ def dependent_hosted_number_orders
382
+ context.dependent_hosted_number_orders
383
+ end
384
+
385
+ ##
386
+ # Provide a user friendly representation
387
+ def to_s
388
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
389
+ "<Twilio.Numbers.V2.AuthorizationDocumentInstance #{values}>"
390
+ end
391
+
392
+ ##
393
+ # Provide a detailed, user friendly representation
394
+ def inspect
395
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
396
+ "<Twilio.Numbers.V2.AuthorizationDocumentInstance #{values}>"
397
+ end
398
+ end
399
+
400
+ end
401
+ end
402
+ end
403
+ end