twilio-ruby 6.12.0 → 6.12.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,393 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Flex
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 FlexApi < FlexApiBase
19
+ class V1 < Version
20
+ class PluginConfigurationContext < InstanceContext
21
+
22
+ class ConfiguredPluginList < ListResource
23
+
24
+ ##
25
+ # Initialize the ConfiguredPluginList
26
+ # @param [Version] version Version that contains the resource
27
+ # @return [ConfiguredPluginList] ConfiguredPluginList
28
+ def initialize(version, configuration_sid: nil)
29
+ super(version)
30
+ # Path Solution
31
+ @solution = { configuration_sid: configuration_sid }
32
+ @uri = "/PluginService/Configurations/#{@solution[:configuration_sid]}/Plugins"
33
+
34
+ end
35
+
36
+ ##
37
+ # Lists ConfiguredPluginInstance records from the API as a list.
38
+ # Unlike stream(), this operation is eager and will load `limit` records into
39
+ # memory before returning.
40
+ # @param [String] flex_metadata The Flex-Metadata HTTP request header
41
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
42
+ # guarantees to never return more than limit. Default is no limit
43
+ # @param [Integer] page_size Number of records to fetch per request, when
44
+ # not set will use the default value of 50 records. If no page_size is defined
45
+ # but a limit is defined, stream() will attempt to read the limit with the most
46
+ # efficient page size, i.e. min(limit, 1000)
47
+ # @return [Array] Array of up to limit results
48
+ def list(flex_metadata: :unset, limit: nil, page_size: nil)
49
+ self.stream(
50
+ flex_metadata: flex_metadata,
51
+ limit: limit,
52
+ page_size: page_size
53
+ ).entries
54
+ end
55
+
56
+ ##
57
+ # Streams Instance records from the API as an Enumerable.
58
+ # This operation lazily loads records as efficiently as possible until the limit
59
+ # is reached.
60
+ # @param [String] flex_metadata The Flex-Metadata HTTP request header
61
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
62
+ # guarantees to never return more than limit. Default is no limit
63
+ # @param [Integer] page_size Number of records to fetch per request, when
64
+ # not set will use the default value of 50 records. If no page_size is defined
65
+ # but a limit is defined, stream() will attempt to read the limit with the most
66
+ # efficient page size, i.e. min(limit, 1000)
67
+ # @return [Enumerable] Enumerable that will yield up to limit results
68
+ def stream(flex_metadata: :unset, limit: nil, page_size: nil)
69
+ limits = @version.read_limits(limit, page_size)
70
+
71
+ page = self.page(
72
+ flex_metadata: flex_metadata,
73
+ page_size: limits[:page_size], )
74
+
75
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
76
+ end
77
+
78
+ ##
79
+ # When passed a block, yields ConfiguredPluginInstance records from the API.
80
+ # This operation lazily loads records as efficiently as possible until the limit
81
+ # is reached.
82
+ def each
83
+ limits = @version.read_limits
84
+
85
+ page = self.page(page_size: limits[:page_size], )
86
+
87
+ @version.stream(page,
88
+ limit: limits[:limit],
89
+ page_limit: limits[:page_limit]).each {|x| yield x}
90
+ end
91
+
92
+ ##
93
+ # Retrieve a single page of ConfiguredPluginInstance records from the API.
94
+ # Request is executed immediately.
95
+ # @param [String] flex_metadata The Flex-Metadata HTTP request header
96
+ # @param [String] page_token PageToken provided by the API
97
+ # @param [Integer] page_number Page Number, this value is simply for client state
98
+ # @param [Integer] page_size Number of records to return, defaults to 50
99
+ # @return [Page] Page of ConfiguredPluginInstance
100
+ def page(flex_metadata: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
101
+ params = Twilio::Values.of({
102
+ 'Flex-Metadata' => flex_metadata,
103
+ 'PageToken' => page_token,
104
+ 'Page' => page_number,
105
+ 'PageSize' => page_size,
106
+ })
107
+
108
+ response = @version.page('GET', @uri, params: params)
109
+
110
+ ConfiguredPluginPage.new(@version, response, @solution)
111
+ end
112
+
113
+ ##
114
+ # Retrieve a single page of ConfiguredPluginInstance records from the API.
115
+ # Request is executed immediately.
116
+ # @param [String] target_url API-generated URL for the requested results page
117
+ # @return [Page] Page of ConfiguredPluginInstance
118
+ def get_page(target_url)
119
+ response = @version.domain.request(
120
+ 'GET',
121
+ target_url
122
+ )
123
+ ConfiguredPluginPage.new(@version, response, @solution)
124
+ end
125
+
126
+
127
+
128
+ # Provide a user friendly representation
129
+ def to_s
130
+ '#<Twilio.FlexApi.V1.ConfiguredPluginList>'
131
+ end
132
+ end
133
+
134
+
135
+ class ConfiguredPluginContext < InstanceContext
136
+ ##
137
+ # Initialize the ConfiguredPluginContext
138
+ # @param [Version] version Version that contains the resource
139
+ # @param [String] configuration_sid The SID of the Flex Plugin Configuration the resource to belongs to.
140
+ # @param [String] plugin_sid The unique string that we created to identify the Flex Plugin resource.
141
+ # @return [ConfiguredPluginContext] ConfiguredPluginContext
142
+ def initialize(version, configuration_sid, plugin_sid)
143
+ super(version)
144
+
145
+ # Path Solution
146
+ @solution = { configuration_sid: configuration_sid, plugin_sid: plugin_sid, }
147
+ @uri = "/PluginService/Configurations/#{@solution[:configuration_sid]}/Plugins/#{@solution[:plugin_sid]}"
148
+
149
+
150
+ end
151
+ ##
152
+ # Fetch the ConfiguredPluginInstance
153
+ # @param [String] flex_metadata The Flex-Metadata HTTP request header
154
+ # @return [ConfiguredPluginInstance] Fetched ConfiguredPluginInstance
155
+ def fetch(
156
+ flex_metadata: :unset
157
+ )
158
+
159
+
160
+ headers = Twilio::Values.of({ 'Flex-Metadata' => flex_metadata, })
161
+ payload = @version.fetch('GET', @uri, headers: headers)
162
+ ConfiguredPluginInstance.new(
163
+ @version,
164
+ payload,
165
+ configuration_sid: @solution[:configuration_sid],
166
+ plugin_sid: @solution[:plugin_sid],
167
+ )
168
+ end
169
+
170
+
171
+ ##
172
+ # Provide a user friendly representation
173
+ def to_s
174
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
175
+ "#<Twilio.FlexApi.V1.ConfiguredPluginContext #{context}>"
176
+ end
177
+
178
+ ##
179
+ # Provide a detailed, user friendly representation
180
+ def inspect
181
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
182
+ "#<Twilio.FlexApi.V1.ConfiguredPluginContext #{context}>"
183
+ end
184
+ end
185
+
186
+ class ConfiguredPluginPage < Page
187
+ ##
188
+ # Initialize the ConfiguredPluginPage
189
+ # @param [Version] version Version that contains the resource
190
+ # @param [Response] response Response from the API
191
+ # @param [Hash] solution Path solution for the resource
192
+ # @return [ConfiguredPluginPage] ConfiguredPluginPage
193
+ def initialize(version, response, solution)
194
+ super(version, response)
195
+
196
+ # Path Solution
197
+ @solution = solution
198
+ end
199
+
200
+ ##
201
+ # Build an instance of ConfiguredPluginInstance
202
+ # @param [Hash] payload Payload response from the API
203
+ # @return [ConfiguredPluginInstance] ConfiguredPluginInstance
204
+ def get_instance(payload)
205
+ ConfiguredPluginInstance.new(@version, payload, configuration_sid: @solution[:configuration_sid])
206
+ end
207
+
208
+ ##
209
+ # Provide a user friendly representation
210
+ def to_s
211
+ '<Twilio.FlexApi.V1.ConfiguredPluginPage>'
212
+ end
213
+ end
214
+ class ConfiguredPluginInstance < InstanceResource
215
+ ##
216
+ # Initialize the ConfiguredPluginInstance
217
+ # @param [Version] version Version that contains the resource
218
+ # @param [Hash] payload payload that contains response from Twilio
219
+ # @param [String] account_sid The SID of the
220
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this ConfiguredPlugin
221
+ # resource.
222
+ # @param [String] sid The SID of the Call resource to fetch.
223
+ # @return [ConfiguredPluginInstance] ConfiguredPluginInstance
224
+ def initialize(version, payload , configuration_sid: nil, plugin_sid: nil)
225
+ super(version)
226
+
227
+ # Marshaled Properties
228
+ @properties = {
229
+ 'account_sid' => payload['account_sid'],
230
+ 'configuration_sid' => payload['configuration_sid'],
231
+ 'plugin_sid' => payload['plugin_sid'],
232
+ 'plugin_version_sid' => payload['plugin_version_sid'],
233
+ 'phase' => payload['phase'] == nil ? payload['phase'] : payload['phase'].to_i,
234
+ 'plugin_url' => payload['plugin_url'],
235
+ 'unique_name' => payload['unique_name'],
236
+ 'friendly_name' => payload['friendly_name'],
237
+ 'description' => payload['description'],
238
+ 'plugin_archived' => payload['plugin_archived'],
239
+ 'version' => payload['version'],
240
+ 'changelog' => payload['changelog'],
241
+ 'plugin_version_archived' => payload['plugin_version_archived'],
242
+ 'private' => payload['private'],
243
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
244
+ 'url' => payload['url'],
245
+ }
246
+
247
+ # Context
248
+ @instance_context = nil
249
+ @params = { 'configuration_sid' => configuration_sid || @properties['configuration_sid'] ,'plugin_sid' => plugin_sid || @properties['plugin_sid'] , }
250
+ end
251
+
252
+ ##
253
+ # Generate an instance context for the instance, the context is capable of
254
+ # performing various actions. All instance actions are proxied to the context
255
+ # @return [ConfiguredPluginContext] CallContext for this CallInstance
256
+ def context
257
+ unless @instance_context
258
+ @instance_context = ConfiguredPluginContext.new(@version , @params['configuration_sid'], @params['plugin_sid'])
259
+ end
260
+ @instance_context
261
+ end
262
+
263
+ ##
264
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that the Flex Plugin resource is installed for.
265
+ def account_sid
266
+ @properties['account_sid']
267
+ end
268
+
269
+ ##
270
+ # @return [String] The SID of the Flex Plugin Configuration that this Flex Plugin belongs to.
271
+ def configuration_sid
272
+ @properties['configuration_sid']
273
+ end
274
+
275
+ ##
276
+ # @return [String] The SID of the Flex Plugin.
277
+ def plugin_sid
278
+ @properties['plugin_sid']
279
+ end
280
+
281
+ ##
282
+ # @return [String] The SID of the Flex Plugin Version.
283
+ def plugin_version_sid
284
+ @properties['plugin_version_sid']
285
+ end
286
+
287
+ ##
288
+ # @return [String] The phase this Flex Plugin would initialize at runtime.
289
+ def phase
290
+ @properties['phase']
291
+ end
292
+
293
+ ##
294
+ # @return [String] The URL of where the Flex Plugin Version JavaScript bundle is hosted on.
295
+ def plugin_url
296
+ @properties['plugin_url']
297
+ end
298
+
299
+ ##
300
+ # @return [String] The name that uniquely identifies this Flex Plugin resource.
301
+ def unique_name
302
+ @properties['unique_name']
303
+ end
304
+
305
+ ##
306
+ # @return [String] The friendly name of this Flex Plugin resource.
307
+ def friendly_name
308
+ @properties['friendly_name']
309
+ end
310
+
311
+ ##
312
+ # @return [String] A descriptive string that you create to describe the plugin resource. It can be up to 500 characters long
313
+ def description
314
+ @properties['description']
315
+ end
316
+
317
+ ##
318
+ # @return [Boolean] Whether the Flex Plugin is archived. The default value is false.
319
+ def plugin_archived
320
+ @properties['plugin_archived']
321
+ end
322
+
323
+ ##
324
+ # @return [String] The latest version of this Flex Plugin Version.
325
+ def version
326
+ @properties['version']
327
+ end
328
+
329
+ ##
330
+ # @return [String] A changelog that describes the changes this Flex Plugin Version brings.
331
+ def changelog
332
+ @properties['changelog']
333
+ end
334
+
335
+ ##
336
+ # @return [Boolean] Whether the Flex Plugin Version is archived. The default value is false.
337
+ def plugin_version_archived
338
+ @properties['plugin_version_archived']
339
+ end
340
+
341
+ ##
342
+ # @return [Boolean] Whether to validate the request is authorized to access the Flex Plugin Version.
343
+ def private
344
+ @properties['private']
345
+ end
346
+
347
+ ##
348
+ # @return [Time] The date and time in GMT when the Flex Plugin was installed specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
349
+ def date_created
350
+ @properties['date_created']
351
+ end
352
+
353
+ ##
354
+ # @return [String] The absolute URL of the Flex Plugin resource.
355
+ def url
356
+ @properties['url']
357
+ end
358
+
359
+ ##
360
+ # Fetch the ConfiguredPluginInstance
361
+ # @param [String] flex_metadata The Flex-Metadata HTTP request header
362
+ # @return [ConfiguredPluginInstance] Fetched ConfiguredPluginInstance
363
+ def fetch(
364
+ flex_metadata: :unset
365
+ )
366
+
367
+ context.fetch(
368
+ flex_metadata: flex_metadata,
369
+ )
370
+ end
371
+
372
+ ##
373
+ # Provide a user friendly representation
374
+ def to_s
375
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
376
+ "<Twilio.FlexApi.V1.ConfiguredPluginInstance #{values}>"
377
+ end
378
+
379
+ ##
380
+ # Provide a detailed, user friendly representation
381
+ def inspect
382
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
383
+ "<Twilio.FlexApi.V1.ConfiguredPluginInstance #{values}>"
384
+ end
385
+ end
386
+
387
+ end
388
+ end
389
+ end
390
+ end
391
+ end
392
+
393
+