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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGES.md +107 -1
- data/CONTRIBUTING.md +2 -2
- data/ISSUE_TEMPLATE.md +5 -1
- data/PULL_REQUEST_TEMPLATE.md +1 -1
- data/README.md +4 -3
- data/lib/twilio-ruby/framework/version.rb +4 -8
- data/lib/twilio-ruby/rest/api/v2010/account/application.rb +6 -4
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +12 -3
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/machine_to_machine.rb +12 -3
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/mobile.rb +12 -3
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/national.rb +12 -3
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb +12 -3
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb +12 -3
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/voip.rb +12 -3
- data/lib/twilio-ruby/rest/api/v2010/account/call.rb +2 -1
- data/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb +85 -60
- data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +5 -2
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +14 -0
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +14 -0
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +14 -0
- data/lib/twilio-ruby/rest/api/v2010/account/message.rb +8 -1
- data/lib/twilio-ruby/rest/api/v2010/account/message/feedback.rb +3 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage/trigger.rb +2 -1
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb +8 -4
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb +11 -4
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb +13 -6
- data/lib/twilio-ruby/rest/client.rb +7 -0
- data/lib/twilio-ruby/rest/conversations.rb +39 -3
- data/lib/twilio-ruby/rest/conversations/v1.rb +68 -5
- data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +268 -0
- data/lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb +262 -0
- data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +21 -10
- data/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb +13 -10
- data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +34 -19
- data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +48 -32
- data/lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb +14 -11
- data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
- data/lib/twilio-ruby/rest/conversations/v1/role.rb +374 -0
- data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +388 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +271 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb +315 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +549 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +394 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +519 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +457 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +395 -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 +72 -0
- data/lib/twilio-ruby/rest/events/v1.rb +90 -0
- data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
- data/lib/twilio-ruby/rest/events/v1/schema.rb +226 -0
- data/lib/twilio-ruby/rest/events/v1/schema/schema_version.rb +290 -0
- data/lib/twilio-ruby/rest/events/v1/sink.rb +380 -0
- data/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb +115 -0
- data/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb +119 -0
- data/lib/twilio-ruby/rest/events/v1/subscription.rb +383 -0
- data/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +216 -0
- data/lib/twilio-ruby/rest/fax/v1/fax.rb +2 -1
- data/lib/twilio-ruby/rest/messaging.rb +6 -0
- data/lib/twilio-ruby/rest/messaging/v1.rb +7 -0
- data/lib/twilio-ruby/rest/messaging/v1/deactivation.rb +164 -0
- data/lib/twilio-ruby/rest/messaging/v1/service.rb +6 -3
- data/lib/twilio-ruby/rest/notify/v1/credential.rb +12 -6
- data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +10 -2
- data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +3 -3
- data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb +16 -2
- data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
- data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb +10 -5
- data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document/dependent_hosted_number_order.rb +6 -3
- data/lib/twilio-ruby/rest/preview/trusted_comms/business/insights.rb +1 -4
- data/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb +3 -1
- data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +45 -4
- data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +14 -1
- 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/fleet.rb +12 -11
- data/lib/twilio-ruby/rest/supersim/v1/sim.rb +17 -7
- data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +75 -9
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +6 -2
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +1 -4
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb +6 -2
- data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +38 -23
- data/lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb +2 -1
- data/lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb +2 -1
- data/lib/twilio-ruby/rest/trunking/v1/trunk/recording.rb +201 -0
- data/lib/twilio-ruby/rest/verify/v2/service.rb +21 -9
- data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +10 -2
- data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +7 -2
- data/lib/twilio-ruby/rest/video/v1/composition.rb +7 -3
- data/lib/twilio-ruby/rest/video/v1/composition_hook.rb +18 -9
- data/lib/twilio-ruby/rest/video/v1/room.rb +2 -1
- data/lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribe_rule.rb +0 -6
- data/lib/twilio-ruby/rest/voice/v1/dialing_permissions.rb +1 -4
- data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +2 -1
- data/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +5 -19
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/framework/version_spec.rb +53 -0
- data/spec/holodeck/holodeck.rb +3 -3
- data/spec/integration/api/v2010/account/incoming_phone_number/local_spec.rb +35 -36
- data/spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb +39 -40
- data/spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb +35 -36
- data/spec/integration/api/v2010/account/incoming_phone_number_spec.rb +25 -23
- data/spec/integration/api/v2010/account/message_spec.rb +37 -0
- data/spec/integration/bulkexports/v1/export/day_spec.rb +5 -5
- data/spec/integration/bulkexports/v1/export_configuration_spec.rb +4 -4
- data/spec/integration/bulkexports/v1/export_spec.rb +3 -3
- data/spec/integration/conversations/v1/{webhook_spec.rb → configuration/webhook_spec.rb} +12 -8
- data/spec/integration/conversations/v1/configuration_spec.rb +87 -0
- data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
- data/spec/integration/conversations/v1/conversation/message_spec.rb +38 -0
- data/spec/integration/conversations/v1/conversation/participant_spec.rb +60 -4
- data/spec/integration/conversations/v1/conversation_spec.rb +35 -0
- data/spec/integration/conversations/v1/credential_spec.rb +219 -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/notification_spec.rb +115 -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/events/v1/schema/schema_version_spec.rb +126 -0
- data/spec/integration/events/v1/schema_spec.rb +46 -0
- data/spec/integration/events/v1/sink/sink_test_spec.rb +42 -0
- data/spec/integration/events/v1/sink/sink_validate_spec.rb +44 -0
- data/spec/integration/events/v1/sink_spec.rb +217 -0
- data/spec/integration/events/v1/subscription/subscribed_event_spec.rb +91 -0
- data/spec/integration/events/v1/subscription_spec.rb +243 -0
- data/spec/integration/messaging/v1/deactivation_spec.rb +40 -0
- data/spec/integration/numbers/v2/regulatory_compliance/end_user_spec.rb +27 -0
- data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
- data/spec/integration/studio/v1/flow/execution/execution_step_spec.rb +1 -0
- data/spec/integration/studio/v2/flow/execution/execution_step_spec.rb +1 -0
- data/spec/integration/supersim/v1/sim_spec.rb +23 -0
- data/spec/integration/supersim/v1/usage_record_spec.rb +463 -18
- data/spec/integration/trunking/v1/trunk/recording_spec.rb +79 -0
- data/spec/integration/trunking/v1/trunk_spec.rb +4 -0
- data/spec/integration/verify/v2/service/access_token_spec.rb +1 -1
- data/spec/integration/verify/v2/service/entity/challenge_spec.rb +8 -8
- data/spec/integration/video/v1/room_spec.rb +37 -0
- data/spec/integration/wireless/v1/sim/data_session_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +82 -5
- data/lib/twilio-ruby/rest/conversations/v1/webhook.rb +0 -262
@@ -0,0 +1,549 @@
|
|
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
|
+
class ConversationContext < InstanceContext
|
15
|
+
##
|
16
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
17
|
+
class MessageList < ListResource
|
18
|
+
##
|
19
|
+
# Initialize the MessageList
|
20
|
+
# @param [Version] version Version that contains the resource
|
21
|
+
# @param [String] chat_service_sid The SID of the [Conversation
|
22
|
+
# Service](https://www.twilio.com/docs/conversations/api/service-resource) the
|
23
|
+
# Participant resource is associated with.
|
24
|
+
# @param [String] conversation_sid The unique ID of the
|
25
|
+
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource)
|
26
|
+
# for this message.
|
27
|
+
# @return [MessageList] MessageList
|
28
|
+
def initialize(version, chat_service_sid: nil, conversation_sid: nil)
|
29
|
+
super(version)
|
30
|
+
|
31
|
+
# Path Solution
|
32
|
+
@solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid}
|
33
|
+
@uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Messages"
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Create the MessageInstance
|
38
|
+
# @param [String] author The channel specific identifier of the message's author.
|
39
|
+
# Defaults to `system`.
|
40
|
+
# @param [String] body The content of the message, can be up to 1,600 characters
|
41
|
+
# long.
|
42
|
+
# @param [Time] date_created The date that this resource was created.
|
43
|
+
# @param [Time] date_updated The date that this resource was last updated. `null`
|
44
|
+
# if the message has not been edited.
|
45
|
+
# @param [String] attributes A string metadata field you can use to store any data
|
46
|
+
# you wish. The string value must contain structurally valid JSON if specified.
|
47
|
+
# **Note** that if the attributes are not set "{}" will be returned.
|
48
|
+
# @param [String] media_sid The Media SID to be attached to the new Message.
|
49
|
+
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
|
50
|
+
# X-Twilio-Webhook-Enabled HTTP request header
|
51
|
+
# @return [MessageInstance] Created MessageInstance
|
52
|
+
def create(author: :unset, body: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, media_sid: :unset, x_twilio_webhook_enabled: :unset)
|
53
|
+
data = Twilio::Values.of({
|
54
|
+
'Author' => author,
|
55
|
+
'Body' => body,
|
56
|
+
'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
|
57
|
+
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
|
58
|
+
'Attributes' => attributes,
|
59
|
+
'MediaSid' => media_sid,
|
60
|
+
})
|
61
|
+
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
|
62
|
+
|
63
|
+
payload = @version.create('POST', @uri, data: data, headers: headers)
|
64
|
+
|
65
|
+
MessageInstance.new(
|
66
|
+
@version,
|
67
|
+
payload,
|
68
|
+
chat_service_sid: @solution[:chat_service_sid],
|
69
|
+
conversation_sid: @solution[:conversation_sid],
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# Lists MessageInstance records from the API as a list.
|
75
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
76
|
+
# memory before returning.
|
77
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
78
|
+
# guarantees to never return more than limit. Default is no limit
|
79
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
80
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
81
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
82
|
+
# efficient page size, i.e. min(limit, 1000)
|
83
|
+
# @return [Array] Array of up to limit results
|
84
|
+
def list(limit: nil, page_size: nil)
|
85
|
+
self.stream(limit: limit, page_size: page_size).entries
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Streams MessageInstance records from the API as an Enumerable.
|
90
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
91
|
+
# is reached.
|
92
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
93
|
+
# guarantees to never return more than limit. Default is no limit.
|
94
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
95
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
96
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
97
|
+
# efficient page size, i.e. min(limit, 1000)
|
98
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
99
|
+
def stream(limit: nil, page_size: nil)
|
100
|
+
limits = @version.read_limits(limit, page_size)
|
101
|
+
|
102
|
+
page = self.page(page_size: limits[:page_size], )
|
103
|
+
|
104
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
105
|
+
end
|
106
|
+
|
107
|
+
##
|
108
|
+
# When passed a block, yields MessageInstance records from the API.
|
109
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
110
|
+
# is reached.
|
111
|
+
def each
|
112
|
+
limits = @version.read_limits
|
113
|
+
|
114
|
+
page = self.page(page_size: limits[:page_size], )
|
115
|
+
|
116
|
+
@version.stream(page,
|
117
|
+
limit: limits[:limit],
|
118
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
119
|
+
end
|
120
|
+
|
121
|
+
##
|
122
|
+
# Retrieve a single page of MessageInstance records from the API.
|
123
|
+
# Request is executed immediately.
|
124
|
+
# @param [String] page_token PageToken provided by the API
|
125
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
126
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
127
|
+
# @return [Page] Page of MessageInstance
|
128
|
+
def page(page_token: :unset, page_number: :unset, page_size: :unset)
|
129
|
+
params = Twilio::Values.of({
|
130
|
+
'PageToken' => page_token,
|
131
|
+
'Page' => page_number,
|
132
|
+
'PageSize' => page_size,
|
133
|
+
})
|
134
|
+
|
135
|
+
response = @version.page('GET', @uri, params: params)
|
136
|
+
|
137
|
+
MessagePage.new(@version, response, @solution)
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# Retrieve a single page of MessageInstance records from the API.
|
142
|
+
# Request is executed immediately.
|
143
|
+
# @param [String] target_url API-generated URL for the requested results page
|
144
|
+
# @return [Page] Page of MessageInstance
|
145
|
+
def get_page(target_url)
|
146
|
+
response = @version.domain.request(
|
147
|
+
'GET',
|
148
|
+
target_url
|
149
|
+
)
|
150
|
+
MessagePage.new(@version, response, @solution)
|
151
|
+
end
|
152
|
+
|
153
|
+
##
|
154
|
+
# Provide a user friendly representation
|
155
|
+
def to_s
|
156
|
+
'#<Twilio.Conversations.V1.MessageList>'
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
##
|
161
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
162
|
+
class MessagePage < Page
|
163
|
+
##
|
164
|
+
# Initialize the MessagePage
|
165
|
+
# @param [Version] version Version that contains the resource
|
166
|
+
# @param [Response] response Response from the API
|
167
|
+
# @param [Hash] solution Path solution for the resource
|
168
|
+
# @return [MessagePage] MessagePage
|
169
|
+
def initialize(version, response, solution)
|
170
|
+
super(version, response)
|
171
|
+
|
172
|
+
# Path Solution
|
173
|
+
@solution = solution
|
174
|
+
end
|
175
|
+
|
176
|
+
##
|
177
|
+
# Build an instance of MessageInstance
|
178
|
+
# @param [Hash] payload Payload response from the API
|
179
|
+
# @return [MessageInstance] MessageInstance
|
180
|
+
def get_instance(payload)
|
181
|
+
MessageInstance.new(
|
182
|
+
@version,
|
183
|
+
payload,
|
184
|
+
chat_service_sid: @solution[:chat_service_sid],
|
185
|
+
conversation_sid: @solution[:conversation_sid],
|
186
|
+
)
|
187
|
+
end
|
188
|
+
|
189
|
+
##
|
190
|
+
# Provide a user friendly representation
|
191
|
+
def to_s
|
192
|
+
'<Twilio.Conversations.V1.MessagePage>'
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
##
|
197
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
198
|
+
class MessageContext < InstanceContext
|
199
|
+
##
|
200
|
+
# Initialize the MessageContext
|
201
|
+
# @param [Version] version Version that contains the resource
|
202
|
+
# @param [String] chat_service_sid The SID of the [Conversation
|
203
|
+
# Service](https://www.twilio.com/docs/conversations/api/service-resource) the
|
204
|
+
# Participant resource is associated with.
|
205
|
+
# @param [String] conversation_sid The unique ID of the
|
206
|
+
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource)
|
207
|
+
# for this message.
|
208
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
209
|
+
# resource.
|
210
|
+
# @return [MessageContext] MessageContext
|
211
|
+
def initialize(version, chat_service_sid, conversation_sid, sid)
|
212
|
+
super(version)
|
213
|
+
|
214
|
+
# Path Solution
|
215
|
+
@solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid, sid: sid, }
|
216
|
+
@uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Messages/#{@solution[:sid]}"
|
217
|
+
|
218
|
+
# Dependents
|
219
|
+
@delivery_receipts = nil
|
220
|
+
end
|
221
|
+
|
222
|
+
##
|
223
|
+
# Update the MessageInstance
|
224
|
+
# @param [String] author The channel specific identifier of the message's author.
|
225
|
+
# Defaults to `system`.
|
226
|
+
# @param [String] body The content of the message, can be up to 1,600 characters
|
227
|
+
# long.
|
228
|
+
# @param [Time] date_created The date that this resource was created.
|
229
|
+
# @param [Time] date_updated The date that this resource was last updated. `null`
|
230
|
+
# if the message has not been edited.
|
231
|
+
# @param [String] attributes A string metadata field you can use to store any data
|
232
|
+
# you wish. The string value must contain structurally valid JSON if specified.
|
233
|
+
# **Note** that if the attributes are not set "{}" will be returned.
|
234
|
+
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
|
235
|
+
# X-Twilio-Webhook-Enabled HTTP request header
|
236
|
+
# @return [MessageInstance] Updated MessageInstance
|
237
|
+
def update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset)
|
238
|
+
data = Twilio::Values.of({
|
239
|
+
'Author' => author,
|
240
|
+
'Body' => body,
|
241
|
+
'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
|
242
|
+
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
|
243
|
+
'Attributes' => attributes,
|
244
|
+
})
|
245
|
+
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
|
246
|
+
|
247
|
+
payload = @version.update('POST', @uri, data: data, headers: headers)
|
248
|
+
|
249
|
+
MessageInstance.new(
|
250
|
+
@version,
|
251
|
+
payload,
|
252
|
+
chat_service_sid: @solution[:chat_service_sid],
|
253
|
+
conversation_sid: @solution[:conversation_sid],
|
254
|
+
sid: @solution[:sid],
|
255
|
+
)
|
256
|
+
end
|
257
|
+
|
258
|
+
##
|
259
|
+
# Delete the MessageInstance
|
260
|
+
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
|
261
|
+
# X-Twilio-Webhook-Enabled HTTP request header
|
262
|
+
# @return [Boolean] true if delete succeeds, false otherwise
|
263
|
+
def delete(x_twilio_webhook_enabled: :unset)
|
264
|
+
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
|
265
|
+
|
266
|
+
@version.delete('DELETE', @uri, headers: headers)
|
267
|
+
end
|
268
|
+
|
269
|
+
##
|
270
|
+
# Fetch the MessageInstance
|
271
|
+
# @return [MessageInstance] Fetched MessageInstance
|
272
|
+
def fetch
|
273
|
+
payload = @version.fetch('GET', @uri)
|
274
|
+
|
275
|
+
MessageInstance.new(
|
276
|
+
@version,
|
277
|
+
payload,
|
278
|
+
chat_service_sid: @solution[:chat_service_sid],
|
279
|
+
conversation_sid: @solution[:conversation_sid],
|
280
|
+
sid: @solution[:sid],
|
281
|
+
)
|
282
|
+
end
|
283
|
+
|
284
|
+
##
|
285
|
+
# Access the delivery_receipts
|
286
|
+
# @return [DeliveryReceiptList]
|
287
|
+
# @return [DeliveryReceiptContext] if sid was passed.
|
288
|
+
def delivery_receipts(sid=:unset)
|
289
|
+
raise ArgumentError, 'sid cannot be nil' if sid.nil?
|
290
|
+
|
291
|
+
if sid != :unset
|
292
|
+
return DeliveryReceiptContext.new(
|
293
|
+
@version,
|
294
|
+
@solution[:chat_service_sid],
|
295
|
+
@solution[:conversation_sid],
|
296
|
+
@solution[:sid],
|
297
|
+
sid,
|
298
|
+
)
|
299
|
+
end
|
300
|
+
|
301
|
+
unless @delivery_receipts
|
302
|
+
@delivery_receipts = DeliveryReceiptList.new(
|
303
|
+
@version,
|
304
|
+
chat_service_sid: @solution[:chat_service_sid],
|
305
|
+
conversation_sid: @solution[:conversation_sid],
|
306
|
+
message_sid: @solution[:sid],
|
307
|
+
)
|
308
|
+
end
|
309
|
+
|
310
|
+
@delivery_receipts
|
311
|
+
end
|
312
|
+
|
313
|
+
##
|
314
|
+
# Provide a user friendly representation
|
315
|
+
def to_s
|
316
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
317
|
+
"#<Twilio.Conversations.V1.MessageContext #{context}>"
|
318
|
+
end
|
319
|
+
|
320
|
+
##
|
321
|
+
# Provide a detailed, user friendly representation
|
322
|
+
def inspect
|
323
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
324
|
+
"#<Twilio.Conversations.V1.MessageContext #{context}>"
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
##
|
329
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
330
|
+
class MessageInstance < InstanceResource
|
331
|
+
##
|
332
|
+
# Initialize the MessageInstance
|
333
|
+
# @param [Version] version Version that contains the resource
|
334
|
+
# @param [Hash] payload payload that contains response from Twilio
|
335
|
+
# @param [String] chat_service_sid The SID of the [Conversation
|
336
|
+
# Service](https://www.twilio.com/docs/conversations/api/service-resource) the
|
337
|
+
# Participant resource is associated with.
|
338
|
+
# @param [String] conversation_sid The unique ID of the
|
339
|
+
# [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource)
|
340
|
+
# for this message.
|
341
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
342
|
+
# resource.
|
343
|
+
# @return [MessageInstance] MessageInstance
|
344
|
+
def initialize(version, payload, chat_service_sid: nil, conversation_sid: nil, sid: nil)
|
345
|
+
super(version)
|
346
|
+
|
347
|
+
# Marshaled Properties
|
348
|
+
@properties = {
|
349
|
+
'account_sid' => payload['account_sid'],
|
350
|
+
'chat_service_sid' => payload['chat_service_sid'],
|
351
|
+
'conversation_sid' => payload['conversation_sid'],
|
352
|
+
'sid' => payload['sid'],
|
353
|
+
'index' => payload['index'].to_i,
|
354
|
+
'author' => payload['author'],
|
355
|
+
'body' => payload['body'],
|
356
|
+
'media' => payload['media'],
|
357
|
+
'attributes' => payload['attributes'],
|
358
|
+
'participant_sid' => payload['participant_sid'],
|
359
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
360
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
361
|
+
'delivery' => payload['delivery'],
|
362
|
+
'url' => payload['url'],
|
363
|
+
'links' => payload['links'],
|
364
|
+
}
|
365
|
+
|
366
|
+
# Context
|
367
|
+
@instance_context = nil
|
368
|
+
@params = {
|
369
|
+
'chat_service_sid' => chat_service_sid,
|
370
|
+
'conversation_sid' => conversation_sid,
|
371
|
+
'sid' => sid || @properties['sid'],
|
372
|
+
}
|
373
|
+
end
|
374
|
+
|
375
|
+
##
|
376
|
+
# Generate an instance context for the instance, the context is capable of
|
377
|
+
# performing various actions. All instance actions are proxied to the context
|
378
|
+
# @return [MessageContext] MessageContext for this MessageInstance
|
379
|
+
def context
|
380
|
+
unless @instance_context
|
381
|
+
@instance_context = MessageContext.new(
|
382
|
+
@version,
|
383
|
+
@params['chat_service_sid'],
|
384
|
+
@params['conversation_sid'],
|
385
|
+
@params['sid'],
|
386
|
+
)
|
387
|
+
end
|
388
|
+
@instance_context
|
389
|
+
end
|
390
|
+
|
391
|
+
##
|
392
|
+
# @return [String] The unique ID of the Account responsible for this message.
|
393
|
+
def account_sid
|
394
|
+
@properties['account_sid']
|
395
|
+
end
|
396
|
+
|
397
|
+
##
|
398
|
+
# @return [String] The SID of the Conversation Service that the resource is associated with.
|
399
|
+
def chat_service_sid
|
400
|
+
@properties['chat_service_sid']
|
401
|
+
end
|
402
|
+
|
403
|
+
##
|
404
|
+
# @return [String] The unique ID of the Conversation for this message.
|
405
|
+
def conversation_sid
|
406
|
+
@properties['conversation_sid']
|
407
|
+
end
|
408
|
+
|
409
|
+
##
|
410
|
+
# @return [String] A 34 character string that uniquely identifies this resource.
|
411
|
+
def sid
|
412
|
+
@properties['sid']
|
413
|
+
end
|
414
|
+
|
415
|
+
##
|
416
|
+
# @return [String] The index of the message within the Conversation.
|
417
|
+
def index
|
418
|
+
@properties['index']
|
419
|
+
end
|
420
|
+
|
421
|
+
##
|
422
|
+
# @return [String] The channel specific identifier of the message's author.
|
423
|
+
def author
|
424
|
+
@properties['author']
|
425
|
+
end
|
426
|
+
|
427
|
+
##
|
428
|
+
# @return [String] The content of the message.
|
429
|
+
def body
|
430
|
+
@properties['body']
|
431
|
+
end
|
432
|
+
|
433
|
+
##
|
434
|
+
# @return [Hash] An array of objects that describe the Message's media if attached, otherwise, null.
|
435
|
+
def media
|
436
|
+
@properties['media']
|
437
|
+
end
|
438
|
+
|
439
|
+
##
|
440
|
+
# @return [String] A string metadata field you can use to store any data you wish.
|
441
|
+
def attributes
|
442
|
+
@properties['attributes']
|
443
|
+
end
|
444
|
+
|
445
|
+
##
|
446
|
+
# @return [String] The unique ID of messages's author participant.
|
447
|
+
def participant_sid
|
448
|
+
@properties['participant_sid']
|
449
|
+
end
|
450
|
+
|
451
|
+
##
|
452
|
+
# @return [Time] The date that this resource was created.
|
453
|
+
def date_created
|
454
|
+
@properties['date_created']
|
455
|
+
end
|
456
|
+
|
457
|
+
##
|
458
|
+
# @return [Time] The date that this resource was last updated.
|
459
|
+
def date_updated
|
460
|
+
@properties['date_updated']
|
461
|
+
end
|
462
|
+
|
463
|
+
##
|
464
|
+
# @return [Hash] An object that contains the summary of delivery statuses for the message to non-chat participants.
|
465
|
+
def delivery
|
466
|
+
@properties['delivery']
|
467
|
+
end
|
468
|
+
|
469
|
+
##
|
470
|
+
# @return [String] An absolute URL for this message.
|
471
|
+
def url
|
472
|
+
@properties['url']
|
473
|
+
end
|
474
|
+
|
475
|
+
##
|
476
|
+
# @return [String] Absolute URLs to access the Receipts of this Message.
|
477
|
+
def links
|
478
|
+
@properties['links']
|
479
|
+
end
|
480
|
+
|
481
|
+
##
|
482
|
+
# Update the MessageInstance
|
483
|
+
# @param [String] author The channel specific identifier of the message's author.
|
484
|
+
# Defaults to `system`.
|
485
|
+
# @param [String] body The content of the message, can be up to 1,600 characters
|
486
|
+
# long.
|
487
|
+
# @param [Time] date_created The date that this resource was created.
|
488
|
+
# @param [Time] date_updated The date that this resource was last updated. `null`
|
489
|
+
# if the message has not been edited.
|
490
|
+
# @param [String] attributes A string metadata field you can use to store any data
|
491
|
+
# you wish. The string value must contain structurally valid JSON if specified.
|
492
|
+
# **Note** that if the attributes are not set "{}" will be returned.
|
493
|
+
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
|
494
|
+
# X-Twilio-Webhook-Enabled HTTP request header
|
495
|
+
# @return [MessageInstance] Updated MessageInstance
|
496
|
+
def update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset)
|
497
|
+
context.update(
|
498
|
+
author: author,
|
499
|
+
body: body,
|
500
|
+
date_created: date_created,
|
501
|
+
date_updated: date_updated,
|
502
|
+
attributes: attributes,
|
503
|
+
x_twilio_webhook_enabled: x_twilio_webhook_enabled,
|
504
|
+
)
|
505
|
+
end
|
506
|
+
|
507
|
+
##
|
508
|
+
# Delete the MessageInstance
|
509
|
+
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
|
510
|
+
# X-Twilio-Webhook-Enabled HTTP request header
|
511
|
+
# @return [Boolean] true if delete succeeds, false otherwise
|
512
|
+
def delete(x_twilio_webhook_enabled: :unset)
|
513
|
+
context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
|
514
|
+
end
|
515
|
+
|
516
|
+
##
|
517
|
+
# Fetch the MessageInstance
|
518
|
+
# @return [MessageInstance] Fetched MessageInstance
|
519
|
+
def fetch
|
520
|
+
context.fetch
|
521
|
+
end
|
522
|
+
|
523
|
+
##
|
524
|
+
# Access the delivery_receipts
|
525
|
+
# @return [delivery_receipts] delivery_receipts
|
526
|
+
def delivery_receipts
|
527
|
+
context.delivery_receipts
|
528
|
+
end
|
529
|
+
|
530
|
+
##
|
531
|
+
# Provide a user friendly representation
|
532
|
+
def to_s
|
533
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
534
|
+
"<Twilio.Conversations.V1.MessageInstance #{values}>"
|
535
|
+
end
|
536
|
+
|
537
|
+
##
|
538
|
+
# Provide a detailed, user friendly representation
|
539
|
+
def inspect
|
540
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
541
|
+
"<Twilio.Conversations.V1.MessageInstance #{values}>"
|
542
|
+
end
|
543
|
+
end
|
544
|
+
end
|
545
|
+
end
|
546
|
+
end
|
547
|
+
end
|
548
|
+
end
|
549
|
+
end
|