twilio-ruby 5.39.3 → 5.40.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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +24 -1
  3. data/CONTRIBUTING.md +2 -2
  4. data/README.md +2 -3
  5. data/lib/twilio-ruby/rest/api/v2010/account/application.rb +6 -4
  6. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +3 -3
  7. data/lib/twilio-ruby/rest/client.rb +7 -0
  8. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +12 -2
  9. data/lib/twilio-ruby/rest/events.rb +54 -0
  10. data/lib/twilio-ruby/rest/events/v1.rb +58 -0
  11. data/lib/twilio-ruby/rest/events/v1/sink.rb +379 -0
  12. data/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb +115 -0
  13. data/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb +118 -0
  14. data/lib/twilio-ruby/rest/events/v1/subscription.rb +358 -0
  15. data/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +322 -0
  16. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +33 -17
  17. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +13 -1
  18. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +12 -11
  19. data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +75 -9
  20. data/lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribe_rule.rb +0 -6
  21. data/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +5 -19
  22. data/lib/twilio-ruby/version.rb +1 -1
  23. data/spec/integration/events/v1/sink/sink_test_spec.rb +42 -0
  24. data/spec/integration/events/v1/sink/sink_validate_spec.rb +44 -0
  25. data/spec/integration/events/v1/sink_spec.rb +217 -0
  26. data/spec/integration/events/v1/subscription/subscribed_event_spec.rb +212 -0
  27. data/spec/integration/events/v1/subscription_spec.rb +205 -0
  28. data/spec/integration/supersim/v1/usage_record_spec.rb +463 -18
  29. data/spec/integration/wireless/v1/sim/data_session_spec.rb +2 -2
  30. metadata +19 -2
@@ -0,0 +1,115 @@
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 Events < Domain
12
+ class V1 < Version
13
+ class SinkContext < 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 SinkTestList < ListResource
17
+ ##
18
+ # Initialize the SinkTestList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] sid The sid
21
+ # @return [SinkTestList] SinkTestList
22
+ def initialize(version, sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {sid: sid}
27
+ @uri = "/Sinks/#{@solution[:sid]}/Test"
28
+ end
29
+
30
+ ##
31
+ # Create the SinkTestInstance
32
+ # @return [SinkTestInstance] Created SinkTestInstance
33
+ def create
34
+ payload = @version.create('POST', @uri)
35
+
36
+ SinkTestInstance.new(@version, payload, sid: @solution[:sid], )
37
+ end
38
+
39
+ ##
40
+ # Provide a user friendly representation
41
+ def to_s
42
+ '#<Twilio.Events.V1.SinkTestList>'
43
+ end
44
+ end
45
+
46
+ ##
47
+ # 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.
48
+ class SinkTestPage < Page
49
+ ##
50
+ # Initialize the SinkTestPage
51
+ # @param [Version] version Version that contains the resource
52
+ # @param [Response] response Response from the API
53
+ # @param [Hash] solution Path solution for the resource
54
+ # @return [SinkTestPage] SinkTestPage
55
+ def initialize(version, response, solution)
56
+ super(version, response)
57
+
58
+ # Path Solution
59
+ @solution = solution
60
+ end
61
+
62
+ ##
63
+ # Build an instance of SinkTestInstance
64
+ # @param [Hash] payload Payload response from the API
65
+ # @return [SinkTestInstance] SinkTestInstance
66
+ def get_instance(payload)
67
+ SinkTestInstance.new(@version, payload, sid: @solution[:sid], )
68
+ end
69
+
70
+ ##
71
+ # Provide a user friendly representation
72
+ def to_s
73
+ '<Twilio.Events.V1.SinkTestPage>'
74
+ end
75
+ end
76
+
77
+ ##
78
+ # 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.
79
+ class SinkTestInstance < InstanceResource
80
+ ##
81
+ # Initialize the SinkTestInstance
82
+ # @param [Version] version Version that contains the resource
83
+ # @param [Hash] payload payload that contains response from Twilio
84
+ # @param [String] sid The sid
85
+ # @return [SinkTestInstance] SinkTestInstance
86
+ def initialize(version, payload, sid: nil)
87
+ super(version)
88
+
89
+ # Marshaled Properties
90
+ @properties = {'result' => payload['result'], }
91
+ end
92
+
93
+ ##
94
+ # @return [String] The result
95
+ def result
96
+ @properties['result']
97
+ end
98
+
99
+ ##
100
+ # Provide a user friendly representation
101
+ def to_s
102
+ "<Twilio.Events.V1.SinkTestInstance>"
103
+ end
104
+
105
+ ##
106
+ # Provide a detailed, user friendly representation
107
+ def inspect
108
+ "<Twilio.Events.V1.SinkTestInstance>"
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,118 @@
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 Events < Domain
12
+ class V1 < Version
13
+ class SinkContext < 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 SinkValidateList < ListResource
17
+ ##
18
+ # Initialize the SinkValidateList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] sid The sid
21
+ # @return [SinkValidateList] SinkValidateList
22
+ def initialize(version, sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {sid: sid}
27
+ @uri = "/Sinks/#{@solution[:sid]}/Validate"
28
+ end
29
+
30
+ ##
31
+ # Create the SinkValidateInstance
32
+ # @param [String] test_id The test_id
33
+ # @return [SinkValidateInstance] Created SinkValidateInstance
34
+ def create(test_id: nil)
35
+ data = Twilio::Values.of({'TestId' => test_id, })
36
+
37
+ payload = @version.create('POST', @uri, data: data)
38
+
39
+ SinkValidateInstance.new(@version, payload, sid: @solution[:sid], )
40
+ end
41
+
42
+ ##
43
+ # Provide a user friendly representation
44
+ def to_s
45
+ '#<Twilio.Events.V1.SinkValidateList>'
46
+ end
47
+ end
48
+
49
+ ##
50
+ # 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.
51
+ class SinkValidatePage < Page
52
+ ##
53
+ # Initialize the SinkValidatePage
54
+ # @param [Version] version Version that contains the resource
55
+ # @param [Response] response Response from the API
56
+ # @param [Hash] solution Path solution for the resource
57
+ # @return [SinkValidatePage] SinkValidatePage
58
+ def initialize(version, response, solution)
59
+ super(version, response)
60
+
61
+ # Path Solution
62
+ @solution = solution
63
+ end
64
+
65
+ ##
66
+ # Build an instance of SinkValidateInstance
67
+ # @param [Hash] payload Payload response from the API
68
+ # @return [SinkValidateInstance] SinkValidateInstance
69
+ def get_instance(payload)
70
+ SinkValidateInstance.new(@version, payload, sid: @solution[:sid], )
71
+ end
72
+
73
+ ##
74
+ # Provide a user friendly representation
75
+ def to_s
76
+ '<Twilio.Events.V1.SinkValidatePage>'
77
+ end
78
+ end
79
+
80
+ ##
81
+ # 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.
82
+ class SinkValidateInstance < InstanceResource
83
+ ##
84
+ # Initialize the SinkValidateInstance
85
+ # @param [Version] version Version that contains the resource
86
+ # @param [Hash] payload payload that contains response from Twilio
87
+ # @param [String] sid The sid
88
+ # @return [SinkValidateInstance] SinkValidateInstance
89
+ def initialize(version, payload, sid: nil)
90
+ super(version)
91
+
92
+ # Marshaled Properties
93
+ @properties = {'result' => payload['result'], }
94
+ end
95
+
96
+ ##
97
+ # @return [String] The result
98
+ def result
99
+ @properties['result']
100
+ end
101
+
102
+ ##
103
+ # Provide a user friendly representation
104
+ def to_s
105
+ "<Twilio.Events.V1.SinkValidateInstance>"
106
+ end
107
+
108
+ ##
109
+ # Provide a detailed, user friendly representation
110
+ def inspect
111
+ "<Twilio.Events.V1.SinkValidateInstance>"
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,358 @@
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 Events < Domain
12
+ class V1 < Version
13
+ ##
14
+ # 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.
15
+ class SubscriptionList < ListResource
16
+ ##
17
+ # Initialize the SubscriptionList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [SubscriptionList] SubscriptionList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/Subscriptions"
26
+ end
27
+
28
+ ##
29
+ # Lists SubscriptionInstance records from the API as a list.
30
+ # Unlike stream(), this operation is eager and will load `limit` records into
31
+ # memory before returning.
32
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
33
+ # guarantees to never return more than limit. Default is no limit
34
+ # @param [Integer] page_size Number of records to fetch per request, when
35
+ # not set will use the default value of 50 records. If no page_size is defined
36
+ # but a limit is defined, stream() will attempt to read the limit with the most
37
+ # efficient page size, i.e. min(limit, 1000)
38
+ # @return [Array] Array of up to limit results
39
+ def list(limit: nil, page_size: nil)
40
+ self.stream(limit: limit, page_size: page_size).entries
41
+ end
42
+
43
+ ##
44
+ # Streams SubscriptionInstance records from the API as an Enumerable.
45
+ # This operation lazily loads records as efficiently as possible until the limit
46
+ # is reached.
47
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
48
+ # guarantees to never return more than limit. Default is no limit.
49
+ # @param [Integer] page_size Number of records to fetch per request, when
50
+ # not set will use the default value of 50 records. If no page_size is defined
51
+ # but a limit is defined, stream() will attempt to read the limit with the most
52
+ # efficient page size, i.e. min(limit, 1000)
53
+ # @return [Enumerable] Enumerable that will yield up to limit results
54
+ def stream(limit: nil, page_size: nil)
55
+ limits = @version.read_limits(limit, page_size)
56
+
57
+ page = self.page(page_size: limits[:page_size], )
58
+
59
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
60
+ end
61
+
62
+ ##
63
+ # When passed a block, yields SubscriptionInstance records from the API.
64
+ # This operation lazily loads records as efficiently as possible until the limit
65
+ # is reached.
66
+ def each
67
+ limits = @version.read_limits
68
+
69
+ page = self.page(page_size: limits[:page_size], )
70
+
71
+ @version.stream(page,
72
+ limit: limits[:limit],
73
+ page_limit: limits[:page_limit]).each {|x| yield x}
74
+ end
75
+
76
+ ##
77
+ # Retrieve a single page of SubscriptionInstance records from the API.
78
+ # Request is executed immediately.
79
+ # @param [String] page_token PageToken provided by the API
80
+ # @param [Integer] page_number Page Number, this value is simply for client state
81
+ # @param [Integer] page_size Number of records to return, defaults to 50
82
+ # @return [Page] Page of SubscriptionInstance
83
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
84
+ params = Twilio::Values.of({
85
+ 'PageToken' => page_token,
86
+ 'Page' => page_number,
87
+ 'PageSize' => page_size,
88
+ })
89
+
90
+ response = @version.page('GET', @uri, params: params)
91
+
92
+ SubscriptionPage.new(@version, response, @solution)
93
+ end
94
+
95
+ ##
96
+ # Retrieve a single page of SubscriptionInstance records from the API.
97
+ # Request is executed immediately.
98
+ # @param [String] target_url API-generated URL for the requested results page
99
+ # @return [Page] Page of SubscriptionInstance
100
+ def get_page(target_url)
101
+ response = @version.domain.request(
102
+ 'GET',
103
+ target_url
104
+ )
105
+ SubscriptionPage.new(@version, response, @solution)
106
+ end
107
+
108
+ ##
109
+ # Create the SubscriptionInstance
110
+ # @param [String] description The description
111
+ # @param [String] sink_sid The sink_sid
112
+ # @param [Hash] types The types
113
+ # @return [SubscriptionInstance] Created SubscriptionInstance
114
+ def create(description: nil, sink_sid: nil, types: nil)
115
+ data = Twilio::Values.of({
116
+ 'Description' => description,
117
+ 'SinkSid' => sink_sid,
118
+ 'Types' => Twilio.serialize_list(types) { |e| Twilio.serialize_object(e) },
119
+ })
120
+
121
+ payload = @version.create('POST', @uri, data: data)
122
+
123
+ SubscriptionInstance.new(@version, payload, )
124
+ end
125
+
126
+ ##
127
+ # Provide a user friendly representation
128
+ def to_s
129
+ '#<Twilio.Events.V1.SubscriptionList>'
130
+ end
131
+ end
132
+
133
+ ##
134
+ # 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.
135
+ class SubscriptionPage < Page
136
+ ##
137
+ # Initialize the SubscriptionPage
138
+ # @param [Version] version Version that contains the resource
139
+ # @param [Response] response Response from the API
140
+ # @param [Hash] solution Path solution for the resource
141
+ # @return [SubscriptionPage] SubscriptionPage
142
+ def initialize(version, response, solution)
143
+ super(version, response)
144
+
145
+ # Path Solution
146
+ @solution = solution
147
+ end
148
+
149
+ ##
150
+ # Build an instance of SubscriptionInstance
151
+ # @param [Hash] payload Payload response from the API
152
+ # @return [SubscriptionInstance] SubscriptionInstance
153
+ def get_instance(payload)
154
+ SubscriptionInstance.new(@version, payload, )
155
+ end
156
+
157
+ ##
158
+ # Provide a user friendly representation
159
+ def to_s
160
+ '<Twilio.Events.V1.SubscriptionPage>'
161
+ end
162
+ end
163
+
164
+ ##
165
+ # 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.
166
+ class SubscriptionContext < InstanceContext
167
+ ##
168
+ # Initialize the SubscriptionContext
169
+ # @param [Version] version Version that contains the resource
170
+ # @param [String] sid The sid
171
+ # @return [SubscriptionContext] SubscriptionContext
172
+ def initialize(version, sid)
173
+ super(version)
174
+
175
+ # Path Solution
176
+ @solution = {sid: sid, }
177
+ @uri = "/Subscriptions/#{@solution[:sid]}"
178
+
179
+ # Dependents
180
+ @subscribed_events = nil
181
+ end
182
+
183
+ ##
184
+ # Fetch the SubscriptionInstance
185
+ # @return [SubscriptionInstance] Fetched SubscriptionInstance
186
+ def fetch
187
+ payload = @version.fetch('GET', @uri)
188
+
189
+ SubscriptionInstance.new(@version, payload, sid: @solution[:sid], )
190
+ end
191
+
192
+ ##
193
+ # Delete the SubscriptionInstance
194
+ # @return [Boolean] true if delete succeeds, false otherwise
195
+ def delete
196
+ @version.delete('DELETE', @uri)
197
+ end
198
+
199
+ ##
200
+ # Access the subscribed_events
201
+ # @return [SubscribedEventList]
202
+ # @return [SubscribedEventContext] if type was passed.
203
+ def subscribed_events(type=:unset)
204
+ raise ArgumentError, 'type cannot be nil' if type.nil?
205
+
206
+ if type != :unset
207
+ return SubscribedEventContext.new(@version, @solution[:sid], type, )
208
+ end
209
+
210
+ unless @subscribed_events
211
+ @subscribed_events = SubscribedEventList.new(@version, subscription_sid: @solution[:sid], )
212
+ end
213
+
214
+ @subscribed_events
215
+ end
216
+
217
+ ##
218
+ # Provide a user friendly representation
219
+ def to_s
220
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
221
+ "#<Twilio.Events.V1.SubscriptionContext #{context}>"
222
+ end
223
+
224
+ ##
225
+ # Provide a detailed, user friendly representation
226
+ def inspect
227
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
228
+ "#<Twilio.Events.V1.SubscriptionContext #{context}>"
229
+ end
230
+ end
231
+
232
+ ##
233
+ # 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.
234
+ class SubscriptionInstance < InstanceResource
235
+ ##
236
+ # Initialize the SubscriptionInstance
237
+ # @param [Version] version Version that contains the resource
238
+ # @param [Hash] payload payload that contains response from Twilio
239
+ # @param [String] sid The sid
240
+ # @return [SubscriptionInstance] SubscriptionInstance
241
+ def initialize(version, payload, sid: nil)
242
+ super(version)
243
+
244
+ # Marshaled Properties
245
+ @properties = {
246
+ 'account_sid' => payload['account_sid'],
247
+ 'sid' => payload['sid'],
248
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
249
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
250
+ 'description' => payload['description'],
251
+ 'sink_sid' => payload['sink_sid'],
252
+ 'url' => payload['url'],
253
+ 'links' => payload['links'],
254
+ }
255
+
256
+ # Context
257
+ @instance_context = nil
258
+ @params = {'sid' => sid || @properties['sid'], }
259
+ end
260
+
261
+ ##
262
+ # Generate an instance context for the instance, the context is capable of
263
+ # performing various actions. All instance actions are proxied to the context
264
+ # @return [SubscriptionContext] SubscriptionContext for this SubscriptionInstance
265
+ def context
266
+ unless @instance_context
267
+ @instance_context = SubscriptionContext.new(@version, @params['sid'], )
268
+ end
269
+ @instance_context
270
+ end
271
+
272
+ ##
273
+ # @return [String] The account_sid
274
+ def account_sid
275
+ @properties['account_sid']
276
+ end
277
+
278
+ ##
279
+ # @return [String] The sid
280
+ def sid
281
+ @properties['sid']
282
+ end
283
+
284
+ ##
285
+ # @return [Time] The date_created
286
+ def date_created
287
+ @properties['date_created']
288
+ end
289
+
290
+ ##
291
+ # @return [Time] The date_updated
292
+ def date_updated
293
+ @properties['date_updated']
294
+ end
295
+
296
+ ##
297
+ # @return [String] The description
298
+ def description
299
+ @properties['description']
300
+ end
301
+
302
+ ##
303
+ # @return [String] The sink_sid
304
+ def sink_sid
305
+ @properties['sink_sid']
306
+ end
307
+
308
+ ##
309
+ # @return [String] The url
310
+ def url
311
+ @properties['url']
312
+ end
313
+
314
+ ##
315
+ # @return [String] The links
316
+ def links
317
+ @properties['links']
318
+ end
319
+
320
+ ##
321
+ # Fetch the SubscriptionInstance
322
+ # @return [SubscriptionInstance] Fetched SubscriptionInstance
323
+ def fetch
324
+ context.fetch
325
+ end
326
+
327
+ ##
328
+ # Delete the SubscriptionInstance
329
+ # @return [Boolean] true if delete succeeds, false otherwise
330
+ def delete
331
+ context.delete
332
+ end
333
+
334
+ ##
335
+ # Access the subscribed_events
336
+ # @return [subscribed_events] subscribed_events
337
+ def subscribed_events
338
+ context.subscribed_events
339
+ end
340
+
341
+ ##
342
+ # Provide a user friendly representation
343
+ def to_s
344
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
345
+ "<Twilio.Events.V1.SubscriptionInstance #{values}>"
346
+ end
347
+
348
+ ##
349
+ # Provide a detailed, user friendly representation
350
+ def inspect
351
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
352
+ "<Twilio.Events.V1.SubscriptionInstance #{values}>"
353
+ end
354
+ end
355
+ end
356
+ end
357
+ end
358
+ end