twilio-ruby 5.39.2 → 5.40.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGES.md +107 -1
  4. data/CONTRIBUTING.md +2 -2
  5. data/ISSUE_TEMPLATE.md +5 -1
  6. data/PULL_REQUEST_TEMPLATE.md +1 -1
  7. data/README.md +4 -3
  8. data/lib/twilio-ruby/framework/version.rb +4 -8
  9. data/lib/twilio-ruby/rest/api/v2010/account/application.rb +6 -4
  10. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +12 -3
  11. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/machine_to_machine.rb +12 -3
  12. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/mobile.rb +12 -3
  13. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/national.rb +12 -3
  14. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb +12 -3
  15. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb +12 -3
  16. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/voip.rb +12 -3
  17. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +2 -1
  18. data/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb +85 -60
  19. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +5 -2
  20. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +14 -0
  21. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +14 -0
  22. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +14 -0
  23. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +8 -1
  24. data/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb +3 -1
  25. data/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb +2 -1
  26. data/lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb +8 -4
  27. data/lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb +11 -4
  28. data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb +13 -6
  29. data/lib/twilio-ruby/rest/client.rb +7 -0
  30. data/lib/twilio-ruby/rest/conversations.rb +39 -3
  31. data/lib/twilio-ruby/rest/conversations/v1.rb +68 -5
  32. data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +268 -0
  33. data/lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb +262 -0
  34. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +21 -10
  35. data/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb +13 -10
  36. data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +34 -19
  37. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +48 -32
  38. data/lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb +14 -11
  39. data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
  40. data/lib/twilio-ruby/rest/conversations/v1/role.rb +374 -0
  41. data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
  42. data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +388 -0
  43. data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +271 -0
  44. data/lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb +315 -0
  45. data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
  46. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +549 -0
  47. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +394 -0
  48. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +519 -0
  49. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +457 -0
  50. data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +395 -0
  51. data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
  52. data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
  53. data/lib/twilio-ruby/rest/events.rb +72 -0
  54. data/lib/twilio-ruby/rest/events/v1.rb +90 -0
  55. data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
  56. data/lib/twilio-ruby/rest/events/v1/schema.rb +226 -0
  57. data/lib/twilio-ruby/rest/events/v1/schema/schema_version.rb +290 -0
  58. data/lib/twilio-ruby/rest/events/v1/sink.rb +380 -0
  59. data/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb +115 -0
  60. data/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb +119 -0
  61. data/lib/twilio-ruby/rest/events/v1/subscription.rb +383 -0
  62. data/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +216 -0
  63. data/lib/twilio-ruby/rest/fax/v1/fax.rb +2 -1
  64. data/lib/twilio-ruby/rest/messaging.rb +6 -0
  65. data/lib/twilio-ruby/rest/messaging/v1.rb +7 -0
  66. data/lib/twilio-ruby/rest/messaging/v1/deactivation.rb +164 -0
  67. data/lib/twilio-ruby/rest/messaging/v1/service.rb +6 -3
  68. data/lib/twilio-ruby/rest/notify/v1/credential.rb +12 -6
  69. data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +10 -2
  70. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +3 -3
  71. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb +16 -2
  72. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
  73. data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb +10 -5
  74. data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.rb +6 -3
  75. data/lib/twilio-ruby/rest/preview/trusted_comms/business/insights.rb +1 -4
  76. data/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb +3 -1
  77. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +45 -4
  78. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +14 -1
  79. data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
  80. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
  81. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
  82. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
  83. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
  84. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
  85. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
  86. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
  87. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
  88. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
  89. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +12 -11
  90. data/lib/twilio-ruby/rest/supersim/v1/sim.rb +17 -7
  91. data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +75 -9
  92. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
  93. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +6 -2
  94. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +1 -4
  95. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb +6 -2
  96. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +38 -23
  97. data/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb +2 -1
  98. data/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb +2 -1
  99. data/lib/twilio-ruby/rest/trunking/v1/trunk/recording.rb +201 -0
  100. data/lib/twilio-ruby/rest/verify/v2/service.rb +21 -9
  101. data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +10 -2
  102. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +7 -2
  103. data/lib/twilio-ruby/rest/video/v1/composition.rb +7 -3
  104. data/lib/twilio-ruby/rest/video/v1/composition_hook.rb +18 -9
  105. data/lib/twilio-ruby/rest/video/v1/room.rb +2 -1
  106. data/lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribe_rule.rb +0 -6
  107. data/lib/twilio-ruby/rest/voice/v1/dialing_permissions.rb +1 -4
  108. data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +2 -1
  109. data/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +5 -19
  110. data/lib/twilio-ruby/version.rb +1 -1
  111. data/spec/framework/version_spec.rb +53 -0
  112. data/spec/holodeck/holodeck.rb +3 -3
  113. data/spec/integration/api/v2010/account/incoming_phone_number/local_spec.rb +35 -36
  114. data/spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb +39 -40
  115. data/spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb +35 -36
  116. data/spec/integration/api/v2010/account/incoming_phone_number_spec.rb +25 -23
  117. data/spec/integration/api/v2010/account/message_spec.rb +37 -0
  118. data/spec/integration/bulkexports/v1/export/day_spec.rb +5 -5
  119. data/spec/integration/bulkexports/v1/export_configuration_spec.rb +4 -4
  120. data/spec/integration/bulkexports/v1/export_spec.rb +3 -3
  121. data/spec/integration/conversations/v1/{webhook_spec.rb → configuration/webhook_spec.rb} +12 -8
  122. data/spec/integration/conversations/v1/configuration_spec.rb +87 -0
  123. data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
  124. data/spec/integration/conversations/v1/conversation/message_spec.rb +38 -0
  125. data/spec/integration/conversations/v1/conversation/participant_spec.rb +60 -4
  126. data/spec/integration/conversations/v1/conversation_spec.rb +35 -0
  127. data/spec/integration/conversations/v1/credential_spec.rb +219 -0
  128. data/spec/integration/conversations/v1/role_spec.rb +249 -0
  129. data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
  130. data/spec/integration/conversations/v1/service/configuration/notification_spec.rb +115 -0
  131. data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
  132. data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
  133. data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
  134. data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
  135. data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
  136. data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
  137. data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
  138. data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
  139. data/spec/integration/conversations/v1/service_spec.rb +174 -0
  140. data/spec/integration/conversations/v1/user_spec.rb +220 -0
  141. data/spec/integration/events/v1/event_type_spec.rb +133 -0
  142. data/spec/integration/events/v1/schema/schema_version_spec.rb +126 -0
  143. data/spec/integration/events/v1/schema_spec.rb +46 -0
  144. data/spec/integration/events/v1/sink/sink_test_spec.rb +42 -0
  145. data/spec/integration/events/v1/sink/sink_validate_spec.rb +44 -0
  146. data/spec/integration/events/v1/sink_spec.rb +217 -0
  147. data/spec/integration/events/v1/subscription/subscribed_event_spec.rb +91 -0
  148. data/spec/integration/events/v1/subscription_spec.rb +243 -0
  149. data/spec/integration/messaging/v1/deactivation_spec.rb +40 -0
  150. data/spec/integration/numbers/v2/regulatory_compliance/end_user_spec.rb +27 -0
  151. data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
  152. data/spec/integration/studio/v1/flow/execution/execution_step_spec.rb +1 -0
  153. data/spec/integration/studio/v2/flow/execution/execution_step_spec.rb +1 -0
  154. data/spec/integration/supersim/v1/sim_spec.rb +23 -0
  155. data/spec/integration/supersim/v1/usage_record_spec.rb +463 -18
  156. data/spec/integration/trunking/v1/trunk/recording_spec.rb +79 -0
  157. data/spec/integration/trunking/v1/trunk_spec.rb +4 -0
  158. data/spec/integration/verify/v2/service/access_token_spec.rb +1 -1
  159. data/spec/integration/verify/v2/service/entity/challenge_spec.rb +8 -8
  160. data/spec/integration/video/v1/room_spec.rb +37 -0
  161. data/spec/integration/wireless/v1/sim/data_session_spec.rb +2 -2
  162. data/spec/spec_helper.rb +1 -1
  163. metadata +82 -5
  164. data/lib/twilio-ruby/rest/conversations/v1/webhook.rb +0 -262
@@ -0,0 +1,290 @@
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 SchemaContext < 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 VersionList < ListResource
17
+ ##
18
+ # Initialize the VersionList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] id The unique identifier of the schema. Each schema can have
21
+ # multiple versions, that share the same id.
22
+ # @return [VersionList] VersionList
23
+ def initialize(version, id: nil)
24
+ super(version)
25
+
26
+ # Path Solution
27
+ @solution = {id: id}
28
+ @uri = "/Schemas/#{@solution[:id]}/Versions"
29
+ end
30
+
31
+ ##
32
+ # Lists VersionInstance records from the API as a list.
33
+ # Unlike stream(), this operation is eager and will load `limit` records into
34
+ # memory before returning.
35
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
36
+ # guarantees to never return more than limit. Default is no limit
37
+ # @param [Integer] page_size Number of records to fetch per request, when
38
+ # not set will use the default value of 50 records. If no page_size is defined
39
+ # but a limit is defined, stream() will attempt to read the limit with the most
40
+ # efficient page size, i.e. min(limit, 1000)
41
+ # @return [Array] Array of up to limit results
42
+ def list(limit: nil, page_size: nil)
43
+ self.stream(limit: limit, page_size: page_size).entries
44
+ end
45
+
46
+ ##
47
+ # Streams VersionInstance records from the API as an Enumerable.
48
+ # This operation lazily loads records as efficiently as possible until the limit
49
+ # is reached.
50
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
51
+ # guarantees to never return more than limit. Default is no limit.
52
+ # @param [Integer] page_size Number of records to fetch per request, when
53
+ # not set will use the default value of 50 records. If no page_size is defined
54
+ # but a limit is defined, stream() will attempt to read the limit with the most
55
+ # efficient page size, i.e. min(limit, 1000)
56
+ # @return [Enumerable] Enumerable that will yield up to limit results
57
+ def stream(limit: nil, page_size: nil)
58
+ limits = @version.read_limits(limit, page_size)
59
+
60
+ page = self.page(page_size: limits[:page_size], )
61
+
62
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
63
+ end
64
+
65
+ ##
66
+ # When passed a block, yields VersionInstance records from the API.
67
+ # This operation lazily loads records as efficiently as possible until the limit
68
+ # is reached.
69
+ def each
70
+ limits = @version.read_limits
71
+
72
+ page = self.page(page_size: limits[:page_size], )
73
+
74
+ @version.stream(page,
75
+ limit: limits[:limit],
76
+ page_limit: limits[:page_limit]).each {|x| yield x}
77
+ end
78
+
79
+ ##
80
+ # Retrieve a single page of VersionInstance records from the API.
81
+ # Request is executed immediately.
82
+ # @param [String] page_token PageToken provided by the API
83
+ # @param [Integer] page_number Page Number, this value is simply for client state
84
+ # @param [Integer] page_size Number of records to return, defaults to 50
85
+ # @return [Page] Page of VersionInstance
86
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
87
+ params = Twilio::Values.of({
88
+ 'PageToken' => page_token,
89
+ 'Page' => page_number,
90
+ 'PageSize' => page_size,
91
+ })
92
+
93
+ response = @version.page('GET', @uri, params: params)
94
+
95
+ VersionPage.new(@version, response, @solution)
96
+ end
97
+
98
+ ##
99
+ # Retrieve a single page of VersionInstance records from the API.
100
+ # Request is executed immediately.
101
+ # @param [String] target_url API-generated URL for the requested results page
102
+ # @return [Page] Page of VersionInstance
103
+ def get_page(target_url)
104
+ response = @version.domain.request(
105
+ 'GET',
106
+ target_url
107
+ )
108
+ VersionPage.new(@version, response, @solution)
109
+ end
110
+
111
+ ##
112
+ # Provide a user friendly representation
113
+ def to_s
114
+ '#<Twilio.Events.V1.VersionList>'
115
+ end
116
+ end
117
+
118
+ ##
119
+ # 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.
120
+ class VersionPage < Page
121
+ ##
122
+ # Initialize the VersionPage
123
+ # @param [Version] version Version that contains the resource
124
+ # @param [Response] response Response from the API
125
+ # @param [Hash] solution Path solution for the resource
126
+ # @return [VersionPage] VersionPage
127
+ def initialize(version, response, solution)
128
+ super(version, response)
129
+
130
+ # Path Solution
131
+ @solution = solution
132
+ end
133
+
134
+ ##
135
+ # Build an instance of VersionInstance
136
+ # @param [Hash] payload Payload response from the API
137
+ # @return [VersionInstance] VersionInstance
138
+ def get_instance(payload)
139
+ VersionInstance.new(@version, payload, id: @solution[:id], )
140
+ end
141
+
142
+ ##
143
+ # Provide a user friendly representation
144
+ def to_s
145
+ '<Twilio.Events.V1.VersionPage>'
146
+ end
147
+ end
148
+
149
+ ##
150
+ # 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.
151
+ class VersionContext < InstanceContext
152
+ ##
153
+ # Initialize the VersionContext
154
+ # @param [Version] version Version that contains the resource
155
+ # @param [String] id The unique identifier of the schema. Each schema can have
156
+ # multiple versions, that share the same id.
157
+ # @param [String] schema_version The version of the schema
158
+ # @return [VersionContext] VersionContext
159
+ def initialize(version, id, schema_version)
160
+ super(version)
161
+
162
+ # Path Solution
163
+ @solution = {id: id, schema_version: schema_version, }
164
+ @uri = "/Schemas/#{@solution[:id]}/Versions/#{@solution[:schema_version]}"
165
+ end
166
+
167
+ ##
168
+ # Fetch the VersionInstance
169
+ # @return [VersionInstance] Fetched VersionInstance
170
+ def fetch
171
+ payload = @version.fetch('GET', @uri)
172
+
173
+ VersionInstance.new(
174
+ @version,
175
+ payload,
176
+ id: @solution[:id],
177
+ schema_version: @solution[:schema_version],
178
+ )
179
+ end
180
+
181
+ ##
182
+ # Provide a user friendly representation
183
+ def to_s
184
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
185
+ "#<Twilio.Events.V1.VersionContext #{context}>"
186
+ end
187
+
188
+ ##
189
+ # Provide a detailed, user friendly representation
190
+ def inspect
191
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
192
+ "#<Twilio.Events.V1.VersionContext #{context}>"
193
+ end
194
+ end
195
+
196
+ ##
197
+ # 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.
198
+ class VersionInstance < InstanceResource
199
+ ##
200
+ # Initialize the VersionInstance
201
+ # @param [Version] version Version that contains the resource
202
+ # @param [Hash] payload payload that contains response from Twilio
203
+ # @param [String] id The unique identifier of the schema. Each schema can have
204
+ # multiple versions, that share the same id.
205
+ # @param [String] schema_version The version of the schema
206
+ # @return [VersionInstance] VersionInstance
207
+ def initialize(version, payload, id: nil, schema_version: nil)
208
+ super(version)
209
+
210
+ # Marshaled Properties
211
+ @properties = {
212
+ 'id' => payload['id'],
213
+ 'schema_version' => payload['schema_version'].to_i,
214
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
215
+ 'url' => payload['url'],
216
+ 'raw' => payload['raw'],
217
+ }
218
+
219
+ # Context
220
+ @instance_context = nil
221
+ @params = {'id' => id, 'schema_version' => schema_version || @properties['schema_version'], }
222
+ end
223
+
224
+ ##
225
+ # Generate an instance context for the instance, the context is capable of
226
+ # performing various actions. All instance actions are proxied to the context
227
+ # @return [VersionContext] VersionContext for this VersionInstance
228
+ def context
229
+ unless @instance_context
230
+ @instance_context = VersionContext.new(@version, @params['id'], @params['schema_version'], )
231
+ end
232
+ @instance_context
233
+ end
234
+
235
+ ##
236
+ # @return [String] The unique identifier of the schema.
237
+ def id
238
+ @properties['id']
239
+ end
240
+
241
+ ##
242
+ # @return [String] The version of this schema.
243
+ def schema_version
244
+ @properties['schema_version']
245
+ end
246
+
247
+ ##
248
+ # @return [Time] The date the schema version was created.
249
+ def date_created
250
+ @properties['date_created']
251
+ end
252
+
253
+ ##
254
+ # @return [String] The URL of this resource.
255
+ def url
256
+ @properties['url']
257
+ end
258
+
259
+ ##
260
+ # @return [String] The raw
261
+ def raw
262
+ @properties['raw']
263
+ end
264
+
265
+ ##
266
+ # Fetch the VersionInstance
267
+ # @return [VersionInstance] Fetched VersionInstance
268
+ def fetch
269
+ context.fetch
270
+ end
271
+
272
+ ##
273
+ # Provide a user friendly representation
274
+ def to_s
275
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
276
+ "<Twilio.Events.V1.VersionInstance #{values}>"
277
+ end
278
+
279
+ ##
280
+ # Provide a detailed, user friendly representation
281
+ def inspect
282
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
283
+ "<Twilio.Events.V1.VersionInstance #{values}>"
284
+ end
285
+ end
286
+ end
287
+ end
288
+ end
289
+ end
290
+ 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