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