twilio-ruby 5.22.0 → 5.22.1

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +15 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/client.rb +7 -0
  5. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +14 -0
  6. data/lib/twilio-ruby/rest/messaging/v1/session.rb +1 -7
  7. data/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb +34 -32
  8. data/lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb +37 -35
  9. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb +45 -38
  10. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +38 -34
  11. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +67 -52
  12. data/lib/twilio-ruby/rest/proxy/v1/service/short_code.rb +32 -23
  13. data/lib/twilio-ruby/rest/proxy/v1/service.rb +123 -79
  14. data/lib/twilio-ruby/rest/proxy/v1.rb +2 -1
  15. data/lib/twilio-ruby/rest/proxy.rb +2 -1
  16. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +366 -0
  17. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +384 -0
  18. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +348 -0
  19. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +358 -0
  20. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +398 -0
  21. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +417 -0
  22. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +366 -0
  23. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +384 -0
  24. data/lib/twilio-ruby/rest/{verify → serverless}/v1/service.rb +139 -175
  25. data/lib/twilio-ruby/rest/{verify → serverless}/v1.rb +6 -6
  26. data/lib/twilio-ruby/rest/serverless.rb +46 -0
  27. data/lib/twilio-ruby/rest/trunking/v1/trunk/terminating_sip_domain.rb +419 -0
  28. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +26 -0
  29. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +46 -38
  30. data/lib/twilio-ruby/rest/verify/v2/service/verification_check.rb +24 -20
  31. data/lib/twilio-ruby/rest/verify/v2/service.rb +59 -57
  32. data/lib/twilio-ruby/rest/verify/v2.rb +2 -1
  33. data/lib/twilio-ruby/rest/verify.rb +2 -8
  34. data/lib/twilio-ruby/version.rb +1 -1
  35. data/spec/integration/flex_api/v1/configuration_spec.rb +15 -0
  36. data/spec/integration/messaging/v1/session/participant_spec.rb +10 -10
  37. data/spec/integration/serverless/v1/service/asset/asset_version_spec.rb +144 -0
  38. data/spec/integration/serverless/v1/service/asset_spec.rb +177 -0
  39. data/spec/integration/serverless/v1/service/build_spec.rb +184 -0
  40. data/spec/integration/serverless/v1/service/environment/deployment_spec.rb +137 -0
  41. data/spec/integration/serverless/v1/service/environment/variable_spec.rb +181 -0
  42. data/spec/integration/serverless/v1/service/environment_spec.rb +143 -0
  43. data/spec/integration/serverless/v1/service/function/function_version_spec.rb +144 -0
  44. data/spec/integration/serverless/v1/service/function_spec.rb +177 -0
  45. data/spec/integration/serverless/v1/service_spec.rb +180 -0
  46. data/spec/integration/trunking/v1/trunk/terminating_sip_domain_spec.rb +231 -0
  47. data/spec/integration/trunking/v1/trunk_spec.rb +12 -6
  48. metadata +34 -12
  49. data/lib/twilio-ruby/rest/verify/v1/service/verification.rb +0 -340
  50. data/lib/twilio-ruby/rest/verify/v1/service/verification_check.rb +0 -209
  51. data/spec/integration/verify/v1/service/verification_check_spec.rb +0 -54
  52. data/spec/integration/verify/v1/service/verification_spec.rb +0 -169
  53. data/spec/integration/verify/v1/service_spec.rb +0 -231
@@ -0,0 +1,366 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Serverless < Domain
12
+ class V1 < Version
13
+ class ServiceContext < InstanceContext
14
+ class FunctionContext < InstanceContext
15
+ ##
16
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
17
+ class FunctionVersionList < ListResource
18
+ ##
19
+ # Initialize the FunctionVersionList
20
+ # @param [Version] version Version that contains the resource
21
+ # @param [String] service_sid The service_sid
22
+ # @param [String] function_sid The function_sid
23
+ # @return [FunctionVersionList] FunctionVersionList
24
+ def initialize(version, service_sid: nil, function_sid: nil)
25
+ super(version)
26
+
27
+ # Path Solution
28
+ @solution = {service_sid: service_sid, function_sid: function_sid}
29
+ @uri = "/Services/#{@solution[:service_sid]}/Functions/#{@solution[:function_sid]}/Versions"
30
+ end
31
+
32
+ ##
33
+ # Lists FunctionVersionInstance records from the API as a list.
34
+ # Unlike stream(), this operation is eager and will load `limit` records into
35
+ # memory before returning.
36
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
37
+ # guarantees to never return more than limit. Default is no limit
38
+ # @param [Integer] page_size Number of records to fetch per request, when
39
+ # not set will use the default value of 50 records. If no page_size is defined
40
+ # but a limit is defined, stream() will attempt to read the limit with the most
41
+ # efficient page size, i.e. min(limit, 1000)
42
+ # @return [Array] Array of up to limit results
43
+ def list(limit: nil, page_size: nil)
44
+ self.stream(limit: limit, page_size: page_size).entries
45
+ end
46
+
47
+ ##
48
+ # Streams FunctionVersionInstance records from the API as an Enumerable.
49
+ # This operation lazily loads records as efficiently as possible until the limit
50
+ # is reached.
51
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
52
+ # guarantees to never return more than limit. Default is no limit.
53
+ # @param [Integer] page_size Number of records to fetch per request, when
54
+ # not set will use the default value of 50 records. If no page_size is defined
55
+ # but a limit is defined, stream() will attempt to read the limit with the most
56
+ # efficient page size, i.e. min(limit, 1000)
57
+ # @return [Enumerable] Enumerable that will yield up to limit results
58
+ def stream(limit: nil, page_size: nil)
59
+ limits = @version.read_limits(limit, page_size)
60
+
61
+ page = self.page(page_size: limits[:page_size], )
62
+
63
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
64
+ end
65
+
66
+ ##
67
+ # When passed a block, yields FunctionVersionInstance records from the API.
68
+ # This operation lazily loads records as efficiently as possible until the limit
69
+ # is reached.
70
+ def each
71
+ limits = @version.read_limits
72
+
73
+ page = self.page(page_size: limits[:page_size], )
74
+
75
+ @version.stream(page,
76
+ limit: limits[:limit],
77
+ page_limit: limits[:page_limit]).each {|x| yield x}
78
+ end
79
+
80
+ ##
81
+ # Retrieve a single page of FunctionVersionInstance records from the API.
82
+ # Request is executed immediately.
83
+ # @param [String] page_token PageToken provided by the API
84
+ # @param [Integer] page_number Page Number, this value is simply for client state
85
+ # @param [Integer] page_size Number of records to return, defaults to 50
86
+ # @return [Page] Page of FunctionVersionInstance
87
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
88
+ params = Twilio::Values.of({
89
+ 'PageToken' => page_token,
90
+ 'Page' => page_number,
91
+ 'PageSize' => page_size,
92
+ })
93
+ response = @version.page(
94
+ 'GET',
95
+ @uri,
96
+ params
97
+ )
98
+ FunctionVersionPage.new(@version, response, @solution)
99
+ end
100
+
101
+ ##
102
+ # Retrieve a single page of FunctionVersionInstance records from the API.
103
+ # Request is executed immediately.
104
+ # @param [String] target_url API-generated URL for the requested results page
105
+ # @return [Page] Page of FunctionVersionInstance
106
+ def get_page(target_url)
107
+ response = @version.domain.request(
108
+ 'GET',
109
+ target_url
110
+ )
111
+ FunctionVersionPage.new(@version, response, @solution)
112
+ end
113
+
114
+ ##
115
+ # Retrieve a single page of FunctionVersionInstance records from the API.
116
+ # Request is executed immediately.
117
+ # @param [String] path The path
118
+ # @param [function_version.Visibility] visibility The visibility
119
+ # @return [FunctionVersionInstance] Newly created FunctionVersionInstance
120
+ def create(path: nil, visibility: nil)
121
+ data = Twilio::Values.of({'Path' => path, 'Visibility' => visibility, })
122
+
123
+ payload = @version.create(
124
+ 'POST',
125
+ @uri,
126
+ data: data
127
+ )
128
+
129
+ FunctionVersionInstance.new(
130
+ @version,
131
+ payload,
132
+ service_sid: @solution[:service_sid],
133
+ function_sid: @solution[:function_sid],
134
+ )
135
+ end
136
+
137
+ ##
138
+ # Provide a user friendly representation
139
+ def to_s
140
+ '#<Twilio.Serverless.V1.FunctionVersionList>'
141
+ end
142
+ end
143
+
144
+ ##
145
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
146
+ class FunctionVersionPage < Page
147
+ ##
148
+ # Initialize the FunctionVersionPage
149
+ # @param [Version] version Version that contains the resource
150
+ # @param [Response] response Response from the API
151
+ # @param [Hash] solution Path solution for the resource
152
+ # @return [FunctionVersionPage] FunctionVersionPage
153
+ def initialize(version, response, solution)
154
+ super(version, response)
155
+
156
+ # Path Solution
157
+ @solution = solution
158
+ end
159
+
160
+ ##
161
+ # Build an instance of FunctionVersionInstance
162
+ # @param [Hash] payload Payload response from the API
163
+ # @return [FunctionVersionInstance] FunctionVersionInstance
164
+ def get_instance(payload)
165
+ FunctionVersionInstance.new(
166
+ @version,
167
+ payload,
168
+ service_sid: @solution[:service_sid],
169
+ function_sid: @solution[:function_sid],
170
+ )
171
+ end
172
+
173
+ ##
174
+ # Provide a user friendly representation
175
+ def to_s
176
+ '<Twilio.Serverless.V1.FunctionVersionPage>'
177
+ end
178
+ end
179
+
180
+ ##
181
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
182
+ class FunctionVersionContext < InstanceContext
183
+ ##
184
+ # Initialize the FunctionVersionContext
185
+ # @param [Version] version Version that contains the resource
186
+ # @param [String] service_sid The service_sid
187
+ # @param [String] function_sid The function_sid
188
+ # @param [String] sid The sid
189
+ # @return [FunctionVersionContext] FunctionVersionContext
190
+ def initialize(version, service_sid, function_sid, sid)
191
+ super(version)
192
+
193
+ # Path Solution
194
+ @solution = {service_sid: service_sid, function_sid: function_sid, sid: sid, }
195
+ @uri = "/Services/#{@solution[:service_sid]}/Functions/#{@solution[:function_sid]}/Versions/#{@solution[:sid]}"
196
+ end
197
+
198
+ ##
199
+ # Fetch a FunctionVersionInstance
200
+ # @return [FunctionVersionInstance] Fetched FunctionVersionInstance
201
+ def fetch
202
+ params = Twilio::Values.of({})
203
+
204
+ payload = @version.fetch(
205
+ 'GET',
206
+ @uri,
207
+ params,
208
+ )
209
+
210
+ FunctionVersionInstance.new(
211
+ @version,
212
+ payload,
213
+ service_sid: @solution[:service_sid],
214
+ function_sid: @solution[:function_sid],
215
+ sid: @solution[:sid],
216
+ )
217
+ end
218
+
219
+ ##
220
+ # Provide a user friendly representation
221
+ def to_s
222
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
223
+ "#<Twilio.Serverless.V1.FunctionVersionContext #{context}>"
224
+ end
225
+
226
+ ##
227
+ # Provide a detailed, user friendly representation
228
+ def inspect
229
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
230
+ "#<Twilio.Serverless.V1.FunctionVersionContext #{context}>"
231
+ end
232
+ end
233
+
234
+ ##
235
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
236
+ class FunctionVersionInstance < InstanceResource
237
+ ##
238
+ # Initialize the FunctionVersionInstance
239
+ # @param [Version] version Version that contains the resource
240
+ # @param [Hash] payload payload that contains response from Twilio
241
+ # @param [String] service_sid The service_sid
242
+ # @param [String] function_sid The function_sid
243
+ # @param [String] sid The sid
244
+ # @return [FunctionVersionInstance] FunctionVersionInstance
245
+ def initialize(version, payload, service_sid: nil, function_sid: nil, sid: nil)
246
+ super(version)
247
+
248
+ # Marshaled Properties
249
+ @properties = {
250
+ 'sid' => payload['sid'],
251
+ 'account_sid' => payload['account_sid'],
252
+ 'service_sid' => payload['service_sid'],
253
+ 'function_sid' => payload['function_sid'],
254
+ 'path' => payload['path'],
255
+ 'pre_signed_upload_url' => payload['pre_signed_upload_url'],
256
+ 'visibility' => payload['visibility'],
257
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
258
+ 'url' => payload['url'],
259
+ }
260
+
261
+ # Context
262
+ @instance_context = nil
263
+ @params = {
264
+ 'service_sid' => service_sid,
265
+ 'function_sid' => function_sid,
266
+ 'sid' => sid || @properties['sid'],
267
+ }
268
+ end
269
+
270
+ ##
271
+ # Generate an instance context for the instance, the context is capable of
272
+ # performing various actions. All instance actions are proxied to the context
273
+ # @return [FunctionVersionContext] FunctionVersionContext for this FunctionVersionInstance
274
+ def context
275
+ unless @instance_context
276
+ @instance_context = FunctionVersionContext.new(
277
+ @version,
278
+ @params['service_sid'],
279
+ @params['function_sid'],
280
+ @params['sid'],
281
+ )
282
+ end
283
+ @instance_context
284
+ end
285
+
286
+ ##
287
+ # @return [String] The sid
288
+ def sid
289
+ @properties['sid']
290
+ end
291
+
292
+ ##
293
+ # @return [String] The account_sid
294
+ def account_sid
295
+ @properties['account_sid']
296
+ end
297
+
298
+ ##
299
+ # @return [String] The service_sid
300
+ def service_sid
301
+ @properties['service_sid']
302
+ end
303
+
304
+ ##
305
+ # @return [String] The function_sid
306
+ def function_sid
307
+ @properties['function_sid']
308
+ end
309
+
310
+ ##
311
+ # @return [String] The path
312
+ def path
313
+ @properties['path']
314
+ end
315
+
316
+ ##
317
+ # @return [Hash] The pre_signed_upload_url
318
+ def pre_signed_upload_url
319
+ @properties['pre_signed_upload_url']
320
+ end
321
+
322
+ ##
323
+ # @return [function_version.Visibility] The visibility
324
+ def visibility
325
+ @properties['visibility']
326
+ end
327
+
328
+ ##
329
+ # @return [Time] The date_created
330
+ def date_created
331
+ @properties['date_created']
332
+ end
333
+
334
+ ##
335
+ # @return [String] The url
336
+ def url
337
+ @properties['url']
338
+ end
339
+
340
+ ##
341
+ # Fetch a FunctionVersionInstance
342
+ # @return [FunctionVersionInstance] Fetched FunctionVersionInstance
343
+ def fetch
344
+ context.fetch
345
+ end
346
+
347
+ ##
348
+ # Provide a user friendly representation
349
+ def to_s
350
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
351
+ "<Twilio.Serverless.V1.FunctionVersionInstance #{values}>"
352
+ end
353
+
354
+ ##
355
+ # Provide a detailed, user friendly representation
356
+ def inspect
357
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
358
+ "<Twilio.Serverless.V1.FunctionVersionInstance #{values}>"
359
+ end
360
+ end
361
+ end
362
+ end
363
+ end
364
+ end
365
+ end
366
+ end
@@ -0,0 +1,384 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Serverless < Domain
12
+ class V1 < Version
13
+ class ServiceContext < InstanceContext
14
+ ##
15
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
16
+ class FunctionList < ListResource
17
+ ##
18
+ # Initialize the FunctionList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] service_sid The service_sid
21
+ # @return [FunctionList] FunctionList
22
+ def initialize(version, service_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {service_sid: service_sid}
27
+ @uri = "/Services/#{@solution[:service_sid]}/Functions"
28
+ end
29
+
30
+ ##
31
+ # Lists FunctionInstance records from the API as a list.
32
+ # Unlike stream(), this operation is eager and will load `limit` records into
33
+ # memory before returning.
34
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
35
+ # guarantees to never return more than limit. Default is no limit
36
+ # @param [Integer] page_size Number of records to fetch per request, when
37
+ # not set will use the default value of 50 records. If no page_size is defined
38
+ # but a limit is defined, stream() will attempt to read the limit with the most
39
+ # efficient page size, i.e. min(limit, 1000)
40
+ # @return [Array] Array of up to limit results
41
+ def list(limit: nil, page_size: nil)
42
+ self.stream(limit: limit, page_size: page_size).entries
43
+ end
44
+
45
+ ##
46
+ # Streams FunctionInstance records from the API as an Enumerable.
47
+ # This operation lazily loads records as efficiently as possible until the limit
48
+ # is reached.
49
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
50
+ # guarantees to never return more than limit. Default is no limit.
51
+ # @param [Integer] page_size Number of records to fetch per request, when
52
+ # not set will use the default value of 50 records. If no page_size is defined
53
+ # but a limit is defined, stream() will attempt to read the limit with the most
54
+ # efficient page size, i.e. min(limit, 1000)
55
+ # @return [Enumerable] Enumerable that will yield up to limit results
56
+ def stream(limit: nil, page_size: nil)
57
+ limits = @version.read_limits(limit, page_size)
58
+
59
+ page = self.page(page_size: limits[:page_size], )
60
+
61
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
62
+ end
63
+
64
+ ##
65
+ # When passed a block, yields FunctionInstance records from the API.
66
+ # This operation lazily loads records as efficiently as possible until the limit
67
+ # is reached.
68
+ def each
69
+ limits = @version.read_limits
70
+
71
+ page = self.page(page_size: limits[:page_size], )
72
+
73
+ @version.stream(page,
74
+ limit: limits[:limit],
75
+ page_limit: limits[:page_limit]).each {|x| yield x}
76
+ end
77
+
78
+ ##
79
+ # Retrieve a single page of FunctionInstance records from the API.
80
+ # Request is executed immediately.
81
+ # @param [String] page_token PageToken provided by the API
82
+ # @param [Integer] page_number Page Number, this value is simply for client state
83
+ # @param [Integer] page_size Number of records to return, defaults to 50
84
+ # @return [Page] Page of FunctionInstance
85
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
86
+ params = Twilio::Values.of({
87
+ 'PageToken' => page_token,
88
+ 'Page' => page_number,
89
+ 'PageSize' => page_size,
90
+ })
91
+ response = @version.page(
92
+ 'GET',
93
+ @uri,
94
+ params
95
+ )
96
+ FunctionPage.new(@version, response, @solution)
97
+ end
98
+
99
+ ##
100
+ # Retrieve a single page of FunctionInstance records from the API.
101
+ # Request is executed immediately.
102
+ # @param [String] target_url API-generated URL for the requested results page
103
+ # @return [Page] Page of FunctionInstance
104
+ def get_page(target_url)
105
+ response = @version.domain.request(
106
+ 'GET',
107
+ target_url
108
+ )
109
+ FunctionPage.new(@version, response, @solution)
110
+ end
111
+
112
+ ##
113
+ # Retrieve a single page of FunctionInstance records from the API.
114
+ # Request is executed immediately.
115
+ # @param [String] friendly_name The friendly_name
116
+ # @return [FunctionInstance] Newly created FunctionInstance
117
+ def create(friendly_name: nil)
118
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, })
119
+
120
+ payload = @version.create(
121
+ 'POST',
122
+ @uri,
123
+ data: data
124
+ )
125
+
126
+ FunctionInstance.new(@version, payload, service_sid: @solution[:service_sid], )
127
+ end
128
+
129
+ ##
130
+ # Provide a user friendly representation
131
+ def to_s
132
+ '#<Twilio.Serverless.V1.FunctionList>'
133
+ end
134
+ end
135
+
136
+ ##
137
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
138
+ class FunctionPage < Page
139
+ ##
140
+ # Initialize the FunctionPage
141
+ # @param [Version] version Version that contains the resource
142
+ # @param [Response] response Response from the API
143
+ # @param [Hash] solution Path solution for the resource
144
+ # @return [FunctionPage] FunctionPage
145
+ def initialize(version, response, solution)
146
+ super(version, response)
147
+
148
+ # Path Solution
149
+ @solution = solution
150
+ end
151
+
152
+ ##
153
+ # Build an instance of FunctionInstance
154
+ # @param [Hash] payload Payload response from the API
155
+ # @return [FunctionInstance] FunctionInstance
156
+ def get_instance(payload)
157
+ FunctionInstance.new(@version, payload, service_sid: @solution[:service_sid], )
158
+ end
159
+
160
+ ##
161
+ # Provide a user friendly representation
162
+ def to_s
163
+ '<Twilio.Serverless.V1.FunctionPage>'
164
+ end
165
+ end
166
+
167
+ ##
168
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
169
+ class FunctionContext < InstanceContext
170
+ ##
171
+ # Initialize the FunctionContext
172
+ # @param [Version] version Version that contains the resource
173
+ # @param [String] service_sid The service_sid
174
+ # @param [String] sid The sid
175
+ # @return [FunctionContext] FunctionContext
176
+ def initialize(version, service_sid, sid)
177
+ super(version)
178
+
179
+ # Path Solution
180
+ @solution = {service_sid: service_sid, sid: sid, }
181
+ @uri = "/Services/#{@solution[:service_sid]}/Functions/#{@solution[:sid]}"
182
+
183
+ # Dependents
184
+ @function_versions = nil
185
+ end
186
+
187
+ ##
188
+ # Fetch a FunctionInstance
189
+ # @return [FunctionInstance] Fetched FunctionInstance
190
+ def fetch
191
+ params = Twilio::Values.of({})
192
+
193
+ payload = @version.fetch(
194
+ 'GET',
195
+ @uri,
196
+ params,
197
+ )
198
+
199
+ FunctionInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
200
+ end
201
+
202
+ ##
203
+ # Update the FunctionInstance
204
+ # @param [String] friendly_name The friendly_name
205
+ # @return [FunctionInstance] Updated FunctionInstance
206
+ def update(friendly_name: nil)
207
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, })
208
+
209
+ payload = @version.update(
210
+ 'POST',
211
+ @uri,
212
+ data: data,
213
+ )
214
+
215
+ FunctionInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
216
+ end
217
+
218
+ ##
219
+ # Access the function_versions
220
+ # @return [FunctionVersionList]
221
+ # @return [FunctionVersionContext] if sid was passed.
222
+ def function_versions(sid=:unset)
223
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
224
+
225
+ if sid != :unset
226
+ return FunctionVersionContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
227
+ end
228
+
229
+ unless @function_versions
230
+ @function_versions = FunctionVersionList.new(
231
+ @version,
232
+ service_sid: @solution[:service_sid],
233
+ function_sid: @solution[:sid],
234
+ )
235
+ end
236
+
237
+ @function_versions
238
+ end
239
+
240
+ ##
241
+ # Provide a user friendly representation
242
+ def to_s
243
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
244
+ "#<Twilio.Serverless.V1.FunctionContext #{context}>"
245
+ end
246
+
247
+ ##
248
+ # Provide a detailed, user friendly representation
249
+ def inspect
250
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
251
+ "#<Twilio.Serverless.V1.FunctionContext #{context}>"
252
+ end
253
+ end
254
+
255
+ ##
256
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
257
+ class FunctionInstance < InstanceResource
258
+ ##
259
+ # Initialize the FunctionInstance
260
+ # @param [Version] version Version that contains the resource
261
+ # @param [Hash] payload payload that contains response from Twilio
262
+ # @param [String] service_sid The service_sid
263
+ # @param [String] sid The sid
264
+ # @return [FunctionInstance] FunctionInstance
265
+ def initialize(version, payload, service_sid: nil, sid: nil)
266
+ super(version)
267
+
268
+ # Marshaled Properties
269
+ @properties = {
270
+ 'sid' => payload['sid'],
271
+ 'account_sid' => payload['account_sid'],
272
+ 'service_sid' => payload['service_sid'],
273
+ 'friendly_name' => payload['friendly_name'],
274
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
275
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
276
+ 'url' => payload['url'],
277
+ 'links' => payload['links'],
278
+ }
279
+
280
+ # Context
281
+ @instance_context = nil
282
+ @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
283
+ end
284
+
285
+ ##
286
+ # Generate an instance context for the instance, the context is capable of
287
+ # performing various actions. All instance actions are proxied to the context
288
+ # @return [FunctionContext] FunctionContext for this FunctionInstance
289
+ def context
290
+ unless @instance_context
291
+ @instance_context = FunctionContext.new(@version, @params['service_sid'], @params['sid'], )
292
+ end
293
+ @instance_context
294
+ end
295
+
296
+ ##
297
+ # @return [String] The sid
298
+ def sid
299
+ @properties['sid']
300
+ end
301
+
302
+ ##
303
+ # @return [String] The account_sid
304
+ def account_sid
305
+ @properties['account_sid']
306
+ end
307
+
308
+ ##
309
+ # @return [String] The service_sid
310
+ def service_sid
311
+ @properties['service_sid']
312
+ end
313
+
314
+ ##
315
+ # @return [String] The friendly_name
316
+ def friendly_name
317
+ @properties['friendly_name']
318
+ end
319
+
320
+ ##
321
+ # @return [Time] The date_created
322
+ def date_created
323
+ @properties['date_created']
324
+ end
325
+
326
+ ##
327
+ # @return [Time] The date_updated
328
+ def date_updated
329
+ @properties['date_updated']
330
+ end
331
+
332
+ ##
333
+ # @return [String] The url
334
+ def url
335
+ @properties['url']
336
+ end
337
+
338
+ ##
339
+ # @return [String] The links
340
+ def links
341
+ @properties['links']
342
+ end
343
+
344
+ ##
345
+ # Fetch a FunctionInstance
346
+ # @return [FunctionInstance] Fetched FunctionInstance
347
+ def fetch
348
+ context.fetch
349
+ end
350
+
351
+ ##
352
+ # Update the FunctionInstance
353
+ # @param [String] friendly_name The friendly_name
354
+ # @return [FunctionInstance] Updated FunctionInstance
355
+ def update(friendly_name: nil)
356
+ context.update(friendly_name: friendly_name, )
357
+ end
358
+
359
+ ##
360
+ # Access the function_versions
361
+ # @return [function_versions] function_versions
362
+ def function_versions
363
+ context.function_versions
364
+ end
365
+
366
+ ##
367
+ # Provide a user friendly representation
368
+ def to_s
369
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
370
+ "<Twilio.Serverless.V1.FunctionInstance #{values}>"
371
+ end
372
+
373
+ ##
374
+ # Provide a detailed, user friendly representation
375
+ def inspect
376
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
377
+ "<Twilio.Serverless.V1.FunctionInstance #{values}>"
378
+ end
379
+ end
380
+ end
381
+ end
382
+ end
383
+ end
384
+ end