twilio-ruby 5.14.1 → 5.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +33 -0
- data/README.md +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +2 -1
- data/lib/twilio-ruby/rest/authy.rb +55 -0
- data/lib/twilio-ruby/rest/authy/v1.rb +59 -0
- data/lib/twilio-ruby/rest/authy/v1/form.rb +190 -0
- data/lib/twilio-ruby/rest/authy/v1/service.rb +378 -0
- data/lib/twilio-ruby/rest/authy/v1/service/entity.rb +372 -0
- data/lib/twilio-ruby/rest/authy/v1/service/entity/factor.rb +474 -0
- data/lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb +405 -0
- data/lib/twilio-ruby/rest/autopilot.rb +47 -0
- data/lib/twilio-ruby/rest/autopilot/v1.rb +43 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant.rb +606 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/defaults.rb +215 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/dialogue.rb +205 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb +417 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb +393 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/model_build.rb +390 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb +443 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/style_sheet.rb +215 -0
- data/lib/twilio-ruby/rest/{preview/understand/assistant/intent.rb → autopilot/v1/assistant/task.rb} +91 -84
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb +377 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb +442 -0
- data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/task_actions.rb +244 -0
- data/lib/twilio-ruby/rest/{preview/understand/assistant/intent/intent_statistics.rb → autopilot/v1/assistant/task/task_statistics.rb} +49 -51
- data/lib/twilio-ruby/rest/chat/v1/service.rb +1 -1
- data/lib/twilio-ruby/rest/chat/v2/service/channel.rb +12 -6
- data/lib/twilio-ruby/rest/client.rb +14 -0
- data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +1 -1
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +12 -6
- data/lib/twilio-ruby/rest/preview/understand.rb +2 -1
- data/lib/twilio-ruby/rest/preview/understand/assistant.rb +59 -29
- data/lib/twilio-ruby/rest/preview/understand/assistant/query.rb +17 -13
- data/lib/twilio-ruby/rest/preview/understand/assistant/style_sheet.rb +215 -0
- data/lib/twilio-ruby/rest/preview/understand/assistant/task.rb +505 -0
- data/lib/twilio-ruby/rest/preview/understand/assistant/{intent → task}/field.rb +25 -25
- data/lib/twilio-ruby/rest/preview/understand/assistant/{intent → task}/sample.rb +30 -30
- data/lib/twilio-ruby/rest/preview/understand/assistant/{intent/intent_actions.rb → task/task_actions.rb} +50 -54
- data/lib/twilio-ruby/rest/preview/understand/assistant/task/task_statistics.rb +224 -0
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +7 -7
- data/lib/twilio-ruby/rest/verify/v1/service.rb +45 -6
- data/lib/twilio-ruby/rest/verify/v1/service/verification.rb +9 -2
- data/lib/twilio-ruby/rest/wireless/v1/command.rb +32 -5
- data/lib/twilio-ruby/twiml/voice_response.rb +66 -5
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/api/v2010/account/call/recording_spec.rb +3 -3
- data/spec/integration/api/v2010/account/conference/participant_spec.rb +42 -1
- data/spec/integration/api/v2010/account/conference/recording_spec.rb +2 -2
- data/spec/integration/authy/v1/form_spec.rb +48 -0
- data/spec/integration/authy/v1/service/entity/factor/challenge_spec.rb +267 -0
- data/spec/integration/authy/v1/service/entity/factor_spec.rb +269 -0
- data/spec/integration/authy/v1/service/entity_spec.rb +201 -0
- data/spec/integration/authy/v1/service_spec.rb +227 -0
- data/spec/integration/autopilot/v1/assistant/defaults_spec.rb +81 -0
- data/spec/integration/autopilot/v1/assistant/dialogue_spec.rb +47 -0
- data/spec/integration/autopilot/v1/assistant/field_type/field_value_spec.rb +210 -0
- data/spec/integration/autopilot/v1/assistant/field_type_spec.rb +246 -0
- data/spec/integration/autopilot/v1/assistant/model_build_spec.rb +241 -0
- data/spec/integration/autopilot/v1/assistant/query_spec.rb +306 -0
- data/spec/integration/autopilot/v1/assistant/style_sheet_spec.rb +81 -0
- data/spec/integration/autopilot/v1/assistant/task/field_spec.rb +207 -0
- data/spec/integration/autopilot/v1/assistant/task/sample_spec.rb +253 -0
- data/spec/integration/autopilot/v1/assistant/task/task_actions_spec.rb +87 -0
- data/spec/integration/autopilot/v1/assistant/task/task_statistics_spec.rb +50 -0
- data/spec/integration/autopilot/v1/assistant/task_spec.rb +262 -0
- data/spec/integration/autopilot/v1/assistant_spec.rb +270 -0
- data/spec/integration/preview/understand/assistant/query_spec.rb +8 -8
- data/spec/integration/preview/understand/assistant/style_sheet_spec.rb +81 -0
- data/spec/integration/preview/understand/assistant/{intent → task}/field_spec.rb +23 -23
- data/spec/integration/preview/understand/assistant/{intent → task}/sample_spec.rb +28 -28
- data/spec/integration/preview/understand/assistant/{intent/intent_actions_spec.rb → task/task_actions_spec.rb} +15 -15
- data/spec/integration/preview/understand/assistant/{intent/intent_statistics_spec.rb → task/task_statistics_spec.rb} +6 -6
- data/spec/integration/preview/understand/assistant/{intent_spec.rb → task_spec.rb} +53 -49
- data/spec/integration/preview/understand/assistant_spec.rb +12 -8
- data/spec/integration/taskrouter/v1/workspace/task_queue_spec.rb +3 -7
- data/spec/integration/verify/v1/service_spec.rb +30 -0
- data/spec/integration/wireless/v1/command_spec.rb +99 -2
- data/spec/twiml/voice_response_spec.rb +25 -2
- metadata +78 -17
|
@@ -144,20 +144,20 @@ module Twilio
|
|
|
144
144
|
# @param [String] language An ISO language-country string of the sample.
|
|
145
145
|
# @param [String] query A user-provided string that uniquely identifies this
|
|
146
146
|
# resource as an alternative to the sid. It can be up to 2048 characters long.
|
|
147
|
-
# @param [String]
|
|
148
|
-
#
|
|
149
|
-
#
|
|
147
|
+
# @param [String] tasks Constraints the query to a set of tasks. Useful when you
|
|
148
|
+
# need to constrain the paths the user can take. Tasks should be comma separated
|
|
149
|
+
# *task-unique-name-1*, *task-unique-name-2*
|
|
150
150
|
# @param [String] model_build The Model Build Sid or unique name of the Model
|
|
151
151
|
# Build to be queried.
|
|
152
|
-
# @param [String] field Constraints the query to a given Field with an
|
|
152
|
+
# @param [String] field Constraints the query to a given Field with an task.
|
|
153
153
|
# Useful when you know the Field you are expecting. It accepts one field in the
|
|
154
|
-
# format *
|
|
154
|
+
# format *task-unique-name-1*:*field-unique-name*
|
|
155
155
|
# @return [QueryInstance] Newly created QueryInstance
|
|
156
|
-
def create(language: nil, query: nil,
|
|
156
|
+
def create(language: nil, query: nil, tasks: :unset, model_build: :unset, field: :unset)
|
|
157
157
|
data = Twilio::Values.of({
|
|
158
158
|
'Language' => language,
|
|
159
159
|
'Query' => query,
|
|
160
|
-
'
|
|
160
|
+
'Tasks' => tasks,
|
|
161
161
|
'ModelBuild' => model_build,
|
|
162
162
|
'Field' => field,
|
|
163
163
|
})
|
|
@@ -215,8 +215,9 @@ module Twilio
|
|
|
215
215
|
##
|
|
216
216
|
# Initialize the QueryContext
|
|
217
217
|
# @param [Version] version Version that contains the resource
|
|
218
|
-
# @param [String] assistant_sid The
|
|
219
|
-
# @param [String] sid
|
|
218
|
+
# @param [String] assistant_sid The unique ID of the Assistant.
|
|
219
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
|
220
|
+
# resource.
|
|
220
221
|
# @return [QueryContext] QueryContext
|
|
221
222
|
def initialize(version, assistant_sid, sid)
|
|
222
223
|
super(version)
|
|
@@ -243,7 +244,8 @@ module Twilio
|
|
|
243
244
|
|
|
244
245
|
##
|
|
245
246
|
# Update the QueryInstance
|
|
246
|
-
# @param [String] sample_sid
|
|
247
|
+
# @param [String] sample_sid An optional reference to the Sample created from this
|
|
248
|
+
# query.
|
|
247
249
|
# @param [String] status A string that described the query status. The values can
|
|
248
250
|
# be: pending_review, reviewed, discarded
|
|
249
251
|
# @return [QueryInstance] Updated QueryInstance
|
|
@@ -282,7 +284,8 @@ module Twilio
|
|
|
282
284
|
# @param [Version] version Version that contains the resource
|
|
283
285
|
# @param [Hash] payload payload that contains response from Twilio
|
|
284
286
|
# @param [String] assistant_sid The unique ID of the parent Assistant.
|
|
285
|
-
# @param [String] sid
|
|
287
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
|
288
|
+
# resource.
|
|
286
289
|
# @return [QueryInstance] QueryInstance
|
|
287
290
|
def initialize(version, payload, assistant_sid: nil, sid: nil)
|
|
288
291
|
super(version)
|
|
@@ -339,7 +342,7 @@ module Twilio
|
|
|
339
342
|
end
|
|
340
343
|
|
|
341
344
|
##
|
|
342
|
-
# @return [Hash] The natural language analysis results which include the
|
|
345
|
+
# @return [Hash] The natural language analysis results which include the Task recognized, the confidence score and a list of identified Fields.
|
|
343
346
|
def results
|
|
344
347
|
@properties['results']
|
|
345
348
|
end
|
|
@@ -407,7 +410,8 @@ module Twilio
|
|
|
407
410
|
|
|
408
411
|
##
|
|
409
412
|
# Update the QueryInstance
|
|
410
|
-
# @param [String] sample_sid
|
|
413
|
+
# @param [String] sample_sid An optional reference to the Sample created from this
|
|
414
|
+
# query.
|
|
411
415
|
# @param [String] status A string that described the query status. The values can
|
|
412
416
|
# be: pending_review, reviewed, discarded
|
|
413
417
|
# @return [QueryInstance] Updated QueryInstance
|
|
@@ -0,0 +1,215 @@
|
|
|
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 Preview < Domain
|
|
12
|
+
class Understand < Version
|
|
13
|
+
class AssistantContext < InstanceContext
|
|
14
|
+
##
|
|
15
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
|
16
|
+
class StyleSheetList < ListResource
|
|
17
|
+
##
|
|
18
|
+
# Initialize the StyleSheetList
|
|
19
|
+
# @param [Version] version Version that contains the resource
|
|
20
|
+
# @param [String] assistant_sid The unique ID of the Assistant
|
|
21
|
+
# @return [StyleSheetList] StyleSheetList
|
|
22
|
+
def initialize(version, assistant_sid: nil)
|
|
23
|
+
super(version)
|
|
24
|
+
|
|
25
|
+
# Path Solution
|
|
26
|
+
@solution = {assistant_sid: assistant_sid}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
##
|
|
30
|
+
# Provide a user friendly representation
|
|
31
|
+
def to_s
|
|
32
|
+
'#<Twilio.Preview.Understand.StyleSheetList>'
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
##
|
|
37
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
|
38
|
+
class StyleSheetPage < Page
|
|
39
|
+
##
|
|
40
|
+
# Initialize the StyleSheetPage
|
|
41
|
+
# @param [Version] version Version that contains the resource
|
|
42
|
+
# @param [Response] response Response from the API
|
|
43
|
+
# @param [Hash] solution Path solution for the resource
|
|
44
|
+
# @return [StyleSheetPage] StyleSheetPage
|
|
45
|
+
def initialize(version, response, solution)
|
|
46
|
+
super(version, response)
|
|
47
|
+
|
|
48
|
+
# Path Solution
|
|
49
|
+
@solution = solution
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
##
|
|
53
|
+
# Build an instance of StyleSheetInstance
|
|
54
|
+
# @param [Hash] payload Payload response from the API
|
|
55
|
+
# @return [StyleSheetInstance] StyleSheetInstance
|
|
56
|
+
def get_instance(payload)
|
|
57
|
+
StyleSheetInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
##
|
|
61
|
+
# Provide a user friendly representation
|
|
62
|
+
def to_s
|
|
63
|
+
'<Twilio.Preview.Understand.StyleSheetPage>'
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
##
|
|
68
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
|
69
|
+
class StyleSheetContext < InstanceContext
|
|
70
|
+
##
|
|
71
|
+
# Initialize the StyleSheetContext
|
|
72
|
+
# @param [Version] version Version that contains the resource
|
|
73
|
+
# @param [String] assistant_sid The unique ID of the Assistant
|
|
74
|
+
# @return [StyleSheetContext] StyleSheetContext
|
|
75
|
+
def initialize(version, assistant_sid)
|
|
76
|
+
super(version)
|
|
77
|
+
|
|
78
|
+
# Path Solution
|
|
79
|
+
@solution = {assistant_sid: assistant_sid, }
|
|
80
|
+
@uri = "/Assistants/#{@solution[:assistant_sid]}/StyleSheet"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# Fetch a StyleSheetInstance
|
|
85
|
+
# @return [StyleSheetInstance] Fetched StyleSheetInstance
|
|
86
|
+
def fetch
|
|
87
|
+
params = Twilio::Values.of({})
|
|
88
|
+
|
|
89
|
+
payload = @version.fetch(
|
|
90
|
+
'GET',
|
|
91
|
+
@uri,
|
|
92
|
+
params,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
StyleSheetInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# Update the StyleSheetInstance
|
|
100
|
+
# @param [Hash] style_sheet The JSON Style sheet string
|
|
101
|
+
# @return [StyleSheetInstance] Updated StyleSheetInstance
|
|
102
|
+
def update(style_sheet: :unset)
|
|
103
|
+
data = Twilio::Values.of({'StyleSheet' => Twilio.serialize_object(style_sheet), })
|
|
104
|
+
|
|
105
|
+
payload = @version.update(
|
|
106
|
+
'POST',
|
|
107
|
+
@uri,
|
|
108
|
+
data: data,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
StyleSheetInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
##
|
|
115
|
+
# Provide a user friendly representation
|
|
116
|
+
def to_s
|
|
117
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
|
118
|
+
"#<Twilio.Preview.Understand.StyleSheetContext #{context}>"
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
##
|
|
123
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
|
124
|
+
class StyleSheetInstance < InstanceResource
|
|
125
|
+
##
|
|
126
|
+
# Initialize the StyleSheetInstance
|
|
127
|
+
# @param [Version] version Version that contains the resource
|
|
128
|
+
# @param [Hash] payload payload that contains response from Twilio
|
|
129
|
+
# @param [String] assistant_sid The unique ID of the Assistant
|
|
130
|
+
# @return [StyleSheetInstance] StyleSheetInstance
|
|
131
|
+
def initialize(version, payload, assistant_sid: nil)
|
|
132
|
+
super(version)
|
|
133
|
+
|
|
134
|
+
# Marshaled Properties
|
|
135
|
+
@properties = {
|
|
136
|
+
'account_sid' => payload['account_sid'],
|
|
137
|
+
'assistant_sid' => payload['assistant_sid'],
|
|
138
|
+
'url' => payload['url'],
|
|
139
|
+
'data' => payload['data'],
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
# Context
|
|
143
|
+
@instance_context = nil
|
|
144
|
+
@params = {'assistant_sid' => assistant_sid, }
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
##
|
|
148
|
+
# Generate an instance context for the instance, the context is capable of
|
|
149
|
+
# performing various actions. All instance actions are proxied to the context
|
|
150
|
+
# @return [StyleSheetContext] StyleSheetContext for this StyleSheetInstance
|
|
151
|
+
def context
|
|
152
|
+
unless @instance_context
|
|
153
|
+
@instance_context = StyleSheetContext.new(@version, @params['assistant_sid'], )
|
|
154
|
+
end
|
|
155
|
+
@instance_context
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
##
|
|
159
|
+
# @return [String] The unique ID of the Account that created this Assistant
|
|
160
|
+
def account_sid
|
|
161
|
+
@properties['account_sid']
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
##
|
|
165
|
+
# @return [String] The unique ID of the Assistant
|
|
166
|
+
def assistant_sid
|
|
167
|
+
@properties['assistant_sid']
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
##
|
|
171
|
+
# @return [String] The url
|
|
172
|
+
def url
|
|
173
|
+
@properties['url']
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
##
|
|
177
|
+
# @return [Hash] The JSON style sheet object
|
|
178
|
+
def data
|
|
179
|
+
@properties['data']
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
##
|
|
183
|
+
# Fetch a StyleSheetInstance
|
|
184
|
+
# @return [StyleSheetInstance] Fetched StyleSheetInstance
|
|
185
|
+
def fetch
|
|
186
|
+
context.fetch
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
##
|
|
190
|
+
# Update the StyleSheetInstance
|
|
191
|
+
# @param [Hash] style_sheet The JSON Style sheet string
|
|
192
|
+
# @return [StyleSheetInstance] Updated StyleSheetInstance
|
|
193
|
+
def update(style_sheet: :unset)
|
|
194
|
+
context.update(style_sheet: style_sheet, )
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
##
|
|
198
|
+
# Provide a user friendly representation
|
|
199
|
+
def to_s
|
|
200
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
|
201
|
+
"<Twilio.Preview.Understand.StyleSheetInstance #{values}>"
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
##
|
|
205
|
+
# Provide a detailed, user friendly representation
|
|
206
|
+
def inspect
|
|
207
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
|
208
|
+
"<Twilio.Preview.Understand.StyleSheetInstance #{values}>"
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
end
|
|
@@ -0,0 +1,505 @@
|
|
|
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 Preview < Domain
|
|
12
|
+
class Understand < Version
|
|
13
|
+
class AssistantContext < InstanceContext
|
|
14
|
+
##
|
|
15
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
|
16
|
+
class TaskList < ListResource
|
|
17
|
+
##
|
|
18
|
+
# Initialize the TaskList
|
|
19
|
+
# @param [Version] version Version that contains the resource
|
|
20
|
+
# @param [String] assistant_sid The unique ID of the Assistant.
|
|
21
|
+
# @return [TaskList] TaskList
|
|
22
|
+
def initialize(version, assistant_sid: nil)
|
|
23
|
+
super(version)
|
|
24
|
+
|
|
25
|
+
# Path Solution
|
|
26
|
+
@solution = {assistant_sid: assistant_sid}
|
|
27
|
+
@uri = "/Assistants/#{@solution[:assistant_sid]}/Tasks"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
##
|
|
31
|
+
# Lists TaskInstance records from the API as a list.
|
|
32
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
|
33
|
+
# memory before returning.
|
|
34
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
|
35
|
+
# guarantees to never return more than limit. Default is no limit
|
|
36
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
|
37
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
|
38
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
|
39
|
+
# efficient page size, i.e. min(limit, 1000)
|
|
40
|
+
# @return [Array] Array of up to limit results
|
|
41
|
+
def list(limit: nil, page_size: nil)
|
|
42
|
+
self.stream(limit: limit, page_size: page_size).entries
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# Streams TaskInstance records from the API as an Enumerable.
|
|
47
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
|
48
|
+
# is reached.
|
|
49
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
|
50
|
+
# guarantees to never return more than limit. Default is no limit.
|
|
51
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
|
52
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
|
53
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
|
54
|
+
# efficient page size, i.e. min(limit, 1000)
|
|
55
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
|
56
|
+
def stream(limit: nil, page_size: nil)
|
|
57
|
+
limits = @version.read_limits(limit, page_size)
|
|
58
|
+
|
|
59
|
+
page = self.page(page_size: limits[:page_size], )
|
|
60
|
+
|
|
61
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# When passed a block, yields TaskInstance records from the API.
|
|
66
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
|
67
|
+
# is reached.
|
|
68
|
+
def each
|
|
69
|
+
limits = @version.read_limits
|
|
70
|
+
|
|
71
|
+
page = self.page(page_size: limits[:page_size], )
|
|
72
|
+
|
|
73
|
+
@version.stream(page,
|
|
74
|
+
limit: limits[:limit],
|
|
75
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# Retrieve a single page of TaskInstance records from the API.
|
|
80
|
+
# Request is executed immediately.
|
|
81
|
+
# @param [String] page_token PageToken provided by the API
|
|
82
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
|
83
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
|
84
|
+
# @return [Page] Page of TaskInstance
|
|
85
|
+
def page(page_token: :unset, page_number: :unset, page_size: :unset)
|
|
86
|
+
params = Twilio::Values.of({
|
|
87
|
+
'PageToken' => page_token,
|
|
88
|
+
'Page' => page_number,
|
|
89
|
+
'PageSize' => page_size,
|
|
90
|
+
})
|
|
91
|
+
response = @version.page(
|
|
92
|
+
'GET',
|
|
93
|
+
@uri,
|
|
94
|
+
params
|
|
95
|
+
)
|
|
96
|
+
TaskPage.new(@version, response, @solution)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
##
|
|
100
|
+
# Retrieve a single page of TaskInstance records from the API.
|
|
101
|
+
# Request is executed immediately.
|
|
102
|
+
# @param [String] target_url API-generated URL for the requested results page
|
|
103
|
+
# @return [Page] Page of TaskInstance
|
|
104
|
+
def get_page(target_url)
|
|
105
|
+
response = @version.domain.request(
|
|
106
|
+
'GET',
|
|
107
|
+
target_url
|
|
108
|
+
)
|
|
109
|
+
TaskPage.new(@version, response, @solution)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
##
|
|
113
|
+
# Retrieve a single page of TaskInstance records from the API.
|
|
114
|
+
# Request is executed immediately.
|
|
115
|
+
# @param [String] unique_name A user-provided string that uniquely identifies this
|
|
116
|
+
# resource as an alternative to the sid. Unique up to 64 characters long.
|
|
117
|
+
# @param [String] friendly_name A user-provided string that identifies this
|
|
118
|
+
# resource. It is non-unique and can up to 255 characters long.
|
|
119
|
+
# @param [Hash] actions A user-provided JSON object encoded as a string to specify
|
|
120
|
+
# the actions for this task. It is optional and non-unique.
|
|
121
|
+
# @param [String] actions_url User-provided HTTP endpoint where from the assistant
|
|
122
|
+
# fetches actions
|
|
123
|
+
# @return [TaskInstance] Newly created TaskInstance
|
|
124
|
+
def create(unique_name: nil, friendly_name: :unset, actions: :unset, actions_url: :unset)
|
|
125
|
+
data = Twilio::Values.of({
|
|
126
|
+
'UniqueName' => unique_name,
|
|
127
|
+
'FriendlyName' => friendly_name,
|
|
128
|
+
'Actions' => Twilio.serialize_object(actions),
|
|
129
|
+
'ActionsUrl' => actions_url,
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
payload = @version.create(
|
|
133
|
+
'POST',
|
|
134
|
+
@uri,
|
|
135
|
+
data: data
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
TaskInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
##
|
|
142
|
+
# Provide a user friendly representation
|
|
143
|
+
def to_s
|
|
144
|
+
'#<Twilio.Preview.Understand.TaskList>'
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
##
|
|
149
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
|
150
|
+
class TaskPage < Page
|
|
151
|
+
##
|
|
152
|
+
# Initialize the TaskPage
|
|
153
|
+
# @param [Version] version Version that contains the resource
|
|
154
|
+
# @param [Response] response Response from the API
|
|
155
|
+
# @param [Hash] solution Path solution for the resource
|
|
156
|
+
# @return [TaskPage] TaskPage
|
|
157
|
+
def initialize(version, response, solution)
|
|
158
|
+
super(version, response)
|
|
159
|
+
|
|
160
|
+
# Path Solution
|
|
161
|
+
@solution = solution
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
##
|
|
165
|
+
# Build an instance of TaskInstance
|
|
166
|
+
# @param [Hash] payload Payload response from the API
|
|
167
|
+
# @return [TaskInstance] TaskInstance
|
|
168
|
+
def get_instance(payload)
|
|
169
|
+
TaskInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
##
|
|
173
|
+
# Provide a user friendly representation
|
|
174
|
+
def to_s
|
|
175
|
+
'<Twilio.Preview.Understand.TaskPage>'
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
##
|
|
180
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
|
181
|
+
class TaskContext < InstanceContext
|
|
182
|
+
##
|
|
183
|
+
# Initialize the TaskContext
|
|
184
|
+
# @param [Version] version Version that contains the resource
|
|
185
|
+
# @param [String] assistant_sid The unique ID of the Assistant.
|
|
186
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
|
187
|
+
# resource.
|
|
188
|
+
# @return [TaskContext] TaskContext
|
|
189
|
+
def initialize(version, assistant_sid, sid)
|
|
190
|
+
super(version)
|
|
191
|
+
|
|
192
|
+
# Path Solution
|
|
193
|
+
@solution = {assistant_sid: assistant_sid, sid: sid, }
|
|
194
|
+
@uri = "/Assistants/#{@solution[:assistant_sid]}/Tasks/#{@solution[:sid]}"
|
|
195
|
+
|
|
196
|
+
# Dependents
|
|
197
|
+
@fields = nil
|
|
198
|
+
@samples = nil
|
|
199
|
+
@task_actions = nil
|
|
200
|
+
@statistics = nil
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
##
|
|
204
|
+
# Fetch a TaskInstance
|
|
205
|
+
# @return [TaskInstance] Fetched TaskInstance
|
|
206
|
+
def fetch
|
|
207
|
+
params = Twilio::Values.of({})
|
|
208
|
+
|
|
209
|
+
payload = @version.fetch(
|
|
210
|
+
'GET',
|
|
211
|
+
@uri,
|
|
212
|
+
params,
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
TaskInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], sid: @solution[:sid], )
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
##
|
|
219
|
+
# Update the TaskInstance
|
|
220
|
+
# @param [String] friendly_name A user-provided string that identifies this
|
|
221
|
+
# resource. It is non-unique and can up to 255 characters long.
|
|
222
|
+
# @param [String] unique_name A user-provided string that uniquely identifies this
|
|
223
|
+
# resource as an alternative to the sid. Unique up to 64 characters long.
|
|
224
|
+
# @param [Hash] actions A user-provided JSON object encoded as a string to specify
|
|
225
|
+
# the actions for this task. It is optional and non-unique.
|
|
226
|
+
# @param [String] actions_url User-provided HTTP endpoint where from the assistant
|
|
227
|
+
# fetches actions
|
|
228
|
+
# @return [TaskInstance] Updated TaskInstance
|
|
229
|
+
def update(friendly_name: :unset, unique_name: :unset, actions: :unset, actions_url: :unset)
|
|
230
|
+
data = Twilio::Values.of({
|
|
231
|
+
'FriendlyName' => friendly_name,
|
|
232
|
+
'UniqueName' => unique_name,
|
|
233
|
+
'Actions' => Twilio.serialize_object(actions),
|
|
234
|
+
'ActionsUrl' => actions_url,
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
payload = @version.update(
|
|
238
|
+
'POST',
|
|
239
|
+
@uri,
|
|
240
|
+
data: data,
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
TaskInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], sid: @solution[:sid], )
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
##
|
|
247
|
+
# Deletes the TaskInstance
|
|
248
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
|
249
|
+
def delete
|
|
250
|
+
@version.delete('delete', @uri)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
##
|
|
254
|
+
# Access the fields
|
|
255
|
+
# @return [FieldList]
|
|
256
|
+
# @return [FieldContext] if sid was passed.
|
|
257
|
+
def fields(sid=:unset)
|
|
258
|
+
raise ArgumentError, 'sid cannot be nil' if sid.nil?
|
|
259
|
+
|
|
260
|
+
if sid != :unset
|
|
261
|
+
return FieldContext.new(@version, @solution[:assistant_sid], @solution[:sid], sid, )
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
unless @fields
|
|
265
|
+
@fields = FieldList.new(
|
|
266
|
+
@version,
|
|
267
|
+
assistant_sid: @solution[:assistant_sid],
|
|
268
|
+
task_sid: @solution[:sid],
|
|
269
|
+
)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
@fields
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
##
|
|
276
|
+
# Access the samples
|
|
277
|
+
# @return [SampleList]
|
|
278
|
+
# @return [SampleContext] if sid was passed.
|
|
279
|
+
def samples(sid=:unset)
|
|
280
|
+
raise ArgumentError, 'sid cannot be nil' if sid.nil?
|
|
281
|
+
|
|
282
|
+
if sid != :unset
|
|
283
|
+
return SampleContext.new(@version, @solution[:assistant_sid], @solution[:sid], sid, )
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
unless @samples
|
|
287
|
+
@samples = SampleList.new(
|
|
288
|
+
@version,
|
|
289
|
+
assistant_sid: @solution[:assistant_sid],
|
|
290
|
+
task_sid: @solution[:sid],
|
|
291
|
+
)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
@samples
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
##
|
|
298
|
+
# Access the task_actions
|
|
299
|
+
# @return [TaskActionsList]
|
|
300
|
+
# @return [TaskActionsContext]
|
|
301
|
+
def task_actions
|
|
302
|
+
TaskActionsContext.new(@version, @solution[:assistant_sid], @solution[:sid], )
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
##
|
|
306
|
+
# Access the statistics
|
|
307
|
+
# @return [TaskStatisticsList]
|
|
308
|
+
# @return [TaskStatisticsContext]
|
|
309
|
+
def statistics
|
|
310
|
+
TaskStatisticsContext.new(@version, @solution[:assistant_sid], @solution[:sid], )
|
|
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.Preview.Understand.TaskContext #{context}>"
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
##
|
|
322
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
|
323
|
+
class TaskInstance < InstanceResource
|
|
324
|
+
##
|
|
325
|
+
# Initialize the TaskInstance
|
|
326
|
+
# @param [Version] version Version that contains the resource
|
|
327
|
+
# @param [Hash] payload payload that contains response from Twilio
|
|
328
|
+
# @param [String] assistant_sid The unique ID of the Assistant.
|
|
329
|
+
# @param [String] sid A 34 character string that uniquely identifies this
|
|
330
|
+
# resource.
|
|
331
|
+
# @return [TaskInstance] TaskInstance
|
|
332
|
+
def initialize(version, payload, assistant_sid: nil, sid: nil)
|
|
333
|
+
super(version)
|
|
334
|
+
|
|
335
|
+
# Marshaled Properties
|
|
336
|
+
@properties = {
|
|
337
|
+
'account_sid' => payload['account_sid'],
|
|
338
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
|
339
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
|
340
|
+
'friendly_name' => payload['friendly_name'],
|
|
341
|
+
'links' => payload['links'],
|
|
342
|
+
'assistant_sid' => payload['assistant_sid'],
|
|
343
|
+
'sid' => payload['sid'],
|
|
344
|
+
'unique_name' => payload['unique_name'],
|
|
345
|
+
'actions_url' => payload['actions_url'],
|
|
346
|
+
'url' => payload['url'],
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
# Context
|
|
350
|
+
@instance_context = nil
|
|
351
|
+
@params = {'assistant_sid' => assistant_sid, 'sid' => sid || @properties['sid'], }
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
##
|
|
355
|
+
# Generate an instance context for the instance, the context is capable of
|
|
356
|
+
# performing various actions. All instance actions are proxied to the context
|
|
357
|
+
# @return [TaskContext] TaskContext for this TaskInstance
|
|
358
|
+
def context
|
|
359
|
+
unless @instance_context
|
|
360
|
+
@instance_context = TaskContext.new(@version, @params['assistant_sid'], @params['sid'], )
|
|
361
|
+
end
|
|
362
|
+
@instance_context
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
##
|
|
366
|
+
# @return [String] The unique ID of the Account that created this Task.
|
|
367
|
+
def account_sid
|
|
368
|
+
@properties['account_sid']
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
##
|
|
372
|
+
# @return [Time] The date that this resource was created
|
|
373
|
+
def date_created
|
|
374
|
+
@properties['date_created']
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
##
|
|
378
|
+
# @return [Time] The date that this resource was last updated
|
|
379
|
+
def date_updated
|
|
380
|
+
@properties['date_updated']
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
##
|
|
384
|
+
# @return [String] A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.
|
|
385
|
+
def friendly_name
|
|
386
|
+
@properties['friendly_name']
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
##
|
|
390
|
+
# @return [String] The links
|
|
391
|
+
def links
|
|
392
|
+
@properties['links']
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
##
|
|
396
|
+
# @return [String] The unique ID of the Assistant.
|
|
397
|
+
def assistant_sid
|
|
398
|
+
@properties['assistant_sid']
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
##
|
|
402
|
+
# @return [String] A 34 character string that uniquely identifies this resource.
|
|
403
|
+
def sid
|
|
404
|
+
@properties['sid']
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
##
|
|
408
|
+
# @return [String] A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
|
|
409
|
+
def unique_name
|
|
410
|
+
@properties['unique_name']
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
##
|
|
414
|
+
# @return [String] User-provided HTTP endpoint where from the assistant fetches actions
|
|
415
|
+
def actions_url
|
|
416
|
+
@properties['actions_url']
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
##
|
|
420
|
+
# @return [String] The url
|
|
421
|
+
def url
|
|
422
|
+
@properties['url']
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
##
|
|
426
|
+
# Fetch a TaskInstance
|
|
427
|
+
# @return [TaskInstance] Fetched TaskInstance
|
|
428
|
+
def fetch
|
|
429
|
+
context.fetch
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
##
|
|
433
|
+
# Update the TaskInstance
|
|
434
|
+
# @param [String] friendly_name A user-provided string that identifies this
|
|
435
|
+
# resource. It is non-unique and can up to 255 characters long.
|
|
436
|
+
# @param [String] unique_name A user-provided string that uniquely identifies this
|
|
437
|
+
# resource as an alternative to the sid. Unique up to 64 characters long.
|
|
438
|
+
# @param [Hash] actions A user-provided JSON object encoded as a string to specify
|
|
439
|
+
# the actions for this task. It is optional and non-unique.
|
|
440
|
+
# @param [String] actions_url User-provided HTTP endpoint where from the assistant
|
|
441
|
+
# fetches actions
|
|
442
|
+
# @return [TaskInstance] Updated TaskInstance
|
|
443
|
+
def update(friendly_name: :unset, unique_name: :unset, actions: :unset, actions_url: :unset)
|
|
444
|
+
context.update(
|
|
445
|
+
friendly_name: friendly_name,
|
|
446
|
+
unique_name: unique_name,
|
|
447
|
+
actions: actions,
|
|
448
|
+
actions_url: actions_url,
|
|
449
|
+
)
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
##
|
|
453
|
+
# Deletes the TaskInstance
|
|
454
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
|
455
|
+
def delete
|
|
456
|
+
context.delete
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
##
|
|
460
|
+
# Access the fields
|
|
461
|
+
# @return [fields] fields
|
|
462
|
+
def fields
|
|
463
|
+
context.fields
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
##
|
|
467
|
+
# Access the samples
|
|
468
|
+
# @return [samples] samples
|
|
469
|
+
def samples
|
|
470
|
+
context.samples
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
##
|
|
474
|
+
# Access the task_actions
|
|
475
|
+
# @return [task_actions] task_actions
|
|
476
|
+
def task_actions
|
|
477
|
+
context.task_actions
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
##
|
|
481
|
+
# Access the statistics
|
|
482
|
+
# @return [statistics] statistics
|
|
483
|
+
def statistics
|
|
484
|
+
context.statistics
|
|
485
|
+
end
|
|
486
|
+
|
|
487
|
+
##
|
|
488
|
+
# Provide a user friendly representation
|
|
489
|
+
def to_s
|
|
490
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
|
491
|
+
"<Twilio.Preview.Understand.TaskInstance #{values}>"
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
##
|
|
495
|
+
# Provide a detailed, user friendly representation
|
|
496
|
+
def inspect
|
|
497
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
|
498
|
+
"<Twilio.Preview.Understand.TaskInstance #{values}>"
|
|
499
|
+
end
|
|
500
|
+
end
|
|
501
|
+
end
|
|
502
|
+
end
|
|
503
|
+
end
|
|
504
|
+
end
|
|
505
|
+
end
|