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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +27 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/framework/version.rb +2 -7
  5. data/lib/twilio-ruby/rest/conversations.rb +52 -0
  6. data/lib/twilio-ruby/rest/conversations/v1.rb +88 -1
  7. data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +258 -0
  8. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +15 -4
  9. data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +19 -10
  10. data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
  11. data/lib/twilio-ruby/rest/conversations/v1/notification.rb +310 -0
  12. data/lib/twilio-ruby/rest/conversations/v1/role.rb +372 -0
  13. data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
  14. data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +385 -0
  15. data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +259 -0
  16. data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
  17. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +546 -0
  18. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +388 -0
  19. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +513 -0
  20. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +454 -0
  21. data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +393 -0
  22. data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
  23. data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
  24. data/lib/twilio-ruby/rest/events.rb +8 -0
  25. data/lib/twilio-ruby/rest/events/v1.rb +15 -0
  26. data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
  27. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +2 -2
  28. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
  29. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +27 -24
  30. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +12 -11
  31. data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
  32. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
  33. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
  34. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
  35. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
  36. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
  37. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
  38. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
  39. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
  40. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
  41. data/lib/twilio-ruby/rest/supersim/v1/sim.rb +17 -7
  42. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
  43. data/lib/twilio-ruby/version.rb +1 -1
  44. data/spec/framework/version_spec.rb +42 -0
  45. data/spec/holodeck/holodeck.rb +3 -3
  46. data/spec/integration/conversations/v1/configuration_spec.rb +85 -0
  47. data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
  48. data/spec/integration/conversations/v1/conversation/participant_spec.rb +6 -6
  49. data/spec/integration/conversations/v1/conversation_spec.rb +5 -0
  50. data/spec/integration/conversations/v1/credential_spec.rb +219 -0
  51. data/spec/integration/conversations/v1/notification_spec.rb +107 -0
  52. data/spec/integration/conversations/v1/role_spec.rb +249 -0
  53. data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
  54. data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
  55. data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
  56. data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
  57. data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
  58. data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
  59. data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
  60. data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
  61. data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
  62. data/spec/integration/conversations/v1/service_spec.rb +174 -0
  63. data/spec/integration/conversations/v1/user_spec.rb +220 -0
  64. data/spec/integration/events/v1/event_type_spec.rb +133 -0
  65. data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
  66. data/spec/integration/supersim/v1/sim_spec.rb +23 -0
  67. metadata +50 -2
@@ -0,0 +1,259 @@
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 ConfigurationList < ListResource
17
+ ##
18
+ # Initialize the ConfigurationList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] chat_service_sid The unique string that we created to identify
21
+ # the Service configuration resource.
22
+ # @return [ConfigurationList] ConfigurationList
23
+ def initialize(version, chat_service_sid: nil)
24
+ super(version)
25
+
26
+ # Path Solution
27
+ @solution = {chat_service_sid: chat_service_sid}
28
+ end
29
+
30
+ ##
31
+ # Provide a user friendly representation
32
+ def to_s
33
+ '#<Twilio.Conversations.V1.ConfigurationList>'
34
+ end
35
+ end
36
+
37
+ ##
38
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
39
+ class ConfigurationPage < Page
40
+ ##
41
+ # Initialize the ConfigurationPage
42
+ # @param [Version] version Version that contains the resource
43
+ # @param [Response] response Response from the API
44
+ # @param [Hash] solution Path solution for the resource
45
+ # @return [ConfigurationPage] ConfigurationPage
46
+ def initialize(version, response, solution)
47
+ super(version, response)
48
+
49
+ # Path Solution
50
+ @solution = solution
51
+ end
52
+
53
+ ##
54
+ # Build an instance of ConfigurationInstance
55
+ # @param [Hash] payload Payload response from the API
56
+ # @return [ConfigurationInstance] ConfigurationInstance
57
+ def get_instance(payload)
58
+ ConfigurationInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
59
+ end
60
+
61
+ ##
62
+ # Provide a user friendly representation
63
+ def to_s
64
+ '<Twilio.Conversations.V1.ConfigurationPage>'
65
+ end
66
+ end
67
+
68
+ ##
69
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
70
+ class ConfigurationContext < InstanceContext
71
+ ##
72
+ # Initialize the ConfigurationContext
73
+ # @param [Version] version Version that contains the resource
74
+ # @param [String] chat_service_sid The SID of the Service configuration resource
75
+ # to fetch.
76
+ # @return [ConfigurationContext] ConfigurationContext
77
+ def initialize(version, chat_service_sid)
78
+ super(version)
79
+
80
+ # Path Solution
81
+ @solution = {chat_service_sid: chat_service_sid, }
82
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Configuration"
83
+ end
84
+
85
+ ##
86
+ # Fetch the ConfigurationInstance
87
+ # @return [ConfigurationInstance] Fetched ConfigurationInstance
88
+ def fetch
89
+ payload = @version.fetch('GET', @uri)
90
+
91
+ ConfigurationInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
92
+ end
93
+
94
+ ##
95
+ # Update the ConfigurationInstance
96
+ # @param [String] default_conversation_creator_role_sid The role assigned to a
97
+ # conversation creator when they join a new conversation. See the [Role
98
+ # resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info
99
+ # about roles.
100
+ # @param [String] default_conversation_role_sid The role assigned to users when
101
+ # they are added to a conversation. See the [Role
102
+ # resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info
103
+ # about roles.
104
+ # @param [String] default_chat_service_role_sid The service role assigned to users
105
+ # when they are added to the service. See the [Role
106
+ # resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info
107
+ # about roles.
108
+ # @return [ConfigurationInstance] Updated ConfigurationInstance
109
+ def update(default_conversation_creator_role_sid: :unset, default_conversation_role_sid: :unset, default_chat_service_role_sid: :unset)
110
+ data = Twilio::Values.of({
111
+ 'DefaultConversationCreatorRoleSid' => default_conversation_creator_role_sid,
112
+ 'DefaultConversationRoleSid' => default_conversation_role_sid,
113
+ 'DefaultChatServiceRoleSid' => default_chat_service_role_sid,
114
+ })
115
+
116
+ payload = @version.update('POST', @uri, data: data)
117
+
118
+ ConfigurationInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
119
+ end
120
+
121
+ ##
122
+ # Provide a user friendly representation
123
+ def to_s
124
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
125
+ "#<Twilio.Conversations.V1.ConfigurationContext #{context}>"
126
+ end
127
+
128
+ ##
129
+ # Provide a detailed, user friendly representation
130
+ def inspect
131
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
132
+ "#<Twilio.Conversations.V1.ConfigurationContext #{context}>"
133
+ end
134
+ end
135
+
136
+ ##
137
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
138
+ class ConfigurationInstance < InstanceResource
139
+ ##
140
+ # Initialize the ConfigurationInstance
141
+ # @param [Version] version Version that contains the resource
142
+ # @param [Hash] payload payload that contains response from Twilio
143
+ # @param [String] chat_service_sid The unique string that we created to identify
144
+ # the Service configuration resource.
145
+ # @return [ConfigurationInstance] ConfigurationInstance
146
+ def initialize(version, payload, chat_service_sid: nil)
147
+ super(version)
148
+
149
+ # Marshaled Properties
150
+ @properties = {
151
+ 'chat_service_sid' => payload['chat_service_sid'],
152
+ 'default_conversation_creator_role_sid' => payload['default_conversation_creator_role_sid'],
153
+ 'default_conversation_role_sid' => payload['default_conversation_role_sid'],
154
+ 'default_chat_service_role_sid' => payload['default_chat_service_role_sid'],
155
+ 'url' => payload['url'],
156
+ 'links' => payload['links'],
157
+ }
158
+
159
+ # Context
160
+ @instance_context = nil
161
+ @params = {'chat_service_sid' => chat_service_sid, }
162
+ end
163
+
164
+ ##
165
+ # Generate an instance context for the instance, the context is capable of
166
+ # performing various actions. All instance actions are proxied to the context
167
+ # @return [ConfigurationContext] ConfigurationContext for this ConfigurationInstance
168
+ def context
169
+ unless @instance_context
170
+ @instance_context = ConfigurationContext.new(@version, @params['chat_service_sid'], )
171
+ end
172
+ @instance_context
173
+ end
174
+
175
+ ##
176
+ # @return [String] The unique string that identifies the resource
177
+ def chat_service_sid
178
+ @properties['chat_service_sid']
179
+ end
180
+
181
+ ##
182
+ # @return [String] The role assigned to a conversation creator user when they join a new conversation
183
+ def default_conversation_creator_role_sid
184
+ @properties['default_conversation_creator_role_sid']
185
+ end
186
+
187
+ ##
188
+ # @return [String] The role assigned to users when they are added to a conversation
189
+ def default_conversation_role_sid
190
+ @properties['default_conversation_role_sid']
191
+ end
192
+
193
+ ##
194
+ # @return [String] The service role assigned to users when they are added to the service
195
+ def default_chat_service_role_sid
196
+ @properties['default_chat_service_role_sid']
197
+ end
198
+
199
+ ##
200
+ # @return [String] The absolute URL of the Service configuration resource
201
+ def url
202
+ @properties['url']
203
+ end
204
+
205
+ ##
206
+ # @return [String] Absolute URL to access the Push Notifications configuration of this Service.
207
+ def links
208
+ @properties['links']
209
+ end
210
+
211
+ ##
212
+ # Fetch the ConfigurationInstance
213
+ # @return [ConfigurationInstance] Fetched ConfigurationInstance
214
+ def fetch
215
+ context.fetch
216
+ end
217
+
218
+ ##
219
+ # Update the ConfigurationInstance
220
+ # @param [String] default_conversation_creator_role_sid The role assigned to a
221
+ # conversation creator when they join a new conversation. See the [Role
222
+ # resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info
223
+ # about roles.
224
+ # @param [String] default_conversation_role_sid The role assigned to users when
225
+ # they are added to a conversation. See the [Role
226
+ # resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info
227
+ # about roles.
228
+ # @param [String] default_chat_service_role_sid The service role assigned to users
229
+ # when they are added to the service. See the [Role
230
+ # resource](https://www.twilio.com/docs/chat/rest/role-resource) for more info
231
+ # about roles.
232
+ # @return [ConfigurationInstance] Updated ConfigurationInstance
233
+ def update(default_conversation_creator_role_sid: :unset, default_conversation_role_sid: :unset, default_chat_service_role_sid: :unset)
234
+ context.update(
235
+ default_conversation_creator_role_sid: default_conversation_creator_role_sid,
236
+ default_conversation_role_sid: default_conversation_role_sid,
237
+ default_chat_service_role_sid: default_chat_service_role_sid,
238
+ )
239
+ end
240
+
241
+ ##
242
+ # Provide a user friendly representation
243
+ def to_s
244
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
245
+ "<Twilio.Conversations.V1.ConfigurationInstance #{values}>"
246
+ end
247
+
248
+ ##
249
+ # Provide a detailed, user friendly representation
250
+ def inspect
251
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
252
+ "<Twilio.Conversations.V1.ConfigurationInstance #{values}>"
253
+ end
254
+ end
255
+ end
256
+ end
257
+ end
258
+ end
259
+ end
@@ -0,0 +1,586 @@
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 ConversationList < ListResource
17
+ ##
18
+ # Initialize the ConversationList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] chat_service_sid The unique id of the [Chat
21
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) this
22
+ # conversation belongs to.
23
+ # @return [ConversationList] ConversationList
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]}/Conversations"
30
+ end
31
+
32
+ ##
33
+ # Create the ConversationInstance
34
+ # @param [String] friendly_name The human-readable name of this conversation,
35
+ # limited to 256 characters. Optional.
36
+ # @param [String] unique_name An application-defined string that uniquely
37
+ # identifies the resource. It can be used to address the resource in place of the
38
+ # resource's `sid` in the URL.
39
+ # @param [String] attributes An optional string metadata field you can use to
40
+ # store any data you wish. The string value must contain structurally valid JSON
41
+ # if specified. **Note** that if the attributes are not set "{}" will be
42
+ # returned.
43
+ # @param [String] messaging_service_sid The unique id of the [SMS
44
+ # Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs
45
+ # to.
46
+ # @param [Time] date_created The date that this resource was created.
47
+ # @param [Time] date_updated The date that this resource was last updated.
48
+ # @param [conversation.State] state Current state of this conversation. Can be
49
+ # either `active`, `inactive` or `closed` and defaults to `active`
50
+ # @param [String] timers_inactive ISO8601 duration when conversation will be
51
+ # switched to `inactive` state. Minimum value for this timer is 1 minute.
52
+ # @param [String] timers_closed ISO8601 duration when conversation will be
53
+ # switched to `closed` state. Minimum value for this timer is 10 minutes.
54
+ # @param [conversation.WebhookEnabledType] x_twilio_webhook_enabled The
55
+ # X-Twilio-Webhook-Enabled HTTP request header
56
+ # @return [ConversationInstance] Created ConversationInstance
57
+ def create(friendly_name: :unset, unique_name: :unset, attributes: :unset, messaging_service_sid: :unset, date_created: :unset, date_updated: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, x_twilio_webhook_enabled: :unset)
58
+ data = Twilio::Values.of({
59
+ 'FriendlyName' => friendly_name,
60
+ 'UniqueName' => unique_name,
61
+ 'Attributes' => attributes,
62
+ 'MessagingServiceSid' => messaging_service_sid,
63
+ 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
64
+ 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
65
+ 'State' => state,
66
+ 'Timers.Inactive' => timers_inactive,
67
+ 'Timers.Closed' => timers_closed,
68
+ })
69
+ headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
70
+
71
+ payload = @version.create('POST', @uri, data: data, headers: headers)
72
+
73
+ ConversationInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
74
+ end
75
+
76
+ ##
77
+ # Lists ConversationInstance records from the API as a list.
78
+ # Unlike stream(), this operation is eager and will load `limit` records into
79
+ # memory before returning.
80
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
81
+ # guarantees to never return more than limit. Default is no limit
82
+ # @param [Integer] page_size Number of records to fetch per request, when
83
+ # not set will use the default value of 50 records. If no page_size is defined
84
+ # but a limit is defined, stream() will attempt to read the limit with the most
85
+ # efficient page size, i.e. min(limit, 1000)
86
+ # @return [Array] Array of up to limit results
87
+ def list(limit: nil, page_size: nil)
88
+ self.stream(limit: limit, page_size: page_size).entries
89
+ end
90
+
91
+ ##
92
+ # Streams ConversationInstance records from the API as an Enumerable.
93
+ # This operation lazily loads records as efficiently as possible until the limit
94
+ # is reached.
95
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
96
+ # guarantees to never return more than limit. Default is no limit.
97
+ # @param [Integer] page_size Number of records to fetch per request, when
98
+ # not set will use the default value of 50 records. If no page_size is defined
99
+ # but a limit is defined, stream() will attempt to read the limit with the most
100
+ # efficient page size, i.e. min(limit, 1000)
101
+ # @return [Enumerable] Enumerable that will yield up to limit results
102
+ def stream(limit: nil, page_size: nil)
103
+ limits = @version.read_limits(limit, page_size)
104
+
105
+ page = self.page(page_size: limits[:page_size], )
106
+
107
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
108
+ end
109
+
110
+ ##
111
+ # When passed a block, yields ConversationInstance records from the API.
112
+ # This operation lazily loads records as efficiently as possible until the limit
113
+ # is reached.
114
+ def each
115
+ limits = @version.read_limits
116
+
117
+ page = self.page(page_size: limits[:page_size], )
118
+
119
+ @version.stream(page,
120
+ limit: limits[:limit],
121
+ page_limit: limits[:page_limit]).each {|x| yield x}
122
+ end
123
+
124
+ ##
125
+ # Retrieve a single page of ConversationInstance records from the API.
126
+ # Request is executed immediately.
127
+ # @param [String] page_token PageToken provided by the API
128
+ # @param [Integer] page_number Page Number, this value is simply for client state
129
+ # @param [Integer] page_size Number of records to return, defaults to 50
130
+ # @return [Page] Page of ConversationInstance
131
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
132
+ params = Twilio::Values.of({
133
+ 'PageToken' => page_token,
134
+ 'Page' => page_number,
135
+ 'PageSize' => page_size,
136
+ })
137
+
138
+ response = @version.page('GET', @uri, params: params)
139
+
140
+ ConversationPage.new(@version, response, @solution)
141
+ end
142
+
143
+ ##
144
+ # Retrieve a single page of ConversationInstance records from the API.
145
+ # Request is executed immediately.
146
+ # @param [String] target_url API-generated URL for the requested results page
147
+ # @return [Page] Page of ConversationInstance
148
+ def get_page(target_url)
149
+ response = @version.domain.request(
150
+ 'GET',
151
+ target_url
152
+ )
153
+ ConversationPage.new(@version, response, @solution)
154
+ end
155
+
156
+ ##
157
+ # Provide a user friendly representation
158
+ def to_s
159
+ '#<Twilio.Conversations.V1.ConversationList>'
160
+ end
161
+ end
162
+
163
+ ##
164
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
165
+ class ConversationPage < Page
166
+ ##
167
+ # Initialize the ConversationPage
168
+ # @param [Version] version Version that contains the resource
169
+ # @param [Response] response Response from the API
170
+ # @param [Hash] solution Path solution for the resource
171
+ # @return [ConversationPage] ConversationPage
172
+ def initialize(version, response, solution)
173
+ super(version, response)
174
+
175
+ # Path Solution
176
+ @solution = solution
177
+ end
178
+
179
+ ##
180
+ # Build an instance of ConversationInstance
181
+ # @param [Hash] payload Payload response from the API
182
+ # @return [ConversationInstance] ConversationInstance
183
+ def get_instance(payload)
184
+ ConversationInstance.new(@version, payload, chat_service_sid: @solution[:chat_service_sid], )
185
+ end
186
+
187
+ ##
188
+ # Provide a user friendly representation
189
+ def to_s
190
+ '<Twilio.Conversations.V1.ConversationPage>'
191
+ end
192
+ end
193
+
194
+ ##
195
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
196
+ class ConversationContext < InstanceContext
197
+ ##
198
+ # Initialize the ConversationContext
199
+ # @param [Version] version Version that contains the resource
200
+ # @param [String] chat_service_sid The chat_service_sid
201
+ # @param [String] sid A 34 character string that uniquely identifies this
202
+ # resource. Can also be the `unique_name` of the Conversation.
203
+ # @return [ConversationContext] ConversationContext
204
+ def initialize(version, chat_service_sid, sid)
205
+ super(version)
206
+
207
+ # Path Solution
208
+ @solution = {chat_service_sid: chat_service_sid, sid: sid, }
209
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:sid]}"
210
+
211
+ # Dependents
212
+ @participants = nil
213
+ @messages = nil
214
+ @webhooks = nil
215
+ end
216
+
217
+ ##
218
+ # Update the ConversationInstance
219
+ # @param [String] friendly_name The human-readable name of this conversation,
220
+ # limited to 256 characters. Optional.
221
+ # @param [Time] date_created The date that this resource was created.
222
+ # @param [Time] date_updated The date that this resource was last updated.
223
+ # @param [String] attributes An optional string metadata field you can use to
224
+ # store any data you wish. The string value must contain structurally valid JSON
225
+ # if specified. **Note** that if the attributes are not set "{}" will be
226
+ # returned.
227
+ # @param [String] messaging_service_sid The unique id of the [SMS
228
+ # Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs
229
+ # to.
230
+ # @param [conversation.State] state Current state of this conversation. Can be
231
+ # either `active`, `inactive` or `closed` and defaults to `active`
232
+ # @param [String] timers_inactive ISO8601 duration when conversation will be
233
+ # switched to `inactive` state. Minimum value for this timer is 1 minute.
234
+ # @param [String] timers_closed ISO8601 duration when conversation will be
235
+ # switched to `closed` state. Minimum value for this timer is 10 minutes.
236
+ # @param [conversation.WebhookEnabledType] x_twilio_webhook_enabled The
237
+ # X-Twilio-Webhook-Enabled HTTP request header
238
+ # @return [ConversationInstance] Updated ConversationInstance
239
+ def update(friendly_name: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_service_sid: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, x_twilio_webhook_enabled: :unset)
240
+ data = Twilio::Values.of({
241
+ 'FriendlyName' => friendly_name,
242
+ 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
243
+ 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
244
+ 'Attributes' => attributes,
245
+ 'MessagingServiceSid' => messaging_service_sid,
246
+ 'State' => state,
247
+ 'Timers.Inactive' => timers_inactive,
248
+ 'Timers.Closed' => timers_closed,
249
+ })
250
+ headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
251
+
252
+ payload = @version.update('POST', @uri, data: data, headers: headers)
253
+
254
+ ConversationInstance.new(
255
+ @version,
256
+ payload,
257
+ chat_service_sid: @solution[:chat_service_sid],
258
+ sid: @solution[:sid],
259
+ )
260
+ end
261
+
262
+ ##
263
+ # Delete the ConversationInstance
264
+ # @param [conversation.WebhookEnabledType] x_twilio_webhook_enabled The
265
+ # X-Twilio-Webhook-Enabled HTTP request header
266
+ # @return [Boolean] true if delete succeeds, false otherwise
267
+ def delete(x_twilio_webhook_enabled: :unset)
268
+ headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
269
+
270
+ @version.delete('DELETE', @uri, headers: headers)
271
+ end
272
+
273
+ ##
274
+ # Fetch the ConversationInstance
275
+ # @return [ConversationInstance] Fetched ConversationInstance
276
+ def fetch
277
+ payload = @version.fetch('GET', @uri)
278
+
279
+ ConversationInstance.new(
280
+ @version,
281
+ payload,
282
+ chat_service_sid: @solution[:chat_service_sid],
283
+ sid: @solution[:sid],
284
+ )
285
+ end
286
+
287
+ ##
288
+ # Access the participants
289
+ # @return [ParticipantList]
290
+ # @return [ParticipantContext] if sid was passed.
291
+ def participants(sid=:unset)
292
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
293
+
294
+ if sid != :unset
295
+ return ParticipantContext.new(@version, @solution[:chat_service_sid], @solution[:sid], sid, )
296
+ end
297
+
298
+ unless @participants
299
+ @participants = ParticipantList.new(
300
+ @version,
301
+ chat_service_sid: @solution[:chat_service_sid],
302
+ conversation_sid: @solution[:sid],
303
+ )
304
+ end
305
+
306
+ @participants
307
+ end
308
+
309
+ ##
310
+ # Access the messages
311
+ # @return [MessageList]
312
+ # @return [MessageContext] if sid was passed.
313
+ def messages(sid=:unset)
314
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
315
+
316
+ if sid != :unset
317
+ return MessageContext.new(@version, @solution[:chat_service_sid], @solution[:sid], sid, )
318
+ end
319
+
320
+ unless @messages
321
+ @messages = MessageList.new(
322
+ @version,
323
+ chat_service_sid: @solution[:chat_service_sid],
324
+ conversation_sid: @solution[:sid],
325
+ )
326
+ end
327
+
328
+ @messages
329
+ end
330
+
331
+ ##
332
+ # Access the webhooks
333
+ # @return [WebhookList]
334
+ # @return [WebhookContext] if sid was passed.
335
+ def webhooks(sid=:unset)
336
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
337
+
338
+ if sid != :unset
339
+ return WebhookContext.new(@version, @solution[:chat_service_sid], @solution[:sid], sid, )
340
+ end
341
+
342
+ unless @webhooks
343
+ @webhooks = WebhookList.new(
344
+ @version,
345
+ chat_service_sid: @solution[:chat_service_sid],
346
+ conversation_sid: @solution[:sid],
347
+ )
348
+ end
349
+
350
+ @webhooks
351
+ end
352
+
353
+ ##
354
+ # Provide a user friendly representation
355
+ def to_s
356
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
357
+ "#<Twilio.Conversations.V1.ConversationContext #{context}>"
358
+ end
359
+
360
+ ##
361
+ # Provide a detailed, user friendly representation
362
+ def inspect
363
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
364
+ "#<Twilio.Conversations.V1.ConversationContext #{context}>"
365
+ end
366
+ end
367
+
368
+ ##
369
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
370
+ class ConversationInstance < InstanceResource
371
+ ##
372
+ # Initialize the ConversationInstance
373
+ # @param [Version] version Version that contains the resource
374
+ # @param [Hash] payload payload that contains response from Twilio
375
+ # @param [String] chat_service_sid The unique id of the [Chat
376
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) this
377
+ # conversation belongs to.
378
+ # @param [String] sid A 34 character string that uniquely identifies this
379
+ # resource. Can also be the `unique_name` of the Conversation.
380
+ # @return [ConversationInstance] ConversationInstance
381
+ def initialize(version, payload, chat_service_sid: nil, sid: nil)
382
+ super(version)
383
+
384
+ # Marshaled Properties
385
+ @properties = {
386
+ 'account_sid' => payload['account_sid'],
387
+ 'chat_service_sid' => payload['chat_service_sid'],
388
+ 'messaging_service_sid' => payload['messaging_service_sid'],
389
+ 'sid' => payload['sid'],
390
+ 'friendly_name' => payload['friendly_name'],
391
+ 'unique_name' => payload['unique_name'],
392
+ 'attributes' => payload['attributes'],
393
+ 'state' => payload['state'],
394
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
395
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
396
+ 'timers' => payload['timers'],
397
+ 'url' => payload['url'],
398
+ 'links' => payload['links'],
399
+ }
400
+
401
+ # Context
402
+ @instance_context = nil
403
+ @params = {'chat_service_sid' => chat_service_sid, 'sid' => sid || @properties['sid'], }
404
+ end
405
+
406
+ ##
407
+ # Generate an instance context for the instance, the context is capable of
408
+ # performing various actions. All instance actions are proxied to the context
409
+ # @return [ConversationContext] ConversationContext for this ConversationInstance
410
+ def context
411
+ unless @instance_context
412
+ @instance_context = ConversationContext.new(@version, @params['chat_service_sid'], @params['sid'], )
413
+ end
414
+ @instance_context
415
+ end
416
+
417
+ ##
418
+ # @return [String] The unique id of the Account responsible for this conversation.
419
+ def account_sid
420
+ @properties['account_sid']
421
+ end
422
+
423
+ ##
424
+ # @return [String] The unique id of the Chat Service this conversation belongs to.
425
+ def chat_service_sid
426
+ @properties['chat_service_sid']
427
+ end
428
+
429
+ ##
430
+ # @return [String] The unique id of the SMS Service this conversation belongs to.
431
+ def messaging_service_sid
432
+ @properties['messaging_service_sid']
433
+ end
434
+
435
+ ##
436
+ # @return [String] A 34 character string that uniquely identifies this resource.
437
+ def sid
438
+ @properties['sid']
439
+ end
440
+
441
+ ##
442
+ # @return [String] The human-readable name of this conversation.
443
+ def friendly_name
444
+ @properties['friendly_name']
445
+ end
446
+
447
+ ##
448
+ # @return [String] An application-defined string that uniquely identifies the resource
449
+ def unique_name
450
+ @properties['unique_name']
451
+ end
452
+
453
+ ##
454
+ # @return [String] An optional string metadata field you can use to store any data you wish.
455
+ def attributes
456
+ @properties['attributes']
457
+ end
458
+
459
+ ##
460
+ # @return [conversation.State] Current state of this conversation.
461
+ def state
462
+ @properties['state']
463
+ end
464
+
465
+ ##
466
+ # @return [Time] The date that this resource was created.
467
+ def date_created
468
+ @properties['date_created']
469
+ end
470
+
471
+ ##
472
+ # @return [Time] The date that this resource was last updated.
473
+ def date_updated
474
+ @properties['date_updated']
475
+ end
476
+
477
+ ##
478
+ # @return [Hash] Timer date values for this conversation.
479
+ def timers
480
+ @properties['timers']
481
+ end
482
+
483
+ ##
484
+ # @return [String] An absolute URL for this conversation.
485
+ def url
486
+ @properties['url']
487
+ end
488
+
489
+ ##
490
+ # @return [String] Absolute URLs to access the Participants, Messages and Webhooks of this Conversation.
491
+ def links
492
+ @properties['links']
493
+ end
494
+
495
+ ##
496
+ # Update the ConversationInstance
497
+ # @param [String] friendly_name The human-readable name of this conversation,
498
+ # limited to 256 characters. Optional.
499
+ # @param [Time] date_created The date that this resource was created.
500
+ # @param [Time] date_updated The date that this resource was last updated.
501
+ # @param [String] attributes An optional string metadata field you can use to
502
+ # store any data you wish. The string value must contain structurally valid JSON
503
+ # if specified. **Note** that if the attributes are not set "{}" will be
504
+ # returned.
505
+ # @param [String] messaging_service_sid The unique id of the [SMS
506
+ # Service](https://www.twilio.com/docs/sms/services/api) this conversation belongs
507
+ # to.
508
+ # @param [conversation.State] state Current state of this conversation. Can be
509
+ # either `active`, `inactive` or `closed` and defaults to `active`
510
+ # @param [String] timers_inactive ISO8601 duration when conversation will be
511
+ # switched to `inactive` state. Minimum value for this timer is 1 minute.
512
+ # @param [String] timers_closed ISO8601 duration when conversation will be
513
+ # switched to `closed` state. Minimum value for this timer is 10 minutes.
514
+ # @param [conversation.WebhookEnabledType] x_twilio_webhook_enabled The
515
+ # X-Twilio-Webhook-Enabled HTTP request header
516
+ # @return [ConversationInstance] Updated ConversationInstance
517
+ def update(friendly_name: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_service_sid: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, x_twilio_webhook_enabled: :unset)
518
+ context.update(
519
+ friendly_name: friendly_name,
520
+ date_created: date_created,
521
+ date_updated: date_updated,
522
+ attributes: attributes,
523
+ messaging_service_sid: messaging_service_sid,
524
+ state: state,
525
+ timers_inactive: timers_inactive,
526
+ timers_closed: timers_closed,
527
+ x_twilio_webhook_enabled: x_twilio_webhook_enabled,
528
+ )
529
+ end
530
+
531
+ ##
532
+ # Delete the ConversationInstance
533
+ # @param [conversation.WebhookEnabledType] x_twilio_webhook_enabled The
534
+ # X-Twilio-Webhook-Enabled HTTP request header
535
+ # @return [Boolean] true if delete succeeds, false otherwise
536
+ def delete(x_twilio_webhook_enabled: :unset)
537
+ context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
538
+ end
539
+
540
+ ##
541
+ # Fetch the ConversationInstance
542
+ # @return [ConversationInstance] Fetched ConversationInstance
543
+ def fetch
544
+ context.fetch
545
+ end
546
+
547
+ ##
548
+ # Access the participants
549
+ # @return [participants] participants
550
+ def participants
551
+ context.participants
552
+ end
553
+
554
+ ##
555
+ # Access the messages
556
+ # @return [messages] messages
557
+ def messages
558
+ context.messages
559
+ end
560
+
561
+ ##
562
+ # Access the webhooks
563
+ # @return [webhooks] webhooks
564
+ def webhooks
565
+ context.webhooks
566
+ end
567
+
568
+ ##
569
+ # Provide a user friendly representation
570
+ def to_s
571
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
572
+ "<Twilio.Conversations.V1.ConversationInstance #{values}>"
573
+ end
574
+
575
+ ##
576
+ # Provide a detailed, user friendly representation
577
+ def inspect
578
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
579
+ "<Twilio.Conversations.V1.ConversationInstance #{values}>"
580
+ end
581
+ end
582
+ end
583
+ end
584
+ end
585
+ end
586
+ end