twilio-ruby 5.40.1 → 5.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +27 -0
- data/README.md +2 -2
- data/lib/twilio-ruby/framework/version.rb +2 -7
- data/lib/twilio-ruby/rest/conversations.rb +52 -0
- data/lib/twilio-ruby/rest/conversations/v1.rb +88 -1
- data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +258 -0
- data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +15 -4
- data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +19 -10
- data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
- data/lib/twilio-ruby/rest/conversations/v1/notification.rb +310 -0
- data/lib/twilio-ruby/rest/conversations/v1/role.rb +372 -0
- data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +385 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +259 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +546 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +388 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +513 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +454 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +393 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
- data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
- data/lib/twilio-ruby/rest/events.rb +8 -0
- data/lib/twilio-ruby/rest/events/v1.rb +15 -0
- data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
- data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +2 -2
- data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
- data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +27 -24
- data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +12 -11
- data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
- data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
- data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
- data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
- data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
- data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
- data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
- data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
- data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
- data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
- data/lib/twilio-ruby/rest/supersim/v1/sim.rb +17 -7
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/framework/version_spec.rb +42 -0
- data/spec/holodeck/holodeck.rb +3 -3
- data/spec/integration/conversations/v1/configuration_spec.rb +85 -0
- data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
- data/spec/integration/conversations/v1/conversation/participant_spec.rb +6 -6
- data/spec/integration/conversations/v1/conversation_spec.rb +5 -0
- data/spec/integration/conversations/v1/credential_spec.rb +219 -0
- data/spec/integration/conversations/v1/notification_spec.rb +107 -0
- data/spec/integration/conversations/v1/role_spec.rb +249 -0
- data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
- data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
- data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
- data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
- data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
- data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
- data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
- data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
- data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
- data/spec/integration/conversations/v1/service_spec.rb +174 -0
- data/spec/integration/conversations/v1/user_spec.rb +220 -0
- data/spec/integration/events/v1/event_type_spec.rb +133 -0
- data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
- data/spec/integration/supersim/v1/sim_spec.rb +23 -0
- metadata +50 -2
@@ -0,0 +1,310 @@
|
|
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 NotificationList < ListResource
|
16
|
+
##
|
17
|
+
# Initialize the NotificationList
|
18
|
+
# @param [Version] version Version that contains the resource
|
19
|
+
# @return [NotificationList] NotificationList
|
20
|
+
def initialize(version)
|
21
|
+
super(version)
|
22
|
+
|
23
|
+
# Path Solution
|
24
|
+
@solution = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Provide a user friendly representation
|
29
|
+
def to_s
|
30
|
+
'#<Twilio.Conversations.V1.NotificationList>'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
36
|
+
class NotificationPage < Page
|
37
|
+
##
|
38
|
+
# Initialize the NotificationPage
|
39
|
+
# @param [Version] version Version that contains the resource
|
40
|
+
# @param [Response] response Response from the API
|
41
|
+
# @param [Hash] solution Path solution for the resource
|
42
|
+
# @return [NotificationPage] NotificationPage
|
43
|
+
def initialize(version, response, solution)
|
44
|
+
super(version, response)
|
45
|
+
|
46
|
+
# Path Solution
|
47
|
+
@solution = solution
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
# Build an instance of NotificationInstance
|
52
|
+
# @param [Hash] payload Payload response from the API
|
53
|
+
# @return [NotificationInstance] NotificationInstance
|
54
|
+
def get_instance(payload)
|
55
|
+
NotificationInstance.new(@version, payload, )
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Provide a user friendly representation
|
60
|
+
def to_s
|
61
|
+
'<Twilio.Conversations.V1.NotificationPage>'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
67
|
+
class NotificationContext < InstanceContext
|
68
|
+
##
|
69
|
+
# Initialize the NotificationContext
|
70
|
+
# @param [Version] version Version that contains the resource
|
71
|
+
# @param [String] chat_service_sid The SID of the [Chat
|
72
|
+
# Service](https://www.twilio.com/docs/chat/rest/service-resource) the
|
73
|
+
# Configuration applies to.
|
74
|
+
# @return [NotificationContext] NotificationContext
|
75
|
+
def initialize(version, chat_service_sid)
|
76
|
+
super(version)
|
77
|
+
|
78
|
+
# Path Solution
|
79
|
+
@solution = {chat_service_sid: chat_service_sid, }
|
80
|
+
@uri = "/Services/#{@solution[:chat_service_sid]}/Configuration/Notifications"
|
81
|
+
end
|
82
|
+
|
83
|
+
##
|
84
|
+
# Update the NotificationInstance
|
85
|
+
# @param [Boolean] log_enabled Weather the notification logging is enabled.
|
86
|
+
# @param [Boolean] new_message_enabled Whether to send a notification when a new
|
87
|
+
# message is added to a conversation. The default is `false`.
|
88
|
+
# @param [String] new_message_template The template to use to create the
|
89
|
+
# notification text displayed when a new message is added to a conversation and
|
90
|
+
# `new_message.enabled` is `true`.
|
91
|
+
# @param [String] new_message_sound The name of the sound to play when a new
|
92
|
+
# message is added to a conversation and `new_message.enabled` is `true`.
|
93
|
+
# @param [Boolean] new_message_badge_count_enabled Whether the new message badge
|
94
|
+
# is enabled. The default is `false`.
|
95
|
+
# @param [Boolean] added_to_conversation_enabled Whether to send a notification
|
96
|
+
# when a participant is added to a conversation. The default is `false`.
|
97
|
+
# @param [String] added_to_conversation_template The template to use to create the
|
98
|
+
# notification text displayed when a participant is added to a conversation and
|
99
|
+
# `added_to_conversation.enabled` is `true`.
|
100
|
+
# @param [String] added_to_conversation_sound The name of the sound to play when a
|
101
|
+
# participant is added to a conversation and `added_to_conversation.enabled` is
|
102
|
+
# `true`.
|
103
|
+
# @param [Boolean] removed_from_conversation_enabled Whether to send a
|
104
|
+
# notification to a user when they are removed from a conversation. The default is
|
105
|
+
# `false`.
|
106
|
+
# @param [String] removed_from_conversation_template The template to use to create
|
107
|
+
# the notification text displayed to a user when they are removed from a
|
108
|
+
# conversation and `removed_from_conversation.enabled` is `true`.
|
109
|
+
# @param [String] removed_from_conversation_sound The name of the sound to play to
|
110
|
+
# a user when they are removed from a conversation and
|
111
|
+
# `removed_from_conversation.enabled` is `true`.
|
112
|
+
# @return [NotificationInstance] Updated NotificationInstance
|
113
|
+
def update(log_enabled: :unset, new_message_enabled: :unset, new_message_template: :unset, new_message_sound: :unset, new_message_badge_count_enabled: :unset, added_to_conversation_enabled: :unset, added_to_conversation_template: :unset, added_to_conversation_sound: :unset, removed_from_conversation_enabled: :unset, removed_from_conversation_template: :unset, removed_from_conversation_sound: :unset)
|
114
|
+
data = Twilio::Values.of({
|
115
|
+
'LogEnabled' => log_enabled,
|
116
|
+
'NewMessage.Enabled' => new_message_enabled,
|
117
|
+
'NewMessage.Template' => new_message_template,
|
118
|
+
'NewMessage.Sound' => new_message_sound,
|
119
|
+
'NewMessage.BadgeCountEnabled' => new_message_badge_count_enabled,
|
120
|
+
'AddedToConversation.Enabled' => added_to_conversation_enabled,
|
121
|
+
'AddedToConversation.Template' => added_to_conversation_template,
|
122
|
+
'AddedToConversation.Sound' => added_to_conversation_sound,
|
123
|
+
'RemovedFromConversation.Enabled' => removed_from_conversation_enabled,
|
124
|
+
'RemovedFromConversation.Template' => removed_from_conversation_template,
|
125
|
+
'RemovedFromConversation.Sound' => removed_from_conversation_sound,
|
126
|
+
})
|
127
|
+
|
128
|
+
payload = @version.update('POST', @uri, data: data)
|
129
|
+
|
130
|
+
NotificationInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
|
131
|
+
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# Fetch the NotificationInstance
|
135
|
+
# @return [NotificationInstance] Fetched NotificationInstance
|
136
|
+
def fetch
|
137
|
+
payload = @version.fetch('GET', @uri)
|
138
|
+
|
139
|
+
NotificationInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
|
140
|
+
end
|
141
|
+
|
142
|
+
##
|
143
|
+
# Provide a user friendly representation
|
144
|
+
def to_s
|
145
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
146
|
+
"#<Twilio.Conversations.V1.NotificationContext #{context}>"
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Provide a detailed, user friendly representation
|
151
|
+
def inspect
|
152
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
153
|
+
"#<Twilio.Conversations.V1.NotificationContext #{context}>"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
159
|
+
class NotificationInstance < InstanceResource
|
160
|
+
##
|
161
|
+
# Initialize the NotificationInstance
|
162
|
+
# @param [Version] version Version that contains the resource
|
163
|
+
# @param [Hash] payload payload that contains response from Twilio
|
164
|
+
# @param [String] chat_service_sid The SID of the [Chat
|
165
|
+
# Service](https://www.twilio.com/docs/chat/rest/service-resource) the
|
166
|
+
# Configuration applies to.
|
167
|
+
# @return [NotificationInstance] NotificationInstance
|
168
|
+
def initialize(version, payload, chat_service_sid: nil)
|
169
|
+
super(version)
|
170
|
+
|
171
|
+
# Marshaled Properties
|
172
|
+
@properties = {
|
173
|
+
'account_sid' => payload['account_sid'],
|
174
|
+
'chat_service_sid' => payload['chat_service_sid'],
|
175
|
+
'new_message' => payload['new_message'],
|
176
|
+
'added_to_conversation' => payload['added_to_conversation'],
|
177
|
+
'removed_from_conversation' => payload['removed_from_conversation'],
|
178
|
+
'log_enabled' => payload['log_enabled'],
|
179
|
+
'url' => payload['url'],
|
180
|
+
}
|
181
|
+
|
182
|
+
# Context
|
183
|
+
@instance_context = nil
|
184
|
+
@params = {'chat_service_sid' => chat_service_sid || @properties['chat_service_sid'], }
|
185
|
+
end
|
186
|
+
|
187
|
+
##
|
188
|
+
# Generate an instance context for the instance, the context is capable of
|
189
|
+
# performing various actions. All instance actions are proxied to the context
|
190
|
+
# @return [NotificationContext] NotificationContext for this NotificationInstance
|
191
|
+
def context
|
192
|
+
unless @instance_context
|
193
|
+
@instance_context = NotificationContext.new(@version, @params['chat_service_sid'], )
|
194
|
+
end
|
195
|
+
@instance_context
|
196
|
+
end
|
197
|
+
|
198
|
+
##
|
199
|
+
# @return [String] The unique id of the Account responsible for this configuration.
|
200
|
+
def account_sid
|
201
|
+
@properties['account_sid']
|
202
|
+
end
|
203
|
+
|
204
|
+
##
|
205
|
+
# @return [String] The SID of the Chat Service that the Configuration applies to.
|
206
|
+
def chat_service_sid
|
207
|
+
@properties['chat_service_sid']
|
208
|
+
end
|
209
|
+
|
210
|
+
##
|
211
|
+
# @return [Hash] The Push Notification configuration for New Messages.
|
212
|
+
def new_message
|
213
|
+
@properties['new_message']
|
214
|
+
end
|
215
|
+
|
216
|
+
##
|
217
|
+
# @return [Hash] The Push Notification configuration for being added to a Conversation.
|
218
|
+
def added_to_conversation
|
219
|
+
@properties['added_to_conversation']
|
220
|
+
end
|
221
|
+
|
222
|
+
##
|
223
|
+
# @return [Hash] The Push Notification configuration for being removed from a Conversation.
|
224
|
+
def removed_from_conversation
|
225
|
+
@properties['removed_from_conversation']
|
226
|
+
end
|
227
|
+
|
228
|
+
##
|
229
|
+
# @return [Boolean] Weather the notification logging is enabled.
|
230
|
+
def log_enabled
|
231
|
+
@properties['log_enabled']
|
232
|
+
end
|
233
|
+
|
234
|
+
##
|
235
|
+
# @return [String] An absolute URL for this configuration.
|
236
|
+
def url
|
237
|
+
@properties['url']
|
238
|
+
end
|
239
|
+
|
240
|
+
##
|
241
|
+
# Update the NotificationInstance
|
242
|
+
# @param [Boolean] log_enabled Weather the notification logging is enabled.
|
243
|
+
# @param [Boolean] new_message_enabled Whether to send a notification when a new
|
244
|
+
# message is added to a conversation. The default is `false`.
|
245
|
+
# @param [String] new_message_template The template to use to create the
|
246
|
+
# notification text displayed when a new message is added to a conversation and
|
247
|
+
# `new_message.enabled` is `true`.
|
248
|
+
# @param [String] new_message_sound The name of the sound to play when a new
|
249
|
+
# message is added to a conversation and `new_message.enabled` is `true`.
|
250
|
+
# @param [Boolean] new_message_badge_count_enabled Whether the new message badge
|
251
|
+
# is enabled. The default is `false`.
|
252
|
+
# @param [Boolean] added_to_conversation_enabled Whether to send a notification
|
253
|
+
# when a participant is added to a conversation. The default is `false`.
|
254
|
+
# @param [String] added_to_conversation_template The template to use to create the
|
255
|
+
# notification text displayed when a participant is added to a conversation and
|
256
|
+
# `added_to_conversation.enabled` is `true`.
|
257
|
+
# @param [String] added_to_conversation_sound The name of the sound to play when a
|
258
|
+
# participant is added to a conversation and `added_to_conversation.enabled` is
|
259
|
+
# `true`.
|
260
|
+
# @param [Boolean] removed_from_conversation_enabled Whether to send a
|
261
|
+
# notification to a user when they are removed from a conversation. The default is
|
262
|
+
# `false`.
|
263
|
+
# @param [String] removed_from_conversation_template The template to use to create
|
264
|
+
# the notification text displayed to a user when they are removed from a
|
265
|
+
# conversation and `removed_from_conversation.enabled` is `true`.
|
266
|
+
# @param [String] removed_from_conversation_sound The name of the sound to play to
|
267
|
+
# a user when they are removed from a conversation and
|
268
|
+
# `removed_from_conversation.enabled` is `true`.
|
269
|
+
# @return [NotificationInstance] Updated NotificationInstance
|
270
|
+
def update(log_enabled: :unset, new_message_enabled: :unset, new_message_template: :unset, new_message_sound: :unset, new_message_badge_count_enabled: :unset, added_to_conversation_enabled: :unset, added_to_conversation_template: :unset, added_to_conversation_sound: :unset, removed_from_conversation_enabled: :unset, removed_from_conversation_template: :unset, removed_from_conversation_sound: :unset)
|
271
|
+
context.update(
|
272
|
+
log_enabled: log_enabled,
|
273
|
+
new_message_enabled: new_message_enabled,
|
274
|
+
new_message_template: new_message_template,
|
275
|
+
new_message_sound: new_message_sound,
|
276
|
+
new_message_badge_count_enabled: new_message_badge_count_enabled,
|
277
|
+
added_to_conversation_enabled: added_to_conversation_enabled,
|
278
|
+
added_to_conversation_template: added_to_conversation_template,
|
279
|
+
added_to_conversation_sound: added_to_conversation_sound,
|
280
|
+
removed_from_conversation_enabled: removed_from_conversation_enabled,
|
281
|
+
removed_from_conversation_template: removed_from_conversation_template,
|
282
|
+
removed_from_conversation_sound: removed_from_conversation_sound,
|
283
|
+
)
|
284
|
+
end
|
285
|
+
|
286
|
+
##
|
287
|
+
# Fetch the NotificationInstance
|
288
|
+
# @return [NotificationInstance] Fetched NotificationInstance
|
289
|
+
def fetch
|
290
|
+
context.fetch
|
291
|
+
end
|
292
|
+
|
293
|
+
##
|
294
|
+
# Provide a user friendly representation
|
295
|
+
def to_s
|
296
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
297
|
+
"<Twilio.Conversations.V1.NotificationInstance #{values}>"
|
298
|
+
end
|
299
|
+
|
300
|
+
##
|
301
|
+
# Provide a detailed, user friendly representation
|
302
|
+
def inspect
|
303
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
304
|
+
"<Twilio.Conversations.V1.NotificationInstance #{values}>"
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
@@ -0,0 +1,372 @@
|
|
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) roles or `service` for [Service](https://www.twilio.com/docs/chat/rest/service-resource) roles.
|
34
|
+
# @param [String] permission A permission that you grant to the new role. Only one
|
35
|
+
# permission can be granted per parameter. To assign more than one permission,
|
36
|
+
# repeat this parameter for each permission value. The values for this parameter
|
37
|
+
# depend on the role's `type`.
|
38
|
+
# @return [RoleInstance] Created RoleInstance
|
39
|
+
def create(friendly_name: nil, type: nil, permission: nil)
|
40
|
+
data = Twilio::Values.of({
|
41
|
+
'FriendlyName' => friendly_name,
|
42
|
+
'Type' => type,
|
43
|
+
'Permission' => Twilio.serialize_list(permission) { |e| e },
|
44
|
+
})
|
45
|
+
|
46
|
+
payload = @version.create('POST', @uri, data: data)
|
47
|
+
|
48
|
+
RoleInstance.new(@version, payload, )
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Lists RoleInstance records from the API as a list.
|
53
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
54
|
+
# memory before returning.
|
55
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
56
|
+
# guarantees to never return more than limit. Default is no limit
|
57
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
58
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
59
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
60
|
+
# efficient page size, i.e. min(limit, 1000)
|
61
|
+
# @return [Array] Array of up to limit results
|
62
|
+
def list(limit: nil, page_size: nil)
|
63
|
+
self.stream(limit: limit, page_size: page_size).entries
|
64
|
+
end
|
65
|
+
|
66
|
+
##
|
67
|
+
# Streams RoleInstance records from the API as an Enumerable.
|
68
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
69
|
+
# is reached.
|
70
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
71
|
+
# guarantees to never return more than limit. Default is no limit.
|
72
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
73
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
74
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
75
|
+
# efficient page size, i.e. min(limit, 1000)
|
76
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
77
|
+
def stream(limit: nil, page_size: nil)
|
78
|
+
limits = @version.read_limits(limit, page_size)
|
79
|
+
|
80
|
+
page = self.page(page_size: limits[:page_size], )
|
81
|
+
|
82
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# When passed a block, yields RoleInstance records from the API.
|
87
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
88
|
+
# is reached.
|
89
|
+
def each
|
90
|
+
limits = @version.read_limits
|
91
|
+
|
92
|
+
page = self.page(page_size: limits[:page_size], )
|
93
|
+
|
94
|
+
@version.stream(page,
|
95
|
+
limit: limits[:limit],
|
96
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Retrieve a single page of RoleInstance records from the API.
|
101
|
+
# Request is executed immediately.
|
102
|
+
# @param [String] page_token PageToken provided by the API
|
103
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
104
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
105
|
+
# @return [Page] Page of RoleInstance
|
106
|
+
def page(page_token: :unset, page_number: :unset, page_size: :unset)
|
107
|
+
params = Twilio::Values.of({
|
108
|
+
'PageToken' => page_token,
|
109
|
+
'Page' => page_number,
|
110
|
+
'PageSize' => page_size,
|
111
|
+
})
|
112
|
+
|
113
|
+
response = @version.page('GET', @uri, params: params)
|
114
|
+
|
115
|
+
RolePage.new(@version, response, @solution)
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Retrieve a single page of RoleInstance records from the API.
|
120
|
+
# Request is executed immediately.
|
121
|
+
# @param [String] target_url API-generated URL for the requested results page
|
122
|
+
# @return [Page] Page of RoleInstance
|
123
|
+
def get_page(target_url)
|
124
|
+
response = @version.domain.request(
|
125
|
+
'GET',
|
126
|
+
target_url
|
127
|
+
)
|
128
|
+
RolePage.new(@version, response, @solution)
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# Provide a user friendly representation
|
133
|
+
def to_s
|
134
|
+
'#<Twilio.Conversations.V1.RoleList>'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
140
|
+
class RolePage < Page
|
141
|
+
##
|
142
|
+
# Initialize the RolePage
|
143
|
+
# @param [Version] version Version that contains the resource
|
144
|
+
# @param [Response] response Response from the API
|
145
|
+
# @param [Hash] solution Path solution for the resource
|
146
|
+
# @return [RolePage] RolePage
|
147
|
+
def initialize(version, response, solution)
|
148
|
+
super(version, response)
|
149
|
+
|
150
|
+
# Path Solution
|
151
|
+
@solution = solution
|
152
|
+
end
|
153
|
+
|
154
|
+
##
|
155
|
+
# Build an instance of RoleInstance
|
156
|
+
# @param [Hash] payload Payload response from the API
|
157
|
+
# @return [RoleInstance] RoleInstance
|
158
|
+
def get_instance(payload)
|
159
|
+
RoleInstance.new(@version, payload, )
|
160
|
+
end
|
161
|
+
|
162
|
+
##
|
163
|
+
# Provide a user friendly representation
|
164
|
+
def to_s
|
165
|
+
'<Twilio.Conversations.V1.RolePage>'
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
##
|
170
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
171
|
+
class RoleContext < InstanceContext
|
172
|
+
##
|
173
|
+
# Initialize the RoleContext
|
174
|
+
# @param [Version] version Version that contains the resource
|
175
|
+
# @param [String] sid The SID of the Role resource to fetch.
|
176
|
+
# @return [RoleContext] RoleContext
|
177
|
+
def initialize(version, sid)
|
178
|
+
super(version)
|
179
|
+
|
180
|
+
# Path Solution
|
181
|
+
@solution = {sid: sid, }
|
182
|
+
@uri = "/Roles/#{@solution[:sid]}"
|
183
|
+
end
|
184
|
+
|
185
|
+
##
|
186
|
+
# Update the RoleInstance
|
187
|
+
# @param [String] permission A permission that you grant to the role. Only one
|
188
|
+
# permission can be granted per parameter. To assign more than one permission,
|
189
|
+
# repeat this parameter for each permission value. Note that the update action
|
190
|
+
# replaces all previously assigned permissions with those defined in the update
|
191
|
+
# action. To remove a permission, do not include it in the subsequent update
|
192
|
+
# action. The values for this parameter depend on the role's `type`.
|
193
|
+
# @return [RoleInstance] Updated RoleInstance
|
194
|
+
def update(permission: nil)
|
195
|
+
data = Twilio::Values.of({'Permission' => Twilio.serialize_list(permission) { |e| e }, })
|
196
|
+
|
197
|
+
payload = @version.update('POST', @uri, data: data)
|
198
|
+
|
199
|
+
RoleInstance.new(@version, payload, sid: @solution[:sid], )
|
200
|
+
end
|
201
|
+
|
202
|
+
##
|
203
|
+
# Delete the RoleInstance
|
204
|
+
# @return [Boolean] true if delete succeeds, false otherwise
|
205
|
+
def delete
|
206
|
+
@version.delete('DELETE', @uri)
|
207
|
+
end
|
208
|
+
|
209
|
+
##
|
210
|
+
# Fetch the RoleInstance
|
211
|
+
# @return [RoleInstance] Fetched RoleInstance
|
212
|
+
def fetch
|
213
|
+
payload = @version.fetch('GET', @uri)
|
214
|
+
|
215
|
+
RoleInstance.new(@version, payload, sid: @solution[:sid], )
|
216
|
+
end
|
217
|
+
|
218
|
+
##
|
219
|
+
# Provide a user friendly representation
|
220
|
+
def to_s
|
221
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
222
|
+
"#<Twilio.Conversations.V1.RoleContext #{context}>"
|
223
|
+
end
|
224
|
+
|
225
|
+
##
|
226
|
+
# Provide a detailed, user friendly representation
|
227
|
+
def inspect
|
228
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
229
|
+
"#<Twilio.Conversations.V1.RoleContext #{context}>"
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
##
|
234
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
235
|
+
class RoleInstance < InstanceResource
|
236
|
+
##
|
237
|
+
# Initialize the RoleInstance
|
238
|
+
# @param [Version] version Version that contains the resource
|
239
|
+
# @param [Hash] payload payload that contains response from Twilio
|
240
|
+
# @param [String] sid The SID of the Role resource to fetch.
|
241
|
+
# @return [RoleInstance] RoleInstance
|
242
|
+
def initialize(version, payload, sid: nil)
|
243
|
+
super(version)
|
244
|
+
|
245
|
+
# Marshaled Properties
|
246
|
+
@properties = {
|
247
|
+
'sid' => payload['sid'],
|
248
|
+
'account_sid' => payload['account_sid'],
|
249
|
+
'chat_service_sid' => payload['chat_service_sid'],
|
250
|
+
'friendly_name' => payload['friendly_name'],
|
251
|
+
'type' => payload['type'],
|
252
|
+
'permissions' => payload['permissions'],
|
253
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
254
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
255
|
+
'url' => payload['url'],
|
256
|
+
}
|
257
|
+
|
258
|
+
# Context
|
259
|
+
@instance_context = nil
|
260
|
+
@params = {'sid' => sid || @properties['sid'], }
|
261
|
+
end
|
262
|
+
|
263
|
+
##
|
264
|
+
# Generate an instance context for the instance, the context is capable of
|
265
|
+
# performing various actions. All instance actions are proxied to the context
|
266
|
+
# @return [RoleContext] RoleContext for this RoleInstance
|
267
|
+
def context
|
268
|
+
unless @instance_context
|
269
|
+
@instance_context = RoleContext.new(@version, @params['sid'], )
|
270
|
+
end
|
271
|
+
@instance_context
|
272
|
+
end
|
273
|
+
|
274
|
+
##
|
275
|
+
# @return [String] The unique string that identifies the resource
|
276
|
+
def sid
|
277
|
+
@properties['sid']
|
278
|
+
end
|
279
|
+
|
280
|
+
##
|
281
|
+
# @return [String] The SID of the Account that created the resource
|
282
|
+
def account_sid
|
283
|
+
@properties['account_sid']
|
284
|
+
end
|
285
|
+
|
286
|
+
##
|
287
|
+
# @return [String] The SID of the Service that the resource is associated with
|
288
|
+
def chat_service_sid
|
289
|
+
@properties['chat_service_sid']
|
290
|
+
end
|
291
|
+
|
292
|
+
##
|
293
|
+
# @return [String] The string that you assigned to describe the resource
|
294
|
+
def friendly_name
|
295
|
+
@properties['friendly_name']
|
296
|
+
end
|
297
|
+
|
298
|
+
##
|
299
|
+
# @return [role.RoleType] The type of role
|
300
|
+
def type
|
301
|
+
@properties['type']
|
302
|
+
end
|
303
|
+
|
304
|
+
##
|
305
|
+
# @return [String] An array of the permissions the role has been granted
|
306
|
+
def permissions
|
307
|
+
@properties['permissions']
|
308
|
+
end
|
309
|
+
|
310
|
+
##
|
311
|
+
# @return [Time] The ISO 8601 date and time in GMT when the resource was created
|
312
|
+
def date_created
|
313
|
+
@properties['date_created']
|
314
|
+
end
|
315
|
+
|
316
|
+
##
|
317
|
+
# @return [Time] The ISO 8601 date and time in GMT when the resource was last updated
|
318
|
+
def date_updated
|
319
|
+
@properties['date_updated']
|
320
|
+
end
|
321
|
+
|
322
|
+
##
|
323
|
+
# @return [String] The absolute URL of the Role resource
|
324
|
+
def url
|
325
|
+
@properties['url']
|
326
|
+
end
|
327
|
+
|
328
|
+
##
|
329
|
+
# Update the RoleInstance
|
330
|
+
# @param [String] permission A permission that you grant to the role. Only one
|
331
|
+
# permission can be granted per parameter. To assign more than one permission,
|
332
|
+
# repeat this parameter for each permission value. Note that the update action
|
333
|
+
# replaces all previously assigned permissions with those defined in the update
|
334
|
+
# action. To remove a permission, do not include it in the subsequent update
|
335
|
+
# action. The values for this parameter depend on the role's `type`.
|
336
|
+
# @return [RoleInstance] Updated RoleInstance
|
337
|
+
def update(permission: nil)
|
338
|
+
context.update(permission: permission, )
|
339
|
+
end
|
340
|
+
|
341
|
+
##
|
342
|
+
# Delete the RoleInstance
|
343
|
+
# @return [Boolean] true if delete succeeds, false otherwise
|
344
|
+
def delete
|
345
|
+
context.delete
|
346
|
+
end
|
347
|
+
|
348
|
+
##
|
349
|
+
# Fetch the RoleInstance
|
350
|
+
# @return [RoleInstance] Fetched RoleInstance
|
351
|
+
def fetch
|
352
|
+
context.fetch
|
353
|
+
end
|
354
|
+
|
355
|
+
##
|
356
|
+
# Provide a user friendly representation
|
357
|
+
def to_s
|
358
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
359
|
+
"<Twilio.Conversations.V1.RoleInstance #{values}>"
|
360
|
+
end
|
361
|
+
|
362
|
+
##
|
363
|
+
# Provide a detailed, user friendly representation
|
364
|
+
def inspect
|
365
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
366
|
+
"<Twilio.Conversations.V1.RoleInstance #{values}>"
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|