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,374 @@
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 Conversations < Domain
12
+ class V1 < Version
13
+ ##
14
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
15
+ class RoleList < ListResource
16
+ ##
17
+ # Initialize the RoleList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [RoleList] RoleList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/Roles"
26
+ end
27
+
28
+ ##
29
+ # Create the RoleInstance
30
+ # @param [String] friendly_name A descriptive string that you create to describe
31
+ # the new resource. It can be up to 64 characters long.
32
+ # @param [role.RoleType] type The type of role. Can be: `conversation` for
33
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource)
34
+ # roles or `service` for [Conversation
35
+ # Service](https://www.twilio.com/docs/conversations/api/service-resource) roles.
36
+ # @param [String] permission A permission that you grant to the new role. Only one
37
+ # permission can be granted per parameter. To assign more than one permission,
38
+ # repeat this parameter for each permission value. The values for this parameter
39
+ # depend on the role's `type`.
40
+ # @return [RoleInstance] Created RoleInstance
41
+ def create(friendly_name: nil, type: nil, permission: nil)
42
+ data = Twilio::Values.of({
43
+ 'FriendlyName' => friendly_name,
44
+ 'Type' => type,
45
+ 'Permission' => Twilio.serialize_list(permission) { |e| e },
46
+ })
47
+
48
+ payload = @version.create('POST', @uri, data: data)
49
+
50
+ RoleInstance.new(@version, payload, )
51
+ end
52
+
53
+ ##
54
+ # Lists RoleInstance records from the API as a list.
55
+ # Unlike stream(), this operation is eager and will load `limit` records into
56
+ # memory before returning.
57
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
58
+ # guarantees to never return more than limit. Default is no limit
59
+ # @param [Integer] page_size Number of records to fetch per request, when
60
+ # not set will use the default value of 50 records. If no page_size is defined
61
+ # but a limit is defined, stream() will attempt to read the limit with the most
62
+ # efficient page size, i.e. min(limit, 1000)
63
+ # @return [Array] Array of up to limit results
64
+ def list(limit: nil, page_size: nil)
65
+ self.stream(limit: limit, page_size: page_size).entries
66
+ end
67
+
68
+ ##
69
+ # Streams RoleInstance records from the API as an Enumerable.
70
+ # This operation lazily loads records as efficiently as possible until the limit
71
+ # is reached.
72
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
73
+ # guarantees to never return more than limit. Default is no limit.
74
+ # @param [Integer] page_size Number of records to fetch per request, when
75
+ # not set will use the default value of 50 records. If no page_size is defined
76
+ # but a limit is defined, stream() will attempt to read the limit with the most
77
+ # efficient page size, i.e. min(limit, 1000)
78
+ # @return [Enumerable] Enumerable that will yield up to limit results
79
+ def stream(limit: nil, page_size: nil)
80
+ limits = @version.read_limits(limit, page_size)
81
+
82
+ page = self.page(page_size: limits[:page_size], )
83
+
84
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
85
+ end
86
+
87
+ ##
88
+ # When passed a block, yields RoleInstance records from the API.
89
+ # This operation lazily loads records as efficiently as possible until the limit
90
+ # is reached.
91
+ def each
92
+ limits = @version.read_limits
93
+
94
+ page = self.page(page_size: limits[:page_size], )
95
+
96
+ @version.stream(page,
97
+ limit: limits[:limit],
98
+ page_limit: limits[:page_limit]).each {|x| yield x}
99
+ end
100
+
101
+ ##
102
+ # Retrieve a single page of RoleInstance records from the API.
103
+ # Request is executed immediately.
104
+ # @param [String] page_token PageToken provided by the API
105
+ # @param [Integer] page_number Page Number, this value is simply for client state
106
+ # @param [Integer] page_size Number of records to return, defaults to 50
107
+ # @return [Page] Page of RoleInstance
108
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
109
+ params = Twilio::Values.of({
110
+ 'PageToken' => page_token,
111
+ 'Page' => page_number,
112
+ 'PageSize' => page_size,
113
+ })
114
+
115
+ response = @version.page('GET', @uri, params: params)
116
+
117
+ RolePage.new(@version, response, @solution)
118
+ end
119
+
120
+ ##
121
+ # Retrieve a single page of RoleInstance records from the API.
122
+ # Request is executed immediately.
123
+ # @param [String] target_url API-generated URL for the requested results page
124
+ # @return [Page] Page of RoleInstance
125
+ def get_page(target_url)
126
+ response = @version.domain.request(
127
+ 'GET',
128
+ target_url
129
+ )
130
+ RolePage.new(@version, response, @solution)
131
+ end
132
+
133
+ ##
134
+ # Provide a user friendly representation
135
+ def to_s
136
+ '#<Twilio.Conversations.V1.RoleList>'
137
+ end
138
+ end
139
+
140
+ ##
141
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
142
+ class RolePage < Page
143
+ ##
144
+ # Initialize the RolePage
145
+ # @param [Version] version Version that contains the resource
146
+ # @param [Response] response Response from the API
147
+ # @param [Hash] solution Path solution for the resource
148
+ # @return [RolePage] RolePage
149
+ def initialize(version, response, solution)
150
+ super(version, response)
151
+
152
+ # Path Solution
153
+ @solution = solution
154
+ end
155
+
156
+ ##
157
+ # Build an instance of RoleInstance
158
+ # @param [Hash] payload Payload response from the API
159
+ # @return [RoleInstance] RoleInstance
160
+ def get_instance(payload)
161
+ RoleInstance.new(@version, payload, )
162
+ end
163
+
164
+ ##
165
+ # Provide a user friendly representation
166
+ def to_s
167
+ '<Twilio.Conversations.V1.RolePage>'
168
+ end
169
+ end
170
+
171
+ ##
172
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
173
+ class RoleContext < InstanceContext
174
+ ##
175
+ # Initialize the RoleContext
176
+ # @param [Version] version Version that contains the resource
177
+ # @param [String] sid The SID of the Role resource to fetch.
178
+ # @return [RoleContext] RoleContext
179
+ def initialize(version, sid)
180
+ super(version)
181
+
182
+ # Path Solution
183
+ @solution = {sid: sid, }
184
+ @uri = "/Roles/#{@solution[:sid]}"
185
+ end
186
+
187
+ ##
188
+ # Update the RoleInstance
189
+ # @param [String] permission A permission that you grant to the role. Only one
190
+ # permission can be granted per parameter. To assign more than one permission,
191
+ # repeat this parameter for each permission value. Note that the update action
192
+ # replaces all previously assigned permissions with those defined in the update
193
+ # action. To remove a permission, do not include it in the subsequent update
194
+ # action. The values for this parameter depend on the role's `type`.
195
+ # @return [RoleInstance] Updated RoleInstance
196
+ def update(permission: nil)
197
+ data = Twilio::Values.of({'Permission' => Twilio.serialize_list(permission) { |e| e }, })
198
+
199
+ payload = @version.update('POST', @uri, data: data)
200
+
201
+ RoleInstance.new(@version, payload, sid: @solution[:sid], )
202
+ end
203
+
204
+ ##
205
+ # Delete the RoleInstance
206
+ # @return [Boolean] true if delete succeeds, false otherwise
207
+ def delete
208
+ @version.delete('DELETE', @uri)
209
+ end
210
+
211
+ ##
212
+ # Fetch the RoleInstance
213
+ # @return [RoleInstance] Fetched RoleInstance
214
+ def fetch
215
+ payload = @version.fetch('GET', @uri)
216
+
217
+ RoleInstance.new(@version, payload, sid: @solution[:sid], )
218
+ end
219
+
220
+ ##
221
+ # Provide a user friendly representation
222
+ def to_s
223
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
224
+ "#<Twilio.Conversations.V1.RoleContext #{context}>"
225
+ end
226
+
227
+ ##
228
+ # Provide a detailed, user friendly representation
229
+ def inspect
230
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
231
+ "#<Twilio.Conversations.V1.RoleContext #{context}>"
232
+ end
233
+ end
234
+
235
+ ##
236
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
237
+ class RoleInstance < InstanceResource
238
+ ##
239
+ # Initialize the RoleInstance
240
+ # @param [Version] version Version that contains the resource
241
+ # @param [Hash] payload payload that contains response from Twilio
242
+ # @param [String] sid The SID of the Role resource to fetch.
243
+ # @return [RoleInstance] RoleInstance
244
+ def initialize(version, payload, sid: nil)
245
+ super(version)
246
+
247
+ # Marshaled Properties
248
+ @properties = {
249
+ 'sid' => payload['sid'],
250
+ 'account_sid' => payload['account_sid'],
251
+ 'chat_service_sid' => payload['chat_service_sid'],
252
+ 'friendly_name' => payload['friendly_name'],
253
+ 'type' => payload['type'],
254
+ 'permissions' => payload['permissions'],
255
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
256
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
257
+ 'url' => payload['url'],
258
+ }
259
+
260
+ # Context
261
+ @instance_context = nil
262
+ @params = {'sid' => sid || @properties['sid'], }
263
+ end
264
+
265
+ ##
266
+ # Generate an instance context for the instance, the context is capable of
267
+ # performing various actions. All instance actions are proxied to the context
268
+ # @return [RoleContext] RoleContext for this RoleInstance
269
+ def context
270
+ unless @instance_context
271
+ @instance_context = RoleContext.new(@version, @params['sid'], )
272
+ end
273
+ @instance_context
274
+ end
275
+
276
+ ##
277
+ # @return [String] The unique string that identifies the resource
278
+ def sid
279
+ @properties['sid']
280
+ end
281
+
282
+ ##
283
+ # @return [String] The SID of the Account that created the resource
284
+ def account_sid
285
+ @properties['account_sid']
286
+ end
287
+
288
+ ##
289
+ # @return [String] The SID of the Conversation Service that the resource is associated with
290
+ def chat_service_sid
291
+ @properties['chat_service_sid']
292
+ end
293
+
294
+ ##
295
+ # @return [String] The string that you assigned to describe the resource
296
+ def friendly_name
297
+ @properties['friendly_name']
298
+ end
299
+
300
+ ##
301
+ # @return [role.RoleType] The type of role
302
+ def type
303
+ @properties['type']
304
+ end
305
+
306
+ ##
307
+ # @return [String] An array of the permissions the role has been granted
308
+ def permissions
309
+ @properties['permissions']
310
+ end
311
+
312
+ ##
313
+ # @return [Time] The ISO 8601 date and time in GMT when the resource was created
314
+ def date_created
315
+ @properties['date_created']
316
+ end
317
+
318
+ ##
319
+ # @return [Time] The ISO 8601 date and time in GMT when the resource was last updated
320
+ def date_updated
321
+ @properties['date_updated']
322
+ end
323
+
324
+ ##
325
+ # @return [String] The absolute URL of the Role resource
326
+ def url
327
+ @properties['url']
328
+ end
329
+
330
+ ##
331
+ # Update the RoleInstance
332
+ # @param [String] permission A permission that you grant to the role. Only one
333
+ # permission can be granted per parameter. To assign more than one permission,
334
+ # repeat this parameter for each permission value. Note that the update action
335
+ # replaces all previously assigned permissions with those defined in the update
336
+ # action. To remove a permission, do not include it in the subsequent update
337
+ # action. The values for this parameter depend on the role's `type`.
338
+ # @return [RoleInstance] Updated RoleInstance
339
+ def update(permission: nil)
340
+ context.update(permission: permission, )
341
+ end
342
+
343
+ ##
344
+ # Delete the RoleInstance
345
+ # @return [Boolean] true if delete succeeds, false otherwise
346
+ def delete
347
+ context.delete
348
+ end
349
+
350
+ ##
351
+ # Fetch the RoleInstance
352
+ # @return [RoleInstance] Fetched RoleInstance
353
+ def fetch
354
+ context.fetch
355
+ end
356
+
357
+ ##
358
+ # Provide a user friendly representation
359
+ def to_s
360
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
361
+ "<Twilio.Conversations.V1.RoleInstance #{values}>"
362
+ end
363
+
364
+ ##
365
+ # Provide a detailed, user friendly representation
366
+ def inspect
367
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
368
+ "<Twilio.Conversations.V1.RoleInstance #{values}>"
369
+ end
370
+ end
371
+ end
372
+ end
373
+ end
374
+ end
@@ -0,0 +1,442 @@
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 Conversations < Domain
12
+ class V1 < Version
13
+ ##
14
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
15
+ class ServiceList < ListResource
16
+ ##
17
+ # Initialize the ServiceList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [ServiceList] ServiceList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/Services"
26
+ end
27
+
28
+ ##
29
+ # Create the ServiceInstance
30
+ # @param [String] friendly_name The human-readable name of this service, limited
31
+ # to 256 characters. Optional.
32
+ # @return [ServiceInstance] Created ServiceInstance
33
+ def create(friendly_name: nil)
34
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, })
35
+
36
+ payload = @version.create('POST', @uri, data: data)
37
+
38
+ ServiceInstance.new(@version, payload, )
39
+ end
40
+
41
+ ##
42
+ # Lists ServiceInstance records from the API as a list.
43
+ # Unlike stream(), this operation is eager and will load `limit` records into
44
+ # memory before returning.
45
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
46
+ # guarantees to never return more than limit. Default is no limit
47
+ # @param [Integer] page_size Number of records to fetch per request, when
48
+ # not set will use the default value of 50 records. If no page_size is defined
49
+ # but a limit is defined, stream() will attempt to read the limit with the most
50
+ # efficient page size, i.e. min(limit, 1000)
51
+ # @return [Array] Array of up to limit results
52
+ def list(limit: nil, page_size: nil)
53
+ self.stream(limit: limit, page_size: page_size).entries
54
+ end
55
+
56
+ ##
57
+ # Streams ServiceInstance records from the API as an Enumerable.
58
+ # This operation lazily loads records as efficiently as possible until the limit
59
+ # is reached.
60
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
61
+ # guarantees to never return more than limit. Default is no limit.
62
+ # @param [Integer] page_size Number of records to fetch per request, when
63
+ # not set will use the default value of 50 records. If no page_size is defined
64
+ # but a limit is defined, stream() will attempt to read the limit with the most
65
+ # efficient page size, i.e. min(limit, 1000)
66
+ # @return [Enumerable] Enumerable that will yield up to limit results
67
+ def stream(limit: nil, page_size: nil)
68
+ limits = @version.read_limits(limit, page_size)
69
+
70
+ page = self.page(page_size: limits[:page_size], )
71
+
72
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
73
+ end
74
+
75
+ ##
76
+ # When passed a block, yields ServiceInstance records from the API.
77
+ # This operation lazily loads records as efficiently as possible until the limit
78
+ # is reached.
79
+ def each
80
+ limits = @version.read_limits
81
+
82
+ page = self.page(page_size: limits[:page_size], )
83
+
84
+ @version.stream(page,
85
+ limit: limits[:limit],
86
+ page_limit: limits[:page_limit]).each {|x| yield x}
87
+ end
88
+
89
+ ##
90
+ # Retrieve a single page of ServiceInstance records from the API.
91
+ # Request is executed immediately.
92
+ # @param [String] page_token PageToken provided by the API
93
+ # @param [Integer] page_number Page Number, this value is simply for client state
94
+ # @param [Integer] page_size Number of records to return, defaults to 50
95
+ # @return [Page] Page of ServiceInstance
96
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
97
+ params = Twilio::Values.of({
98
+ 'PageToken' => page_token,
99
+ 'Page' => page_number,
100
+ 'PageSize' => page_size,
101
+ })
102
+
103
+ response = @version.page('GET', @uri, params: params)
104
+
105
+ ServicePage.new(@version, response, @solution)
106
+ end
107
+
108
+ ##
109
+ # Retrieve a single page of ServiceInstance records from the API.
110
+ # Request is executed immediately.
111
+ # @param [String] target_url API-generated URL for the requested results page
112
+ # @return [Page] Page of ServiceInstance
113
+ def get_page(target_url)
114
+ response = @version.domain.request(
115
+ 'GET',
116
+ target_url
117
+ )
118
+ ServicePage.new(@version, response, @solution)
119
+ end
120
+
121
+ ##
122
+ # Provide a user friendly representation
123
+ def to_s
124
+ '#<Twilio.Conversations.V1.ServiceList>'
125
+ end
126
+ end
127
+
128
+ ##
129
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
130
+ class ServicePage < Page
131
+ ##
132
+ # Initialize the ServicePage
133
+ # @param [Version] version Version that contains the resource
134
+ # @param [Response] response Response from the API
135
+ # @param [Hash] solution Path solution for the resource
136
+ # @return [ServicePage] ServicePage
137
+ def initialize(version, response, solution)
138
+ super(version, response)
139
+
140
+ # Path Solution
141
+ @solution = solution
142
+ end
143
+
144
+ ##
145
+ # Build an instance of ServiceInstance
146
+ # @param [Hash] payload Payload response from the API
147
+ # @return [ServiceInstance] ServiceInstance
148
+ def get_instance(payload)
149
+ ServiceInstance.new(@version, payload, )
150
+ end
151
+
152
+ ##
153
+ # Provide a user friendly representation
154
+ def to_s
155
+ '<Twilio.Conversations.V1.ServicePage>'
156
+ end
157
+ end
158
+
159
+ ##
160
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
161
+ class ServiceContext < InstanceContext
162
+ ##
163
+ # Initialize the ServiceContext
164
+ # @param [Version] version Version that contains the resource
165
+ # @param [String] sid A 34 character string that uniquely identifies this
166
+ # resource.
167
+ # @return [ServiceContext] ServiceContext
168
+ def initialize(version, sid)
169
+ super(version)
170
+
171
+ # Path Solution
172
+ @solution = {sid: sid, }
173
+ @uri = "/Services/#{@solution[:sid]}"
174
+
175
+ # Dependents
176
+ @conversations = nil
177
+ @bindings = nil
178
+ @users = nil
179
+ @roles = nil
180
+ @configuration = nil
181
+ end
182
+
183
+ ##
184
+ # Delete the ServiceInstance
185
+ # @return [Boolean] true if delete succeeds, false otherwise
186
+ def delete
187
+ @version.delete('DELETE', @uri)
188
+ end
189
+
190
+ ##
191
+ # Fetch the ServiceInstance
192
+ # @return [ServiceInstance] Fetched ServiceInstance
193
+ def fetch
194
+ payload = @version.fetch('GET', @uri)
195
+
196
+ ServiceInstance.new(@version, payload, sid: @solution[:sid], )
197
+ end
198
+
199
+ ##
200
+ # Access the conversations
201
+ # @return [ConversationList]
202
+ # @return [ConversationContext] if sid was passed.
203
+ def conversations(sid=:unset)
204
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
205
+
206
+ if sid != :unset
207
+ return ConversationContext.new(@version, @solution[:sid], sid, )
208
+ end
209
+
210
+ unless @conversations
211
+ @conversations = ConversationList.new(@version, chat_service_sid: @solution[:sid], )
212
+ end
213
+
214
+ @conversations
215
+ end
216
+
217
+ ##
218
+ # Access the bindings
219
+ # @return [BindingList]
220
+ # @return [BindingContext] if sid was passed.
221
+ def bindings(sid=:unset)
222
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
223
+
224
+ if sid != :unset
225
+ return BindingContext.new(@version, @solution[:sid], sid, )
226
+ end
227
+
228
+ unless @bindings
229
+ @bindings = BindingList.new(@version, chat_service_sid: @solution[:sid], )
230
+ end
231
+
232
+ @bindings
233
+ end
234
+
235
+ ##
236
+ # Access the users
237
+ # @return [UserList]
238
+ # @return [UserContext] if sid was passed.
239
+ def users(sid=:unset)
240
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
241
+
242
+ if sid != :unset
243
+ return UserContext.new(@version, @solution[:sid], sid, )
244
+ end
245
+
246
+ unless @users
247
+ @users = UserList.new(@version, chat_service_sid: @solution[:sid], )
248
+ end
249
+
250
+ @users
251
+ end
252
+
253
+ ##
254
+ # Access the roles
255
+ # @return [RoleList]
256
+ # @return [RoleContext] if sid was passed.
257
+ def roles(sid=:unset)
258
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
259
+
260
+ if sid != :unset
261
+ return RoleContext.new(@version, @solution[:sid], sid, )
262
+ end
263
+
264
+ unless @roles
265
+ @roles = RoleList.new(@version, chat_service_sid: @solution[:sid], )
266
+ end
267
+
268
+ @roles
269
+ end
270
+
271
+ ##
272
+ # Access the configuration
273
+ # @return [ConfigurationList]
274
+ # @return [ConfigurationContext]
275
+ def configuration
276
+ ConfigurationContext.new(@version, @solution[:sid], )
277
+ end
278
+
279
+ ##
280
+ # Provide a user friendly representation
281
+ def to_s
282
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
283
+ "#<Twilio.Conversations.V1.ServiceContext #{context}>"
284
+ end
285
+
286
+ ##
287
+ # Provide a detailed, user friendly representation
288
+ def inspect
289
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
290
+ "#<Twilio.Conversations.V1.ServiceContext #{context}>"
291
+ end
292
+ end
293
+
294
+ ##
295
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
296
+ class ServiceInstance < InstanceResource
297
+ ##
298
+ # Initialize the ServiceInstance
299
+ # @param [Version] version Version that contains the resource
300
+ # @param [Hash] payload payload that contains response from Twilio
301
+ # @param [String] sid A 34 character string that uniquely identifies this
302
+ # resource.
303
+ # @return [ServiceInstance] ServiceInstance
304
+ def initialize(version, payload, sid: nil)
305
+ super(version)
306
+
307
+ # Marshaled Properties
308
+ @properties = {
309
+ 'account_sid' => payload['account_sid'],
310
+ 'sid' => payload['sid'],
311
+ 'friendly_name' => payload['friendly_name'],
312
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
313
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
314
+ 'url' => payload['url'],
315
+ 'links' => payload['links'],
316
+ }
317
+
318
+ # Context
319
+ @instance_context = nil
320
+ @params = {'sid' => sid || @properties['sid'], }
321
+ end
322
+
323
+ ##
324
+ # Generate an instance context for the instance, the context is capable of
325
+ # performing various actions. All instance actions are proxied to the context
326
+ # @return [ServiceContext] ServiceContext for this ServiceInstance
327
+ def context
328
+ unless @instance_context
329
+ @instance_context = ServiceContext.new(@version, @params['sid'], )
330
+ end
331
+ @instance_context
332
+ end
333
+
334
+ ##
335
+ # @return [String] The unique ID of the Account responsible for this service.
336
+ def account_sid
337
+ @properties['account_sid']
338
+ end
339
+
340
+ ##
341
+ # @return [String] A 34 character string that uniquely identifies this resource.
342
+ def sid
343
+ @properties['sid']
344
+ end
345
+
346
+ ##
347
+ # @return [String] The human-readable name of this service.
348
+ def friendly_name
349
+ @properties['friendly_name']
350
+ end
351
+
352
+ ##
353
+ # @return [Time] The date that this resource was created.
354
+ def date_created
355
+ @properties['date_created']
356
+ end
357
+
358
+ ##
359
+ # @return [Time] The date that this resource was last updated.
360
+ def date_updated
361
+ @properties['date_updated']
362
+ end
363
+
364
+ ##
365
+ # @return [String] An absolute URL for this service.
366
+ def url
367
+ @properties['url']
368
+ end
369
+
370
+ ##
371
+ # @return [String] Absolute URLs to access the Conversations, Users, Roles and Bindings of this Service.
372
+ def links
373
+ @properties['links']
374
+ end
375
+
376
+ ##
377
+ # Delete the ServiceInstance
378
+ # @return [Boolean] true if delete succeeds, false otherwise
379
+ def delete
380
+ context.delete
381
+ end
382
+
383
+ ##
384
+ # Fetch the ServiceInstance
385
+ # @return [ServiceInstance] Fetched ServiceInstance
386
+ def fetch
387
+ context.fetch
388
+ end
389
+
390
+ ##
391
+ # Access the conversations
392
+ # @return [conversations] conversations
393
+ def conversations
394
+ context.conversations
395
+ end
396
+
397
+ ##
398
+ # Access the bindings
399
+ # @return [bindings] bindings
400
+ def bindings
401
+ context.bindings
402
+ end
403
+
404
+ ##
405
+ # Access the users
406
+ # @return [users] users
407
+ def users
408
+ context.users
409
+ end
410
+
411
+ ##
412
+ # Access the roles
413
+ # @return [roles] roles
414
+ def roles
415
+ context.roles
416
+ end
417
+
418
+ ##
419
+ # Access the configuration
420
+ # @return [configuration] configuration
421
+ def configuration
422
+ context.configuration
423
+ end
424
+
425
+ ##
426
+ # Provide a user friendly representation
427
+ def to_s
428
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
429
+ "<Twilio.Conversations.V1.ServiceInstance #{values}>"
430
+ end
431
+
432
+ ##
433
+ # Provide a detailed, user friendly representation
434
+ def inspect
435
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
436
+ "<Twilio.Conversations.V1.ServiceInstance #{values}>"
437
+ end
438
+ end
439
+ end
440
+ end
441
+ end
442
+ end