twilio-ruby 5.39.1 → 5.40.2

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 (122) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGES.md +101 -1
  4. data/CONTRIBUTING.md +2 -2
  5. data/ISSUE_TEMPLATE.md +5 -1
  6. data/Makefile +1 -1
  7. data/PULL_REQUEST_TEMPLATE.md +1 -1
  8. data/README.md +4 -3
  9. data/lib/twilio-ruby/framework/version.rb +2 -7
  10. data/lib/twilio-ruby/rest/api/v2010/account/application.rb +6 -4
  11. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +3 -3
  12. data/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb +79 -60
  13. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +14 -0
  14. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +14 -0
  15. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +14 -0
  16. data/lib/twilio-ruby/rest/client.rb +7 -0
  17. data/lib/twilio-ruby/rest/conversations.rb +52 -0
  18. data/lib/twilio-ruby/rest/conversations/v1.rb +88 -1
  19. data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +258 -0
  20. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +15 -4
  21. data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +19 -10
  22. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +12 -2
  23. data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
  24. data/lib/twilio-ruby/rest/conversations/v1/notification.rb +310 -0
  25. data/lib/twilio-ruby/rest/conversations/v1/role.rb +372 -0
  26. data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
  27. data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +385 -0
  28. data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +259 -0
  29. data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
  30. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +546 -0
  31. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +388 -0
  32. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +513 -0
  33. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +454 -0
  34. data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +393 -0
  35. data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
  36. data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
  37. data/lib/twilio-ruby/rest/events.rb +63 -0
  38. data/lib/twilio-ruby/rest/events/v1.rb +74 -0
  39. data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
  40. data/lib/twilio-ruby/rest/events/v1/sink.rb +380 -0
  41. data/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb +115 -0
  42. data/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb +119 -0
  43. data/lib/twilio-ruby/rest/events/v1/subscription.rb +363 -0
  44. data/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +322 -0
  45. data/lib/twilio-ruby/rest/messaging.rb +6 -0
  46. data/lib/twilio-ruby/rest/messaging/v1.rb +7 -0
  47. data/lib/twilio-ruby/rest/messaging/v1/deactivation.rb +164 -0
  48. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +3 -3
  49. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb +16 -2
  50. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
  51. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +45 -4
  52. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +14 -1
  53. data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
  54. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
  55. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
  56. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
  57. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
  58. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
  59. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
  60. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
  61. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
  62. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
  63. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +12 -11
  64. data/lib/twilio-ruby/rest/supersim/v1/sim.rb +39 -9
  65. data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +75 -9
  66. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
  67. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +25 -3
  68. data/lib/twilio-ruby/rest/verify/v2/service.rb +21 -9
  69. data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +10 -2
  70. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +4 -1
  71. data/lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribe_rule.rb +0 -6
  72. data/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +5 -19
  73. data/lib/twilio-ruby/version.rb +1 -1
  74. data/spec/framework/version_spec.rb +42 -0
  75. data/spec/holodeck/holodeck.rb +3 -3
  76. data/spec/integration/api/v2010/account/incoming_phone_number/local_spec.rb +35 -36
  77. data/spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb +39 -40
  78. data/spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb +35 -36
  79. data/spec/integration/api/v2010/account/incoming_phone_number_spec.rb +25 -23
  80. data/spec/integration/api/v2010/account/message_spec.rb +37 -0
  81. data/spec/integration/bulkexports/v1/export/day_spec.rb +5 -5
  82. data/spec/integration/bulkexports/v1/export_configuration_spec.rb +4 -4
  83. data/spec/integration/bulkexports/v1/export_spec.rb +3 -3
  84. data/spec/integration/conversations/v1/configuration_spec.rb +85 -0
  85. data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
  86. data/spec/integration/conversations/v1/conversation/message_spec.rb +38 -0
  87. data/spec/integration/conversations/v1/conversation/participant_spec.rb +60 -4
  88. data/spec/integration/conversations/v1/conversation_spec.rb +35 -0
  89. data/spec/integration/conversations/v1/credential_spec.rb +219 -0
  90. data/spec/integration/conversations/v1/notification_spec.rb +107 -0
  91. data/spec/integration/conversations/v1/role_spec.rb +249 -0
  92. data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
  93. data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
  94. data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
  95. data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
  96. data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
  97. data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
  98. data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
  99. data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
  100. data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
  101. data/spec/integration/conversations/v1/service_spec.rb +174 -0
  102. data/spec/integration/conversations/v1/user_spec.rb +220 -0
  103. data/spec/integration/events/v1/event_type_spec.rb +133 -0
  104. data/spec/integration/events/v1/sink/sink_test_spec.rb +42 -0
  105. data/spec/integration/events/v1/sink/sink_validate_spec.rb +44 -0
  106. data/spec/integration/events/v1/sink_spec.rb +217 -0
  107. data/spec/integration/events/v1/subscription/subscribed_event_spec.rb +212 -0
  108. data/spec/integration/events/v1/subscription_spec.rb +205 -0
  109. data/spec/integration/messaging/v1/deactivation_spec.rb +40 -0
  110. data/spec/integration/numbers/v2/regulatory_compliance/end_user_spec.rb +27 -0
  111. data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
  112. data/spec/integration/studio/v1/flow/execution/execution_step_spec.rb +1 -0
  113. data/spec/integration/studio/v2/flow/execution/execution_step_spec.rb +1 -0
  114. data/spec/integration/supersim/v1/sim_spec.rb +23 -0
  115. data/spec/integration/supersim/v1/usage_record_spec.rb +463 -18
  116. data/spec/integration/trunking/v1/trunk_spec.rb +4 -0
  117. data/spec/integration/verify/v2/service/access_token_spec.rb +1 -1
  118. data/spec/integration/verify/v2/service/entity/challenge_spec.rb +8 -8
  119. data/spec/integration/video/v1/room_spec.rb +37 -0
  120. data/spec/integration/wireless/v1/sim/data_session_spec.rb +2 -2
  121. data/spec/spec_helper.rb +1 -1
  122. metadata +70 -2
@@ -0,0 +1,74 @@
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
12
+ class V1 < Version
13
+ ##
14
+ # Initialize the V1 version of Events
15
+ def initialize(domain)
16
+ super
17
+ @version = 'v1'
18
+ @event_types = nil
19
+ @sinks = nil
20
+ @subscriptions = nil
21
+ end
22
+
23
+ ##
24
+ # @param [String] type The type
25
+ # @return [Twilio::REST::Events::V1::EventTypeContext] if type was passed.
26
+ # @return [Twilio::REST::Events::V1::EventTypeList]
27
+ def event_types(type=:unset)
28
+ if type.nil?
29
+ raise ArgumentError, 'type cannot be nil'
30
+ elsif type == :unset
31
+ @event_types ||= EventTypeList.new self
32
+ else
33
+ EventTypeContext.new(self, type)
34
+ end
35
+ end
36
+
37
+ ##
38
+ # @param [String] sid A 34 character string that uniquely identifies this Sink.
39
+ # @return [Twilio::REST::Events::V1::SinkContext] if sid was passed.
40
+ # @return [Twilio::REST::Events::V1::SinkList]
41
+ def sinks(sid=:unset)
42
+ if sid.nil?
43
+ raise ArgumentError, 'sid cannot be nil'
44
+ elsif sid == :unset
45
+ @sinks ||= SinkList.new self
46
+ else
47
+ SinkContext.new(self, sid)
48
+ end
49
+ end
50
+
51
+ ##
52
+ # @param [String] sid A 34 character string that uniquely identifies this
53
+ # Subscription.
54
+ # @return [Twilio::REST::Events::V1::SubscriptionContext] if sid was passed.
55
+ # @return [Twilio::REST::Events::V1::SubscriptionList]
56
+ def subscriptions(sid=:unset)
57
+ if sid.nil?
58
+ raise ArgumentError, 'sid cannot be nil'
59
+ elsif sid == :unset
60
+ @subscriptions ||= SubscriptionList.new self
61
+ else
62
+ SubscriptionContext.new(self, sid)
63
+ end
64
+ end
65
+
66
+ ##
67
+ # Provide a user friendly representation
68
+ def to_s
69
+ '<Twilio::REST::Events::V1>'
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,291 @@
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 EventTypeList < ListResource
16
+ ##
17
+ # Initialize the EventTypeList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [EventTypeList] EventTypeList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/Types"
26
+ end
27
+
28
+ ##
29
+ # Lists EventTypeInstance 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 EventTypeInstance 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 EventTypeInstance 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 EventTypeInstance 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 EventTypeInstance
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
+ EventTypePage.new(@version, response, @solution)
93
+ end
94
+
95
+ ##
96
+ # Retrieve a single page of EventTypeInstance 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 EventTypeInstance
100
+ def get_page(target_url)
101
+ response = @version.domain.request(
102
+ 'GET',
103
+ target_url
104
+ )
105
+ EventTypePage.new(@version, response, @solution)
106
+ end
107
+
108
+ ##
109
+ # Provide a user friendly representation
110
+ def to_s
111
+ '#<Twilio.Events.V1.EventTypeList>'
112
+ end
113
+ end
114
+
115
+ ##
116
+ # 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.
117
+ class EventTypePage < Page
118
+ ##
119
+ # Initialize the EventTypePage
120
+ # @param [Version] version Version that contains the resource
121
+ # @param [Response] response Response from the API
122
+ # @param [Hash] solution Path solution for the resource
123
+ # @return [EventTypePage] EventTypePage
124
+ def initialize(version, response, solution)
125
+ super(version, response)
126
+
127
+ # Path Solution
128
+ @solution = solution
129
+ end
130
+
131
+ ##
132
+ # Build an instance of EventTypeInstance
133
+ # @param [Hash] payload Payload response from the API
134
+ # @return [EventTypeInstance] EventTypeInstance
135
+ def get_instance(payload)
136
+ EventTypeInstance.new(@version, payload, )
137
+ end
138
+
139
+ ##
140
+ # Provide a user friendly representation
141
+ def to_s
142
+ '<Twilio.Events.V1.EventTypePage>'
143
+ end
144
+ end
145
+
146
+ ##
147
+ # 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.
148
+ class EventTypeContext < InstanceContext
149
+ ##
150
+ # Initialize the EventTypeContext
151
+ # @param [Version] version Version that contains the resource
152
+ # @param [String] type The type
153
+ # @return [EventTypeContext] EventTypeContext
154
+ def initialize(version, type)
155
+ super(version)
156
+
157
+ # Path Solution
158
+ @solution = {type: type, }
159
+ @uri = "/Types/#{@solution[:type]}"
160
+ end
161
+
162
+ ##
163
+ # Fetch the EventTypeInstance
164
+ # @return [EventTypeInstance] Fetched EventTypeInstance
165
+ def fetch
166
+ payload = @version.fetch('GET', @uri)
167
+
168
+ EventTypeInstance.new(@version, payload, type: @solution[:type], )
169
+ end
170
+
171
+ ##
172
+ # Provide a user friendly representation
173
+ def to_s
174
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
175
+ "#<Twilio.Events.V1.EventTypeContext #{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.Events.V1.EventTypeContext #{context}>"
183
+ end
184
+ end
185
+
186
+ ##
187
+ # 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.
188
+ class EventTypeInstance < InstanceResource
189
+ ##
190
+ # Initialize the EventTypeInstance
191
+ # @param [Version] version Version that contains the resource
192
+ # @param [Hash] payload payload that contains response from Twilio
193
+ # @param [String] type The type
194
+ # @return [EventTypeInstance] EventTypeInstance
195
+ def initialize(version, payload, type: nil)
196
+ super(version)
197
+
198
+ # Marshaled Properties
199
+ @properties = {
200
+ 'type' => payload['type'],
201
+ 'schema_id' => payload['schema_id'],
202
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
203
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
204
+ 'description' => payload['description'],
205
+ 'url' => payload['url'],
206
+ 'links' => payload['links'],
207
+ }
208
+
209
+ # Context
210
+ @instance_context = nil
211
+ @params = {'type' => type || @properties['type'], }
212
+ end
213
+
214
+ ##
215
+ # Generate an instance context for the instance, the context is capable of
216
+ # performing various actions. All instance actions are proxied to the context
217
+ # @return [EventTypeContext] EventTypeContext for this EventTypeInstance
218
+ def context
219
+ unless @instance_context
220
+ @instance_context = EventTypeContext.new(@version, @params['type'], )
221
+ end
222
+ @instance_context
223
+ end
224
+
225
+ ##
226
+ # @return [String] The type
227
+ def type
228
+ @properties['type']
229
+ end
230
+
231
+ ##
232
+ # @return [String] The schema_id
233
+ def schema_id
234
+ @properties['schema_id']
235
+ end
236
+
237
+ ##
238
+ # @return [Time] The date_created
239
+ def date_created
240
+ @properties['date_created']
241
+ end
242
+
243
+ ##
244
+ # @return [Time] The date_updated
245
+ def date_updated
246
+ @properties['date_updated']
247
+ end
248
+
249
+ ##
250
+ # @return [String] The description
251
+ def description
252
+ @properties['description']
253
+ end
254
+
255
+ ##
256
+ # @return [String] The url
257
+ def url
258
+ @properties['url']
259
+ end
260
+
261
+ ##
262
+ # @return [String] The links
263
+ def links
264
+ @properties['links']
265
+ end
266
+
267
+ ##
268
+ # Fetch the EventTypeInstance
269
+ # @return [EventTypeInstance] Fetched EventTypeInstance
270
+ def fetch
271
+ context.fetch
272
+ end
273
+
274
+ ##
275
+ # Provide a user friendly representation
276
+ def to_s
277
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
278
+ "<Twilio.Events.V1.EventTypeInstance #{values}>"
279
+ end
280
+
281
+ ##
282
+ # Provide a detailed, user friendly representation
283
+ def inspect
284
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
285
+ "<Twilio.Events.V1.EventTypeInstance #{values}>"
286
+ end
287
+ end
288
+ end
289
+ end
290
+ end
291
+ end
@@ -0,0 +1,380 @@
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 SinkList < ListResource
16
+ ##
17
+ # Initialize the SinkList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [SinkList] SinkList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/Sinks"
26
+ end
27
+
28
+ ##
29
+ # Create the SinkInstance
30
+ # @param [String] description A human readable description for the Sink
31
+ # @param [Hash] sink_configuration The information required for Twilio to connect
32
+ # to the provided Sink encoded as JSON.
33
+ # @param [sink.SinkType] sink_type The Sink type. Can only be "kinesis" currently.
34
+ # @return [SinkInstance] Created SinkInstance
35
+ def create(description: nil, sink_configuration: nil, sink_type: nil)
36
+ data = Twilio::Values.of({
37
+ 'Description' => description,
38
+ 'SinkConfiguration' => Twilio.serialize_object(sink_configuration),
39
+ 'SinkType' => sink_type,
40
+ })
41
+
42
+ payload = @version.create('POST', @uri, data: data)
43
+
44
+ SinkInstance.new(@version, payload, )
45
+ end
46
+
47
+ ##
48
+ # Lists SinkInstance records from the API as a list.
49
+ # Unlike stream(), this operation is eager and will load `limit` records into
50
+ # memory before returning.
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 [Array] Array of up to limit results
58
+ def list(limit: nil, page_size: nil)
59
+ self.stream(limit: limit, page_size: page_size).entries
60
+ end
61
+
62
+ ##
63
+ # Streams SinkInstance records from the API as an Enumerable.
64
+ # This operation lazily loads records as efficiently as possible until the limit
65
+ # is reached.
66
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
67
+ # guarantees to never return more than limit. Default is no limit.
68
+ # @param [Integer] page_size Number of records to fetch per request, when
69
+ # not set will use the default value of 50 records. If no page_size is defined
70
+ # but a limit is defined, stream() will attempt to read the limit with the most
71
+ # efficient page size, i.e. min(limit, 1000)
72
+ # @return [Enumerable] Enumerable that will yield up to limit results
73
+ def stream(limit: nil, page_size: nil)
74
+ limits = @version.read_limits(limit, page_size)
75
+
76
+ page = self.page(page_size: limits[:page_size], )
77
+
78
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
79
+ end
80
+
81
+ ##
82
+ # When passed a block, yields SinkInstance records from the API.
83
+ # This operation lazily loads records as efficiently as possible until the limit
84
+ # is reached.
85
+ def each
86
+ limits = @version.read_limits
87
+
88
+ page = self.page(page_size: limits[:page_size], )
89
+
90
+ @version.stream(page,
91
+ limit: limits[:limit],
92
+ page_limit: limits[:page_limit]).each {|x| yield x}
93
+ end
94
+
95
+ ##
96
+ # Retrieve a single page of SinkInstance records from the API.
97
+ # Request is executed immediately.
98
+ # @param [String] page_token PageToken provided by the API
99
+ # @param [Integer] page_number Page Number, this value is simply for client state
100
+ # @param [Integer] page_size Number of records to return, defaults to 50
101
+ # @return [Page] Page of SinkInstance
102
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
103
+ params = Twilio::Values.of({
104
+ 'PageToken' => page_token,
105
+ 'Page' => page_number,
106
+ 'PageSize' => page_size,
107
+ })
108
+
109
+ response = @version.page('GET', @uri, params: params)
110
+
111
+ SinkPage.new(@version, response, @solution)
112
+ end
113
+
114
+ ##
115
+ # Retrieve a single page of SinkInstance records from the API.
116
+ # Request is executed immediately.
117
+ # @param [String] target_url API-generated URL for the requested results page
118
+ # @return [Page] Page of SinkInstance
119
+ def get_page(target_url)
120
+ response = @version.domain.request(
121
+ 'GET',
122
+ target_url
123
+ )
124
+ SinkPage.new(@version, response, @solution)
125
+ end
126
+
127
+ ##
128
+ # Provide a user friendly representation
129
+ def to_s
130
+ '#<Twilio.Events.V1.SinkList>'
131
+ end
132
+ end
133
+
134
+ ##
135
+ # 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.
136
+ class SinkPage < Page
137
+ ##
138
+ # Initialize the SinkPage
139
+ # @param [Version] version Version that contains the resource
140
+ # @param [Response] response Response from the API
141
+ # @param [Hash] solution Path solution for the resource
142
+ # @return [SinkPage] SinkPage
143
+ def initialize(version, response, solution)
144
+ super(version, response)
145
+
146
+ # Path Solution
147
+ @solution = solution
148
+ end
149
+
150
+ ##
151
+ # Build an instance of SinkInstance
152
+ # @param [Hash] payload Payload response from the API
153
+ # @return [SinkInstance] SinkInstance
154
+ def get_instance(payload)
155
+ SinkInstance.new(@version, payload, )
156
+ end
157
+
158
+ ##
159
+ # Provide a user friendly representation
160
+ def to_s
161
+ '<Twilio.Events.V1.SinkPage>'
162
+ end
163
+ end
164
+
165
+ ##
166
+ # 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.
167
+ class SinkContext < InstanceContext
168
+ ##
169
+ # Initialize the SinkContext
170
+ # @param [Version] version Version that contains the resource
171
+ # @param [String] sid A 34 character string that uniquely identifies this Sink.
172
+ # @return [SinkContext] SinkContext
173
+ def initialize(version, sid)
174
+ super(version)
175
+
176
+ # Path Solution
177
+ @solution = {sid: sid, }
178
+ @uri = "/Sinks/#{@solution[:sid]}"
179
+
180
+ # Dependents
181
+ @sink_test = nil
182
+ @sink_validate = nil
183
+ end
184
+
185
+ ##
186
+ # Fetch the SinkInstance
187
+ # @return [SinkInstance] Fetched SinkInstance
188
+ def fetch
189
+ payload = @version.fetch('GET', @uri)
190
+
191
+ SinkInstance.new(@version, payload, sid: @solution[:sid], )
192
+ end
193
+
194
+ ##
195
+ # Delete the SinkInstance
196
+ # @return [Boolean] true if delete succeeds, false otherwise
197
+ def delete
198
+ @version.delete('DELETE', @uri)
199
+ end
200
+
201
+ ##
202
+ # Access the sink_test
203
+ # @return [SinkTestList]
204
+ # @return [SinkTestContext]
205
+ def sink_test
206
+ unless @sink_test
207
+ @sink_test = SinkTestList.new(@version, sid: @solution[:sid], )
208
+ end
209
+
210
+ @sink_test
211
+ end
212
+
213
+ ##
214
+ # Access the sink_validate
215
+ # @return [SinkValidateList]
216
+ # @return [SinkValidateContext]
217
+ def sink_validate
218
+ unless @sink_validate
219
+ @sink_validate = SinkValidateList.new(@version, sid: @solution[:sid], )
220
+ end
221
+
222
+ @sink_validate
223
+ end
224
+
225
+ ##
226
+ # Provide a user friendly representation
227
+ def to_s
228
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
229
+ "#<Twilio.Events.V1.SinkContext #{context}>"
230
+ end
231
+
232
+ ##
233
+ # Provide a detailed, user friendly representation
234
+ def inspect
235
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
236
+ "#<Twilio.Events.V1.SinkContext #{context}>"
237
+ end
238
+ end
239
+
240
+ ##
241
+ # 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.
242
+ class SinkInstance < InstanceResource
243
+ ##
244
+ # Initialize the SinkInstance
245
+ # @param [Version] version Version that contains the resource
246
+ # @param [Hash] payload payload that contains response from Twilio
247
+ # @param [String] sid A 34 character string that uniquely identifies this Sink.
248
+ # @return [SinkInstance] SinkInstance
249
+ def initialize(version, payload, sid: nil)
250
+ super(version)
251
+
252
+ # Marshaled Properties
253
+ @properties = {
254
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
255
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
256
+ 'description' => payload['description'],
257
+ 'sid' => payload['sid'],
258
+ 'sink_configuration' => payload['sink_configuration'],
259
+ 'sink_type' => payload['sink_type'],
260
+ 'status' => payload['status'],
261
+ 'url' => payload['url'],
262
+ 'links' => payload['links'],
263
+ }
264
+
265
+ # Context
266
+ @instance_context = nil
267
+ @params = {'sid' => sid || @properties['sid'], }
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 [SinkContext] SinkContext for this SinkInstance
274
+ def context
275
+ unless @instance_context
276
+ @instance_context = SinkContext.new(@version, @params['sid'], )
277
+ end
278
+ @instance_context
279
+ end
280
+
281
+ ##
282
+ # @return [Time] The date this Sink was created
283
+ def date_created
284
+ @properties['date_created']
285
+ end
286
+
287
+ ##
288
+ # @return [Time] The date this Sink was updated
289
+ def date_updated
290
+ @properties['date_updated']
291
+ end
292
+
293
+ ##
294
+ # @return [String] Sink Description
295
+ def description
296
+ @properties['description']
297
+ end
298
+
299
+ ##
300
+ # @return [String] A string that uniquely identifies this Sink.
301
+ def sid
302
+ @properties['sid']
303
+ end
304
+
305
+ ##
306
+ # @return [Hash] JSON Sink configuration.
307
+ def sink_configuration
308
+ @properties['sink_configuration']
309
+ end
310
+
311
+ ##
312
+ # @return [sink.SinkType] Sink type.
313
+ def sink_type
314
+ @properties['sink_type']
315
+ end
316
+
317
+ ##
318
+ # @return [sink.Status] The Status of this Sink
319
+ def status
320
+ @properties['status']
321
+ end
322
+
323
+ ##
324
+ # @return [String] The URL of this resource.
325
+ def url
326
+ @properties['url']
327
+ end
328
+
329
+ ##
330
+ # @return [String] Nested resource URLs.
331
+ def links
332
+ @properties['links']
333
+ end
334
+
335
+ ##
336
+ # Fetch the SinkInstance
337
+ # @return [SinkInstance] Fetched SinkInstance
338
+ def fetch
339
+ context.fetch
340
+ end
341
+
342
+ ##
343
+ # Delete the SinkInstance
344
+ # @return [Boolean] true if delete succeeds, false otherwise
345
+ def delete
346
+ context.delete
347
+ end
348
+
349
+ ##
350
+ # Access the sink_test
351
+ # @return [sink_test] sink_test
352
+ def sink_test
353
+ context.sink_test
354
+ end
355
+
356
+ ##
357
+ # Access the sink_validate
358
+ # @return [sink_validate] sink_validate
359
+ def sink_validate
360
+ context.sink_validate
361
+ end
362
+
363
+ ##
364
+ # Provide a user friendly representation
365
+ def to_s
366
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
367
+ "<Twilio.Events.V1.SinkInstance #{values}>"
368
+ end
369
+
370
+ ##
371
+ # Provide a detailed, user friendly representation
372
+ def inspect
373
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
374
+ "<Twilio.Events.V1.SinkInstance #{values}>"
375
+ end
376
+ end
377
+ end
378
+ end
379
+ end
380
+ end