twilio-ruby 7.10.6 → 7.11.1
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/.github/workflows/test-and-deploy.yml +43 -67
- data/.gitignore +0 -1
- data/CHANGES.md +57 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +154 -0
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/lib/twilio-ruby/rest/accounts/v1/auth_token_promotion.rb +25 -6
- data/lib/twilio-ruby/rest/accounts/v1/secondary_auth_token.rb +48 -12
- data/lib/twilio-ruby/rest/api/v2010/account/call.rb +6 -0
- data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +56 -2
- data/lib/twilio-ruby/rest/client.rb +0 -5
- data/lib/twilio-ruby/rest/content/v1/content/approval_create.rb +11 -1
- data/lib/twilio-ruby/rest/conversations/v1/conversation/message.rb +10 -10
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +10 -10
- data/lib/twilio-ruby/rest/conversations/v2/action.rb +507 -0
- data/lib/twilio-ruby/rest/conversations/v2/communication.rb +43 -21
- data/lib/twilio-ruby/rest/conversations/v2/configuration.rb +59 -21
- data/lib/twilio-ruby/rest/conversations/v2/conversation.rb +28 -28
- data/lib/twilio-ruby/rest/conversations/v2/operation.rb +10 -10
- data/lib/twilio-ruby/rest/conversations/v2/participant.rb +58 -58
- data/lib/twilio-ruby/rest/conversations/v2.rb +61 -45
- data/lib/twilio-ruby/rest/iam/v1/new_api_key.rb +2 -2
- data/lib/twilio-ruby/rest/iam/v1/o_auth_app.rb +15 -2
- data/lib/twilio-ruby/rest/iam_base.rb +6 -1
- data/lib/twilio-ruby/rest/insights/v1/call/call_summary.rb +7 -0
- data/lib/twilio-ruby/rest/insights/v1/call/event.rb +7 -0
- data/lib/twilio-ruby/rest/insights/v1/call_summaries.rb +7 -0
- data/lib/twilio-ruby/rest/insights/v3/metadata.rb +1 -1
- data/lib/twilio-ruby/rest/insights/v3/query.rb +1 -1
- data/lib/twilio-ruby/rest/insights/v3.rb +1 -1
- data/lib/twilio-ruby/rest/intelligence/v3/conversation.rb +8 -8
- data/lib/twilio-ruby/rest/intelligence/v3/rule_execution.rb +502 -0
- data/lib/twilio-ruby/rest/intelligence/v3.rb +6 -0
- data/lib/twilio-ruby/rest/knowledge/v2/chunk.rb +28 -0
- data/lib/twilio-ruby/rest/knowledge/v2/knowledge.rb +38 -0
- data/lib/twilio-ruby/rest/knowledge/v2/search.rb +8 -117
- data/lib/twilio-ruby/rest/knowledge/v2.rb +1 -2
- data/lib/twilio-ruby/rest/memory/v1/bulk.rb +9 -118
- data/lib/twilio-ruby/rest/memory/v1/conversation_summary.rb +13 -5
- data/lib/twilio-ruby/rest/memory/v1/data_mapping.rb +6 -12
- data/lib/twilio-ruby/rest/memory/v1/identifier.rb +1 -1
- data/lib/twilio-ruby/rest/memory/v1/identity_resolution_setting.rb +11 -132
- data/lib/twilio-ruby/rest/memory/v1/import.rb +28 -5
- data/lib/twilio-ruby/rest/memory/v1/lookup.rb +1 -1
- data/lib/twilio-ruby/rest/memory/v1/observation.rb +70 -18
- data/lib/twilio-ruby/rest/memory/v1/operation.rb +1 -1
- data/lib/twilio-ruby/rest/memory/v1/profile.rb +87 -2
- data/lib/twilio-ruby/rest/memory/v1/recall.rb +1 -1
- data/lib/twilio-ruby/rest/memory/v1/revision.rb +1 -1
- data/lib/twilio-ruby/rest/memory/v1/store.rb +46 -1
- data/lib/twilio-ruby/rest/memory/v1/trait.rb +1 -1
- data/lib/twilio-ruby/rest/memory/v1/trait_group.rb +56 -6
- data/lib/twilio-ruby/rest/memory/v1.rb +3 -46
- data/lib/twilio-ruby/rest/messaging/v1/brand_registration.rb +0 -18
- data/lib/twilio-ruby/rest/messaging/v2/channels_sender.rb +23 -4
- data/lib/twilio-ruby/rest/messaging/v3/typing_indicator.rb +4 -4
- data/lib/twilio-ruby/rest/numbers/v1/sms_verification.rb +231 -0
- data/lib/twilio-ruby/rest/numbers/v1/sms_verification_check.rb +238 -0
- data/lib/twilio-ruby/rest/numbers/v1/voice_verification.rb +245 -0
- data/lib/twilio-ruby/rest/numbers/v1/voice_verification_check.rb +224 -0
- data/lib/twilio-ruby/rest/numbers/v1.rb +24 -0
- data/lib/twilio-ruby/rest/{assistants/v1/session.rb → numbers/v2/caller_id.rb} +141 -127
- data/lib/twilio-ruby/rest/numbers/v2.rb +16 -0
- data/lib/twilio-ruby/rest/oauth/v2/authorize.rb +14 -2
- data/lib/twilio-ruby/rest/oauth/v2/oauth_authorization_server.rb +259 -0
- data/lib/twilio-ruby/rest/oauth/v2/token.rb +8 -2
- data/lib/twilio-ruby/rest/preview_iam/versionless/organization.rb +0 -19
- data/lib/twilio-ruby/rest/routes/v3/phone_number.rb +465 -0
- data/lib/twilio-ruby/rest/routes/v3.rb +50 -0
- data/lib/twilio-ruby/rest/routes_base.rb +6 -1
- data/lib/twilio-ruby/rest/trusthub/v1/a2p_brand_registration.rb +330 -0
- data/lib/twilio-ruby/rest/trusthub/v1/a2p_brand_registration_embedded_session.rb +233 -0
- data/lib/twilio-ruby/rest/trusthub/v1/a2p_campaign_registration.rb +321 -0
- data/lib/twilio-ruby/rest/trusthub/v1/a2p_campaign_registration_embedded_session.rb +233 -0
- data/lib/twilio-ruby/rest/trusthub/v1/customer_profiles_provisional_copy.rb +445 -0
- data/lib/twilio-ruby/rest/trusthub/v1/trust_products_provisional_copy.rb +445 -0
- data/lib/twilio-ruby/rest/trusthub/v1.rb +74 -0
- data/lib/twilio-ruby/rest/voice/v2/account_default_configuration.rb +556 -0
- data/lib/twilio-ruby/rest/voice/v2/configuration/default.rb +356 -0
- data/lib/twilio-ruby/rest/voice/v2/configuration.rb +412 -0
- data/lib/twilio-ruby/rest/voice/v2/recording.rb +616 -0
- data/lib/twilio-ruby/rest/voice/v2/transcription.rb +591 -0
- data/lib/twilio-ruby/rest/voice/v2/type.rb +518 -0
- data/lib/twilio-ruby/rest/voice/v2.rb +141 -0
- data/lib/twilio-ruby/rest/voice_base.rb +5 -0
- data/lib/twilio-ruby/twiml/voice_response.rb +6 -68
- data/lib/twilio-ruby/version.rb +1 -1
- data/twilio-ruby.gemspec +1 -1
- metadata +34 -21
- data/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_knowledge.rb +0 -558
- data/lib/twilio-ruby/rest/assistants/v1/assistant/assistants_tool.rb +0 -558
- data/lib/twilio-ruby/rest/assistants/v1/assistant/feedback.rb +0 -431
- data/lib/twilio-ruby/rest/assistants/v1/assistant/message.rb +0 -296
- data/lib/twilio-ruby/rest/assistants/v1/assistant.rb +0 -927
- data/lib/twilio-ruby/rest/assistants/v1/knowledge/chunk.rb +0 -325
- data/lib/twilio-ruby/rest/assistants/v1/knowledge/knowledge_status.rb +0 -349
- data/lib/twilio-ruby/rest/assistants/v1/knowledge.rb +0 -871
- data/lib/twilio-ruby/rest/assistants/v1/policy.rb +0 -364
- data/lib/twilio-ruby/rest/assistants/v1/session/message.rb +0 -360
- data/lib/twilio-ruby/rest/assistants/v1/tool.rb +0 -847
- data/lib/twilio-ruby/rest/assistants/v1.rb +0 -104
- data/lib/twilio-ruby/rest/assistants.rb +0 -6
- data/lib/twilio-ruby/rest/assistants_base.rb +0 -38
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
##
|
|
2
|
+
# This code was generated by
|
|
3
|
+
# ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
|
4
|
+
# | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
|
5
|
+
# | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
|
6
|
+
#
|
|
7
|
+
# Conversation Orchestrator
|
|
8
|
+
# Manage configurations, conversations, participants, and communications. Create configurations to define capture rules and channel settings, then use conversations to group related communications.
|
|
9
|
+
#
|
|
10
|
+
# NOTE: This class is auto generated by OpenAPI Generator.
|
|
11
|
+
# https://openapi-generator.tech
|
|
12
|
+
# Do not edit the class manually.
|
|
13
|
+
#
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
module Twilio
|
|
17
|
+
module REST
|
|
18
|
+
class Conversations < ConversationsBase
|
|
19
|
+
class V2 < Version
|
|
20
|
+
class ActionList < ListResource
|
|
21
|
+
|
|
22
|
+
class ConversationsV2SendMessageContent
|
|
23
|
+
# @param [text]: [String] Plain text message body.
|
|
24
|
+
# @param [content_id]: [String] Content template ID (HX... format). When provided, the template is rendered with the variables map and sent to the recipient.
|
|
25
|
+
# @param [variables]: [Hash<String, String>] Variables to substitute into the content template.
|
|
26
|
+
# @param [media_urls]: [Array<String>] URLs of media attachments to include with the message.
|
|
27
|
+
attr_accessor :text, :content_id, :variables, :media_urls
|
|
28
|
+
def initialize(payload)
|
|
29
|
+
@text = payload["text"]
|
|
30
|
+
@content_id = payload["content_id"]
|
|
31
|
+
@variables = payload["variables"]
|
|
32
|
+
@media_urls = payload["media_urls"]
|
|
33
|
+
end
|
|
34
|
+
def to_json(options = {})
|
|
35
|
+
{
|
|
36
|
+
"text": @text,
|
|
37
|
+
"contentId": @content_id,
|
|
38
|
+
"variables": @variables,
|
|
39
|
+
"mediaUrls": @media_urls,
|
|
40
|
+
}.to_json(options)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class ConversationsV2SendMessageParticipant
|
|
45
|
+
# @param [participant_id]: [String] Participant ID to resolve address from.
|
|
46
|
+
# @param [address]: [String] Explicit address formatted according to channel type.
|
|
47
|
+
# @param [channel]: [ConversationsV2Channel]
|
|
48
|
+
attr_accessor :participant_id, :address, :channel
|
|
49
|
+
def initialize(payload)
|
|
50
|
+
@participant_id = payload["participant_id"]
|
|
51
|
+
@address = payload["address"]
|
|
52
|
+
@channel = payload["channel"]
|
|
53
|
+
end
|
|
54
|
+
def to_json(options = {})
|
|
55
|
+
{
|
|
56
|
+
"participantId": @participant_id,
|
|
57
|
+
"address": @address,
|
|
58
|
+
"channel": @channel,
|
|
59
|
+
}.to_json(options)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class ConversationsV2SendMessagePayload
|
|
64
|
+
# @param [from]: [ActionList.ConversationsV2SendMessageParticipant]
|
|
65
|
+
# @param [to]: [Array<ActionList.ConversationsV2SendMessageParticipant>] The recipients of this action.
|
|
66
|
+
# @param [content]: [ActionList.ConversationsV2SendMessageContent]
|
|
67
|
+
# @param [channel_settings]: [Hash<String, Object>] Channel-specific parameters forwarded as-is to the downstream sending service. Allows passing backend-specific fields without requiring API changes.
|
|
68
|
+
attr_accessor :from, :to, :content, :channel_settings
|
|
69
|
+
def initialize(payload)
|
|
70
|
+
@from = payload["from"]
|
|
71
|
+
@to = payload["to"]
|
|
72
|
+
@content = payload["content"]
|
|
73
|
+
@channel_settings = payload["channel_settings"]
|
|
74
|
+
end
|
|
75
|
+
def to_json(options = {})
|
|
76
|
+
{
|
|
77
|
+
"from": @from,
|
|
78
|
+
"to": @to,
|
|
79
|
+
"content": @content,
|
|
80
|
+
"channelSettings": @channel_settings,
|
|
81
|
+
}.to_json(options)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
class CreateConversationActionRequest
|
|
86
|
+
# @param [type]: [String] Action type discriminator. Accepted values: SEND_MESSAGE.
|
|
87
|
+
# @param [payload]: [ActionList.ConversationsV2SendMessagePayload]
|
|
88
|
+
attr_accessor :type, :payload
|
|
89
|
+
def initialize(payload)
|
|
90
|
+
@type = payload["type"]
|
|
91
|
+
@payload = payload["payload"]
|
|
92
|
+
end
|
|
93
|
+
def to_json(options = {})
|
|
94
|
+
{
|
|
95
|
+
"type": @type,
|
|
96
|
+
"payload": @payload,
|
|
97
|
+
}.to_json(options)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
##
|
|
103
|
+
# Initialize the ActionList
|
|
104
|
+
# @param [Version] version Version that contains the resource
|
|
105
|
+
# @return [ActionList] ActionList
|
|
106
|
+
def initialize(version, conversation_id: nil)
|
|
107
|
+
|
|
108
|
+
apiV1Version = ApiV1Version.new version.domain, version
|
|
109
|
+
super(apiV1Version)
|
|
110
|
+
# Path Solution
|
|
111
|
+
@solution = { conversation_id: conversation_id }
|
|
112
|
+
@uri = "/Conversations/#{@solution[:conversation_id]}/Actions"
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
##
|
|
116
|
+
# Create the ActionInstance
|
|
117
|
+
# @param [CreateConversationActionRequest] create_conversation_action_request The action to perform.
|
|
118
|
+
# @return [ActionInstance] Created ActionInstance
|
|
119
|
+
def create(create_conversation_action_request: nil
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
|
|
123
|
+
headers['Content-Type'] = 'application/json'
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
payload = @version.create('POST', @uri, headers: headers, data: create_conversation_action_request.to_json)
|
|
129
|
+
ActionInstance.new(
|
|
130
|
+
@version,
|
|
131
|
+
payload,
|
|
132
|
+
conversation_id: @solution[:conversation_id],
|
|
133
|
+
)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
##
|
|
137
|
+
# Create the ActionInstanceMetadata
|
|
138
|
+
# @param [CreateConversationActionRequest] create_conversation_action_request The action to perform.
|
|
139
|
+
# @return [ActionInstance] Created ActionInstance
|
|
140
|
+
def create_with_metadata(create_conversation_action_request: nil
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
|
|
144
|
+
headers['Content-Type'] = 'application/json'
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
response = @version.create_with_metadata('POST', @uri, headers: headers, data: create_conversation_action_request.to_json)
|
|
150
|
+
action_instance = ActionInstance.new(
|
|
151
|
+
@version,
|
|
152
|
+
response.body,
|
|
153
|
+
conversation_id: @solution[:conversation_id],
|
|
154
|
+
)
|
|
155
|
+
ActionInstanceMetadata.new(
|
|
156
|
+
@version,
|
|
157
|
+
action_instance,
|
|
158
|
+
response.headers,
|
|
159
|
+
response.status_code
|
|
160
|
+
)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# Provide a user friendly representation
|
|
167
|
+
def to_s
|
|
168
|
+
'#<Twilio.Conversations.V2.ActionList>'
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
class ActionContext < InstanceContext
|
|
174
|
+
##
|
|
175
|
+
# Initialize the ActionContext
|
|
176
|
+
# @param [Version] version Version that contains the resource
|
|
177
|
+
# @param [String] conversation_id
|
|
178
|
+
# @param [String] action_id
|
|
179
|
+
# @return [ActionContext] ActionContext
|
|
180
|
+
def initialize(version, conversation_id, action_id)
|
|
181
|
+
|
|
182
|
+
apiV1Version = ApiV1Version.new version.domain, version
|
|
183
|
+
super(apiV1Version)
|
|
184
|
+
|
|
185
|
+
# Path Solution
|
|
186
|
+
@solution = { conversation_id: conversation_id, action_id: action_id, }
|
|
187
|
+
@uri = "/Conversations/#{@solution[:conversation_id]}/Actions/#{@solution[:action_id]}"
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
end
|
|
191
|
+
##
|
|
192
|
+
# Fetch the ActionInstance
|
|
193
|
+
# @return [ActionInstance] Fetched ActionInstance
|
|
194
|
+
def fetch
|
|
195
|
+
|
|
196
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
payload = @version.fetch('GET', @uri, headers: headers)
|
|
203
|
+
ActionInstance.new(
|
|
204
|
+
@version,
|
|
205
|
+
payload,
|
|
206
|
+
conversation_id: @solution[:conversation_id],
|
|
207
|
+
action_id: @solution[:action_id],
|
|
208
|
+
)
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
##
|
|
212
|
+
# Fetch the ActionInstanceMetadata
|
|
213
|
+
# @return [ActionInstance] Fetched ActionInstance
|
|
214
|
+
def fetch_with_metadata
|
|
215
|
+
|
|
216
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
response = @version.fetch_with_metadata('GET', @uri, headers: headers)
|
|
223
|
+
action_instance = ActionInstance.new(
|
|
224
|
+
@version,
|
|
225
|
+
response.body,
|
|
226
|
+
conversation_id: @solution[:conversation_id],
|
|
227
|
+
action_id: @solution[:action_id],
|
|
228
|
+
)
|
|
229
|
+
ActionInstanceMetadata.new(
|
|
230
|
+
@version,
|
|
231
|
+
action_instance,
|
|
232
|
+
response.headers,
|
|
233
|
+
response.status_code
|
|
234
|
+
)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
##
|
|
239
|
+
# Provide a user friendly representation
|
|
240
|
+
def to_s
|
|
241
|
+
context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
|
|
242
|
+
"#<Twilio.Conversations.V2.ActionContext #{context}>"
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
##
|
|
246
|
+
# Provide a detailed, user friendly representation
|
|
247
|
+
def inspect
|
|
248
|
+
context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
|
|
249
|
+
"#<Twilio.Conversations.V2.ActionContext #{context}>"
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
class ActionInstanceMetadata < InstanceResourceMetadata
|
|
254
|
+
##
|
|
255
|
+
# Initializes a new ActionInstanceMetadata.
|
|
256
|
+
# @param [Version] version Version that contains the resource
|
|
257
|
+
# @param [}ActionInstance] action_instance The instance associated with the metadata.
|
|
258
|
+
# @param [Hash] headers Header object with response headers.
|
|
259
|
+
# @param [Integer] status_code The HTTP status code of the response.
|
|
260
|
+
# @return [ActionInstanceMetadata] The initialized instance with metadata.
|
|
261
|
+
def initialize(version, action_instance, headers, status_code)
|
|
262
|
+
super(version, headers, status_code)
|
|
263
|
+
@action_instance = action_instance
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def action
|
|
267
|
+
@action_instance
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def headers
|
|
271
|
+
@headers
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def status_code
|
|
275
|
+
@status_code
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def to_s
|
|
279
|
+
"<Twilio.Api.V2010.ActionInstanceMetadata status=#{@status_code}>"
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
class ActionListResponse < InstanceListResource
|
|
284
|
+
# @param [Array<ActionInstance>] instance
|
|
285
|
+
# @param [Hash{String => Object}] headers
|
|
286
|
+
# @param [Integer] status_code
|
|
287
|
+
def initialize(version, payload, key)
|
|
288
|
+
@action_instance = payload.body[key].map do |data|
|
|
289
|
+
ActionInstance.new(version, data)
|
|
290
|
+
end
|
|
291
|
+
@headers = payload.headers
|
|
292
|
+
@status_code = payload.status_code
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def action_instance
|
|
296
|
+
@instance
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
class ActionPage < TokenPage
|
|
301
|
+
##
|
|
302
|
+
# Initialize the ActionPage
|
|
303
|
+
# @param [Version] version Version that contains the resource
|
|
304
|
+
# @param [Response] response Response from the API
|
|
305
|
+
# @param [Hash] solution Path solution for the resource
|
|
306
|
+
# @return [ActionPage] ActionPage
|
|
307
|
+
def initialize(version, response, solution)
|
|
308
|
+
|
|
309
|
+
apiV1Version = ApiV1Version.new version.domain, version
|
|
310
|
+
super(apiV1Version, response)
|
|
311
|
+
|
|
312
|
+
# Path Solution
|
|
313
|
+
@solution = solution
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
##
|
|
317
|
+
# Build an instance of ActionInstance
|
|
318
|
+
# @param [Hash] payload Payload response from the API
|
|
319
|
+
# @return [ActionInstance] ActionInstance
|
|
320
|
+
def get_instance(payload)
|
|
321
|
+
ActionInstance.new(@version, payload, conversation_id: @solution[:conversation_id])
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
##
|
|
325
|
+
# Provide a user friendly representation
|
|
326
|
+
def to_s
|
|
327
|
+
'<Twilio.Conversations.V2.ActionPage>'
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
class ActionPageMetadata < PageMetadata
|
|
332
|
+
attr_reader :action_page
|
|
333
|
+
|
|
334
|
+
def initialize(version, response, solution, limit)
|
|
335
|
+
super(version, response)
|
|
336
|
+
@action_page = []
|
|
337
|
+
@limit = limit
|
|
338
|
+
key = get_key(response.body)
|
|
339
|
+
records = 0
|
|
340
|
+
while( limit != :unset && records < limit )
|
|
341
|
+
@action_page << ActionListResponse.new(version, @payload, key, limit - records)
|
|
342
|
+
@payload = self.next_page
|
|
343
|
+
break unless @payload
|
|
344
|
+
records += (@payload.body[key] || []).size
|
|
345
|
+
end
|
|
346
|
+
# Path Solution
|
|
347
|
+
@solution = solution
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def each
|
|
351
|
+
@action_page.each do |record|
|
|
352
|
+
yield record
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def to_s
|
|
357
|
+
'<Twilio::REST::Conversations::V2PageMetadata>';
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
class ActionListResponse < InstanceListResource
|
|
361
|
+
|
|
362
|
+
# @param [Array<ActionInstance>] instance
|
|
363
|
+
# @param [Hash{String => Object}] headers
|
|
364
|
+
# @param [Integer] status_code
|
|
365
|
+
def initialize(version, payload, key, limit = :unset)
|
|
366
|
+
data_list = payload.body[key] || []
|
|
367
|
+
if limit != :unset
|
|
368
|
+
data_list = data_list[0, limit]
|
|
369
|
+
end
|
|
370
|
+
@action = data_list.map do |data|
|
|
371
|
+
ActionInstance.new(version, data)
|
|
372
|
+
end
|
|
373
|
+
@headers = payload.headers
|
|
374
|
+
@status_code = payload.status_code
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def action
|
|
378
|
+
@action
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def headers
|
|
382
|
+
@headers
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
def status_code
|
|
386
|
+
@status_code
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
class ActionInstance < InstanceResource
|
|
391
|
+
##
|
|
392
|
+
# Initialize the ActionInstance
|
|
393
|
+
# @param [Version] version Version that contains the resource
|
|
394
|
+
# @param [Hash] payload payload that contains response from Twilio
|
|
395
|
+
# @param [String] account_sid The SID of the
|
|
396
|
+
# {Account}[https://www.twilio.com/docs/iam/api/account] that created this Action
|
|
397
|
+
# resource.
|
|
398
|
+
# @param [String] sid The SID of the Call resource to fetch.
|
|
399
|
+
# @return [ActionInstance] ActionInstance
|
|
400
|
+
def initialize(version, payload , conversation_id: nil, action_id: nil)
|
|
401
|
+
|
|
402
|
+
apiV1Version = ApiV1Version.new version.domain, version
|
|
403
|
+
super(apiV1Version)
|
|
404
|
+
|
|
405
|
+
# Marshaled Properties
|
|
406
|
+
@properties = {
|
|
407
|
+
'id' => payload['id'],
|
|
408
|
+
'type' => payload['type'],
|
|
409
|
+
'status' => payload['status'],
|
|
410
|
+
'conversation_id' => payload['conversation_id'],
|
|
411
|
+
'related' => payload['related'],
|
|
412
|
+
'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
|
|
413
|
+
'updated_at' => Twilio.deserialize_iso8601_datetime(payload['updated_at']),
|
|
414
|
+
'completed_at' => Twilio.deserialize_iso8601_datetime(payload['completed_at']),
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
# Context
|
|
418
|
+
@instance_context = nil
|
|
419
|
+
@params = { 'conversation_id' => conversation_id || @properties['conversation_id'] ,'action_id' => action_id || @properties['action_id'] , }
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
##
|
|
423
|
+
# Generate an instance context for the instance, the context is capable of
|
|
424
|
+
# performing various actions. All instance actions are proxied to the context
|
|
425
|
+
# @return [ActionContext] CallContext for this CallInstance
|
|
426
|
+
def context
|
|
427
|
+
unless @instance_context
|
|
428
|
+
@instance_context = ActionContext.new(@version , @params['conversation_id'], @params['action_id'])
|
|
429
|
+
end
|
|
430
|
+
@instance_context
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
##
|
|
434
|
+
# @return [String] Unique identifier for this Action.
|
|
435
|
+
def id
|
|
436
|
+
@properties['id']
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
##
|
|
440
|
+
# @return [String] The type of action. Accepted values: SEND_MESSAGE.
|
|
441
|
+
def type
|
|
442
|
+
@properties['type']
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
##
|
|
446
|
+
# @return [ConversationsV2ActionStatus]
|
|
447
|
+
def status
|
|
448
|
+
@properties['status']
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
##
|
|
452
|
+
# @return [String] The conversation this action belongs to.
|
|
453
|
+
def conversation_id
|
|
454
|
+
@properties['conversation_id']
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
##
|
|
458
|
+
# @return [Hash<String, String>] Named identifiers from downstream. For SEND_MESSAGE: - messageSid: The downstream message SID (present when PENDING or COMPLETED) - communicationId: The Communication ID (present when COMPLETED)
|
|
459
|
+
def related
|
|
460
|
+
@properties['related']
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
##
|
|
464
|
+
# @return [Time] Timestamp when the action was created.
|
|
465
|
+
def created_at
|
|
466
|
+
@properties['created_at']
|
|
467
|
+
end
|
|
468
|
+
|
|
469
|
+
##
|
|
470
|
+
# @return [Time] Timestamp when the action was last updated.
|
|
471
|
+
def updated_at
|
|
472
|
+
@properties['updated_at']
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
##
|
|
476
|
+
# @return [Time] Timestamp when the action reached a terminal status.
|
|
477
|
+
def completed_at
|
|
478
|
+
@properties['completed_at']
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
##
|
|
482
|
+
# Fetch the ActionInstance
|
|
483
|
+
# @return [ActionInstance] Fetched ActionInstance
|
|
484
|
+
def fetch
|
|
485
|
+
|
|
486
|
+
context.fetch
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
##
|
|
490
|
+
# Provide a user friendly representation
|
|
491
|
+
def to_s
|
|
492
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
|
493
|
+
"<Twilio.Conversations.V2.ActionInstance #{values}>"
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
##
|
|
497
|
+
# Provide a detailed, user friendly representation
|
|
498
|
+
def inspect
|
|
499
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
|
500
|
+
"<Twilio.Conversations.V2.ActionInstance #{values}>"
|
|
501
|
+
end
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
end
|
|
505
|
+
end
|
|
506
|
+
end
|
|
507
|
+
end
|
|
@@ -83,13 +83,15 @@ module Twilio
|
|
|
83
83
|
# @param [author]: [CommunicationList.CreateCommunicationInConversationRequestAuthor]
|
|
84
84
|
# @param [content]: [CommunicationList.CreateCommunicationInConversationRequestContent]
|
|
85
85
|
# @param [channel_id]: [String]
|
|
86
|
-
# @param [recipients]: [Array<CommunicationList.
|
|
87
|
-
|
|
86
|
+
# @param [recipients]: [Array<CommunicationList.CreateCommunicationInConversationRequestRecipients>]
|
|
87
|
+
# @param [occurred_at]: [Time] Timestamp when this Communication occurred. If omitted, the server uses the current time.
|
|
88
|
+
attr_accessor :author, :content, :channel_id, :recipients, :occurred_at
|
|
88
89
|
def initialize(payload)
|
|
89
90
|
@author = payload["author"]
|
|
90
91
|
@content = payload["content"]
|
|
91
92
|
@channel_id = payload["channel_id"]
|
|
92
93
|
@recipients = payload["recipients"]
|
|
94
|
+
@occurred_at = payload["occurred_at"]
|
|
93
95
|
end
|
|
94
96
|
def to_json(options = {})
|
|
95
97
|
{
|
|
@@ -97,13 +99,14 @@ module Twilio
|
|
|
97
99
|
"content": @content,
|
|
98
100
|
"channelId": @channel_id,
|
|
99
101
|
"recipients": @recipients,
|
|
102
|
+
"occurredAt": @occurred_at,
|
|
100
103
|
}.to_json(options)
|
|
101
104
|
end
|
|
102
105
|
end
|
|
103
106
|
|
|
104
107
|
class CreateCommunicationInConversationRequestAuthor
|
|
105
108
|
# @param [address]: [String]
|
|
106
|
-
# @param [channel]: [String]
|
|
109
|
+
# @param [channel]: [String] Channel type for a Communication address.
|
|
107
110
|
# @param [participant_id]: [String]
|
|
108
111
|
attr_accessor :address, :channel, :participant_id
|
|
109
112
|
def initialize(payload)
|
|
@@ -139,18 +142,37 @@ module Twilio
|
|
|
139
142
|
end
|
|
140
143
|
end
|
|
141
144
|
|
|
145
|
+
class CreateCommunicationInConversationRequestRecipients
|
|
146
|
+
# @param [address]: [String]
|
|
147
|
+
# @param [channel]: [String] Channel type for a Communication address.
|
|
148
|
+
# @param [participant_id]: [String]
|
|
149
|
+
attr_accessor :address, :channel, :participant_id
|
|
150
|
+
def initialize(payload)
|
|
151
|
+
@address = payload["address"]
|
|
152
|
+
@channel = payload["channel"]
|
|
153
|
+
@participant_id = payload["participant_id"]
|
|
154
|
+
end
|
|
155
|
+
def to_json(options = {})
|
|
156
|
+
{
|
|
157
|
+
"address": @address,
|
|
158
|
+
"channel": @channel,
|
|
159
|
+
"participantId": @participant_id,
|
|
160
|
+
}.to_json(options)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
142
164
|
|
|
143
165
|
##
|
|
144
166
|
# Initialize the CommunicationList
|
|
145
167
|
# @param [Version] version Version that contains the resource
|
|
146
168
|
# @return [CommunicationList] CommunicationList
|
|
147
|
-
def initialize(version,
|
|
169
|
+
def initialize(version, conversation_id: nil)
|
|
148
170
|
|
|
149
171
|
apiV1Version = ApiV1Version.new version.domain, version
|
|
150
172
|
super(apiV1Version)
|
|
151
173
|
# Path Solution
|
|
152
|
-
@solution = {
|
|
153
|
-
@uri = "/Conversations/#{@solution[:
|
|
174
|
+
@solution = { conversation_id: conversation_id }
|
|
175
|
+
@uri = "/Conversations/#{@solution[:conversation_id]}/Communications"
|
|
154
176
|
|
|
155
177
|
end
|
|
156
178
|
##
|
|
@@ -170,7 +192,7 @@ module Twilio
|
|
|
170
192
|
CommunicationInstance.new(
|
|
171
193
|
@version,
|
|
172
194
|
payload,
|
|
173
|
-
|
|
195
|
+
conversation_id: @solution[:conversation_id],
|
|
174
196
|
)
|
|
175
197
|
end
|
|
176
198
|
|
|
@@ -191,7 +213,7 @@ module Twilio
|
|
|
191
213
|
communication_instance = CommunicationInstance.new(
|
|
192
214
|
@version,
|
|
193
215
|
response.body,
|
|
194
|
-
|
|
216
|
+
conversation_id: @solution[:conversation_id],
|
|
195
217
|
)
|
|
196
218
|
CommunicationInstanceMetadata.new(
|
|
197
219
|
@version,
|
|
@@ -344,17 +366,17 @@ module Twilio
|
|
|
344
366
|
##
|
|
345
367
|
# Initialize the CommunicationContext
|
|
346
368
|
# @param [Version] version Version that contains the resource
|
|
347
|
-
# @param [String]
|
|
348
|
-
# @param [String]
|
|
369
|
+
# @param [String] conversation_id
|
|
370
|
+
# @param [String] id
|
|
349
371
|
# @return [CommunicationContext] CommunicationContext
|
|
350
|
-
def initialize(version,
|
|
372
|
+
def initialize(version, conversation_id, id)
|
|
351
373
|
|
|
352
374
|
apiV1Version = ApiV1Version.new version.domain, version
|
|
353
375
|
super(apiV1Version)
|
|
354
376
|
|
|
355
377
|
# Path Solution
|
|
356
|
-
@solution = {
|
|
357
|
-
@uri = "/Conversations/#{@solution[:
|
|
378
|
+
@solution = { conversation_id: conversation_id, id: id, }
|
|
379
|
+
@uri = "/Conversations/#{@solution[:conversation_id]}/Communications/#{@solution[:id]}"
|
|
358
380
|
|
|
359
381
|
|
|
360
382
|
end
|
|
@@ -373,8 +395,8 @@ module Twilio
|
|
|
373
395
|
CommunicationInstance.new(
|
|
374
396
|
@version,
|
|
375
397
|
payload,
|
|
376
|
-
|
|
377
|
-
|
|
398
|
+
conversation_id: @solution[:conversation_id],
|
|
399
|
+
id: @solution[:id],
|
|
378
400
|
)
|
|
379
401
|
end
|
|
380
402
|
|
|
@@ -393,8 +415,8 @@ module Twilio
|
|
|
393
415
|
communication_instance = CommunicationInstance.new(
|
|
394
416
|
@version,
|
|
395
417
|
response.body,
|
|
396
|
-
|
|
397
|
-
|
|
418
|
+
conversation_id: @solution[:conversation_id],
|
|
419
|
+
id: @solution[:id],
|
|
398
420
|
)
|
|
399
421
|
CommunicationInstanceMetadata.new(
|
|
400
422
|
@version,
|
|
@@ -488,7 +510,7 @@ module Twilio
|
|
|
488
510
|
# @param [Hash] payload Payload response from the API
|
|
489
511
|
# @return [CommunicationInstance] CommunicationInstance
|
|
490
512
|
def get_instance(payload)
|
|
491
|
-
CommunicationInstance.new(@version, payload,
|
|
513
|
+
CommunicationInstance.new(@version, payload, conversation_id: @solution[:conversation_id])
|
|
492
514
|
end
|
|
493
515
|
|
|
494
516
|
##
|
|
@@ -567,7 +589,7 @@ module Twilio
|
|
|
567
589
|
# resource.
|
|
568
590
|
# @param [String] sid The SID of the Call resource to fetch.
|
|
569
591
|
# @return [CommunicationInstance] CommunicationInstance
|
|
570
|
-
def initialize(version, payload ,
|
|
592
|
+
def initialize(version, payload , conversation_id: nil, id: nil)
|
|
571
593
|
|
|
572
594
|
apiV1Version = ApiV1Version.new version.domain, version
|
|
573
595
|
super(apiV1Version)
|
|
@@ -589,7 +611,7 @@ module Twilio
|
|
|
589
611
|
|
|
590
612
|
# Context
|
|
591
613
|
@instance_context = nil
|
|
592
|
-
@params = { '
|
|
614
|
+
@params = { 'conversation_id' => conversation_id || @properties['conversation_id'] ,'id' => id || @properties['id'] , }
|
|
593
615
|
end
|
|
594
616
|
|
|
595
617
|
##
|
|
@@ -598,7 +620,7 @@ module Twilio
|
|
|
598
620
|
# @return [CommunicationContext] CallContext for this CallInstance
|
|
599
621
|
def context
|
|
600
622
|
unless @instance_context
|
|
601
|
-
@instance_context = CommunicationContext.new(@version , @params['
|
|
623
|
+
@instance_context = CommunicationContext.new(@version , @params['conversation_id'], @params['id'])
|
|
602
624
|
end
|
|
603
625
|
@instance_context
|
|
604
626
|
end
|