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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +33 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +2 -1
  5. data/lib/twilio-ruby/rest/authy.rb +55 -0
  6. data/lib/twilio-ruby/rest/authy/v1.rb +59 -0
  7. data/lib/twilio-ruby/rest/authy/v1/form.rb +190 -0
  8. data/lib/twilio-ruby/rest/authy/v1/service.rb +378 -0
  9. data/lib/twilio-ruby/rest/authy/v1/service/entity.rb +372 -0
  10. data/lib/twilio-ruby/rest/authy/v1/service/entity/factor.rb +474 -0
  11. data/lib/twilio-ruby/rest/authy/v1/service/entity/factor/challenge.rb +405 -0
  12. data/lib/twilio-ruby/rest/autopilot.rb +47 -0
  13. data/lib/twilio-ruby/rest/autopilot/v1.rb +43 -0
  14. data/lib/twilio-ruby/rest/autopilot/v1/assistant.rb +606 -0
  15. data/lib/twilio-ruby/rest/autopilot/v1/assistant/defaults.rb +215 -0
  16. data/lib/twilio-ruby/rest/autopilot/v1/assistant/dialogue.rb +205 -0
  17. data/lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb +417 -0
  18. data/lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.rb +393 -0
  19. data/lib/twilio-ruby/rest/autopilot/v1/assistant/model_build.rb +390 -0
  20. data/lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb +443 -0
  21. data/lib/twilio-ruby/rest/autopilot/v1/assistant/style_sheet.rb +215 -0
  22. data/lib/twilio-ruby/rest/{preview/understand/assistant/intent.rb → autopilot/v1/assistant/task.rb} +91 -84
  23. data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/field.rb +377 -0
  24. data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/sample.rb +442 -0
  25. data/lib/twilio-ruby/rest/autopilot/v1/assistant/task/task_actions.rb +244 -0
  26. data/lib/twilio-ruby/rest/{preview/understand/assistant/intent/intent_statistics.rb → autopilot/v1/assistant/task/task_statistics.rb} +49 -51
  27. data/lib/twilio-ruby/rest/chat/v1/service.rb +1 -1
  28. data/lib/twilio-ruby/rest/chat/v2/service/channel.rb +12 -6
  29. data/lib/twilio-ruby/rest/client.rb +14 -0
  30. data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +1 -1
  31. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +12 -6
  32. data/lib/twilio-ruby/rest/preview/understand.rb +2 -1
  33. data/lib/twilio-ruby/rest/preview/understand/assistant.rb +59 -29
  34. data/lib/twilio-ruby/rest/preview/understand/assistant/query.rb +17 -13
  35. data/lib/twilio-ruby/rest/preview/understand/assistant/style_sheet.rb +215 -0
  36. data/lib/twilio-ruby/rest/preview/understand/assistant/task.rb +505 -0
  37. data/lib/twilio-ruby/rest/preview/understand/assistant/{intent → task}/field.rb +25 -25
  38. data/lib/twilio-ruby/rest/preview/understand/assistant/{intent → task}/sample.rb +30 -30
  39. data/lib/twilio-ruby/rest/preview/understand/assistant/{intent/intent_actions.rb → task/task_actions.rb} +50 -54
  40. data/lib/twilio-ruby/rest/preview/understand/assistant/task/task_statistics.rb +224 -0
  41. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +7 -7
  42. data/lib/twilio-ruby/rest/verify/v1/service.rb +45 -6
  43. data/lib/twilio-ruby/rest/verify/v1/service/verification.rb +9 -2
  44. data/lib/twilio-ruby/rest/wireless/v1/command.rb +32 -5
  45. data/lib/twilio-ruby/twiml/voice_response.rb +66 -5
  46. data/lib/twilio-ruby/version.rb +1 -1
  47. data/spec/integration/api/v2010/account/call/recording_spec.rb +3 -3
  48. data/spec/integration/api/v2010/account/conference/participant_spec.rb +42 -1
  49. data/spec/integration/api/v2010/account/conference/recording_spec.rb +2 -2
  50. data/spec/integration/authy/v1/form_spec.rb +48 -0
  51. data/spec/integration/authy/v1/service/entity/factor/challenge_spec.rb +267 -0
  52. data/spec/integration/authy/v1/service/entity/factor_spec.rb +269 -0
  53. data/spec/integration/authy/v1/service/entity_spec.rb +201 -0
  54. data/spec/integration/authy/v1/service_spec.rb +227 -0
  55. data/spec/integration/autopilot/v1/assistant/defaults_spec.rb +81 -0
  56. data/spec/integration/autopilot/v1/assistant/dialogue_spec.rb +47 -0
  57. data/spec/integration/autopilot/v1/assistant/field_type/field_value_spec.rb +210 -0
  58. data/spec/integration/autopilot/v1/assistant/field_type_spec.rb +246 -0
  59. data/spec/integration/autopilot/v1/assistant/model_build_spec.rb +241 -0
  60. data/spec/integration/autopilot/v1/assistant/query_spec.rb +306 -0
  61. data/spec/integration/autopilot/v1/assistant/style_sheet_spec.rb +81 -0
  62. data/spec/integration/autopilot/v1/assistant/task/field_spec.rb +207 -0
  63. data/spec/integration/autopilot/v1/assistant/task/sample_spec.rb +253 -0
  64. data/spec/integration/autopilot/v1/assistant/task/task_actions_spec.rb +87 -0
  65. data/spec/integration/autopilot/v1/assistant/task/task_statistics_spec.rb +50 -0
  66. data/spec/integration/autopilot/v1/assistant/task_spec.rb +262 -0
  67. data/spec/integration/autopilot/v1/assistant_spec.rb +270 -0
  68. data/spec/integration/preview/understand/assistant/query_spec.rb +8 -8
  69. data/spec/integration/preview/understand/assistant/style_sheet_spec.rb +81 -0
  70. data/spec/integration/preview/understand/assistant/{intent → task}/field_spec.rb +23 -23
  71. data/spec/integration/preview/understand/assistant/{intent → task}/sample_spec.rb +28 -28
  72. data/spec/integration/preview/understand/assistant/{intent/intent_actions_spec.rb → task/task_actions_spec.rb} +15 -15
  73. data/spec/integration/preview/understand/assistant/{intent/intent_statistics_spec.rb → task/task_statistics_spec.rb} +6 -6
  74. data/spec/integration/preview/understand/assistant/{intent_spec.rb → task_spec.rb} +53 -49
  75. data/spec/integration/preview/understand/assistant_spec.rb +12 -8
  76. data/spec/integration/taskrouter/v1/workspace/task_queue_spec.rb +3 -7
  77. data/spec/integration/verify/v1/service_spec.rb +30 -0
  78. data/spec/integration/wireless/v1/command_spec.rb +99 -2
  79. data/spec/twiml/voice_response_spec.rb +25 -2
  80. metadata +78 -17
@@ -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 Autopilot < Domain
12
+ class V1 < 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 DefaultsList < ListResource
17
+ ##
18
+ # Initialize the DefaultsList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] assistant_sid The assistant_sid
21
+ # @return [DefaultsList] DefaultsList
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.Autopilot.V1.DefaultsList>'
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 DefaultsPage < Page
39
+ ##
40
+ # Initialize the DefaultsPage
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 [DefaultsPage] DefaultsPage
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 DefaultsInstance
54
+ # @param [Hash] payload Payload response from the API
55
+ # @return [DefaultsInstance] DefaultsInstance
56
+ def get_instance(payload)
57
+ DefaultsInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
58
+ end
59
+
60
+ ##
61
+ # Provide a user friendly representation
62
+ def to_s
63
+ '<Twilio.Autopilot.V1.DefaultsPage>'
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 DefaultsContext < InstanceContext
70
+ ##
71
+ # Initialize the DefaultsContext
72
+ # @param [Version] version Version that contains the resource
73
+ # @param [String] assistant_sid The assistant_sid
74
+ # @return [DefaultsContext] DefaultsContext
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]}/Defaults"
81
+ end
82
+
83
+ ##
84
+ # Fetch a DefaultsInstance
85
+ # @return [DefaultsInstance] Fetched DefaultsInstance
86
+ def fetch
87
+ params = Twilio::Values.of({})
88
+
89
+ payload = @version.fetch(
90
+ 'GET',
91
+ @uri,
92
+ params,
93
+ )
94
+
95
+ DefaultsInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
96
+ end
97
+
98
+ ##
99
+ # Update the DefaultsInstance
100
+ # @param [Hash] defaults The defaults
101
+ # @return [DefaultsInstance] Updated DefaultsInstance
102
+ def update(defaults: :unset)
103
+ data = Twilio::Values.of({'Defaults' => Twilio.serialize_object(defaults), })
104
+
105
+ payload = @version.update(
106
+ 'POST',
107
+ @uri,
108
+ data: data,
109
+ )
110
+
111
+ DefaultsInstance.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.Autopilot.V1.DefaultsContext #{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 DefaultsInstance < InstanceResource
125
+ ##
126
+ # Initialize the DefaultsInstance
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 assistant_sid
130
+ # @return [DefaultsInstance] DefaultsInstance
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 [DefaultsContext] DefaultsContext for this DefaultsInstance
151
+ def context
152
+ unless @instance_context
153
+ @instance_context = DefaultsContext.new(@version, @params['assistant_sid'], )
154
+ end
155
+ @instance_context
156
+ end
157
+
158
+ ##
159
+ # @return [String] The account_sid
160
+ def account_sid
161
+ @properties['account_sid']
162
+ end
163
+
164
+ ##
165
+ # @return [String] The assistant_sid
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 data
178
+ def data
179
+ @properties['data']
180
+ end
181
+
182
+ ##
183
+ # Fetch a DefaultsInstance
184
+ # @return [DefaultsInstance] Fetched DefaultsInstance
185
+ def fetch
186
+ context.fetch
187
+ end
188
+
189
+ ##
190
+ # Update the DefaultsInstance
191
+ # @param [Hash] defaults The defaults
192
+ # @return [DefaultsInstance] Updated DefaultsInstance
193
+ def update(defaults: :unset)
194
+ context.update(defaults: defaults, )
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.Autopilot.V1.DefaultsInstance #{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.Autopilot.V1.DefaultsInstance #{values}>"
209
+ end
210
+ end
211
+ end
212
+ end
213
+ end
214
+ end
215
+ end
@@ -0,0 +1,205 @@
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 Autopilot < Domain
12
+ class V1 < 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 DialogueList < ListResource
17
+ ##
18
+ # Initialize the DialogueList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] assistant_sid The unique ID of the parent Assistant.
21
+ # @return [DialogueList] DialogueList
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.Autopilot.V1.DialogueList>'
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 DialoguePage < Page
39
+ ##
40
+ # Initialize the DialoguePage
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 [DialoguePage] DialoguePage
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 DialogueInstance
54
+ # @param [Hash] payload Payload response from the API
55
+ # @return [DialogueInstance] DialogueInstance
56
+ def get_instance(payload)
57
+ DialogueInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
58
+ end
59
+
60
+ ##
61
+ # Provide a user friendly representation
62
+ def to_s
63
+ '<Twilio.Autopilot.V1.DialoguePage>'
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 DialogueContext < InstanceContext
70
+ ##
71
+ # Initialize the DialogueContext
72
+ # @param [Version] version Version that contains the resource
73
+ # @param [String] assistant_sid The assistant_sid
74
+ # @param [String] sid The sid
75
+ # @return [DialogueContext] DialogueContext
76
+ def initialize(version, assistant_sid, sid)
77
+ super(version)
78
+
79
+ # Path Solution
80
+ @solution = {assistant_sid: assistant_sid, sid: sid, }
81
+ @uri = "/Assistants/#{@solution[:assistant_sid]}/Dialogues/#{@solution[:sid]}"
82
+ end
83
+
84
+ ##
85
+ # Fetch a DialogueInstance
86
+ # @return [DialogueInstance] Fetched DialogueInstance
87
+ def fetch
88
+ params = Twilio::Values.of({})
89
+
90
+ payload = @version.fetch(
91
+ 'GET',
92
+ @uri,
93
+ params,
94
+ )
95
+
96
+ DialogueInstance.new(
97
+ @version,
98
+ payload,
99
+ assistant_sid: @solution[:assistant_sid],
100
+ sid: @solution[:sid],
101
+ )
102
+ end
103
+
104
+ ##
105
+ # Provide a user friendly representation
106
+ def to_s
107
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
108
+ "#<Twilio.Autopilot.V1.DialogueContext #{context}>"
109
+ end
110
+ end
111
+
112
+ ##
113
+ # 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.
114
+ class DialogueInstance < InstanceResource
115
+ ##
116
+ # Initialize the DialogueInstance
117
+ # @param [Version] version Version that contains the resource
118
+ # @param [Hash] payload payload that contains response from Twilio
119
+ # @param [String] assistant_sid The unique ID of the parent Assistant.
120
+ # @param [String] sid The sid
121
+ # @return [DialogueInstance] DialogueInstance
122
+ def initialize(version, payload, assistant_sid: nil, sid: nil)
123
+ super(version)
124
+
125
+ # Marshaled Properties
126
+ @properties = {
127
+ 'account_sid' => payload['account_sid'],
128
+ 'assistant_sid' => payload['assistant_sid'],
129
+ 'sid' => payload['sid'],
130
+ 'data' => payload['data'],
131
+ 'url' => payload['url'],
132
+ }
133
+
134
+ # Context
135
+ @instance_context = nil
136
+ @params = {'assistant_sid' => assistant_sid, 'sid' => sid || @properties['sid'], }
137
+ end
138
+
139
+ ##
140
+ # Generate an instance context for the instance, the context is capable of
141
+ # performing various actions. All instance actions are proxied to the context
142
+ # @return [DialogueContext] DialogueContext for this DialogueInstance
143
+ def context
144
+ unless @instance_context
145
+ @instance_context = DialogueContext.new(@version, @params['assistant_sid'], @params['sid'], )
146
+ end
147
+ @instance_context
148
+ end
149
+
150
+ ##
151
+ # @return [String] The unique ID of the Account that created this Field.
152
+ def account_sid
153
+ @properties['account_sid']
154
+ end
155
+
156
+ ##
157
+ # @return [String] The unique ID of the parent Assistant.
158
+ def assistant_sid
159
+ @properties['assistant_sid']
160
+ end
161
+
162
+ ##
163
+ # @return [String] The unique ID of the Dialogue
164
+ def sid
165
+ @properties['sid']
166
+ end
167
+
168
+ ##
169
+ # @return [Hash] The dialogue session object as json
170
+ def data
171
+ @properties['data']
172
+ end
173
+
174
+ ##
175
+ # @return [String] The url
176
+ def url
177
+ @properties['url']
178
+ end
179
+
180
+ ##
181
+ # Fetch a DialogueInstance
182
+ # @return [DialogueInstance] Fetched DialogueInstance
183
+ def fetch
184
+ context.fetch
185
+ end
186
+
187
+ ##
188
+ # Provide a user friendly representation
189
+ def to_s
190
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
191
+ "<Twilio.Autopilot.V1.DialogueInstance #{values}>"
192
+ end
193
+
194
+ ##
195
+ # Provide a detailed, user friendly representation
196
+ def inspect
197
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
198
+ "<Twilio.Autopilot.V1.DialogueInstance #{values}>"
199
+ end
200
+ end
201
+ end
202
+ end
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,417 @@
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 Autopilot < Domain
12
+ class V1 < 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 FieldTypeList < ListResource
17
+ ##
18
+ # Initialize the FieldTypeList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] assistant_sid The unique ID of the Assistant.
21
+ # @return [FieldTypeList] FieldTypeList
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]}/FieldTypes"
28
+ end
29
+
30
+ ##
31
+ # Lists FieldTypeInstance 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 FieldTypeInstance 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 FieldTypeInstance 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 FieldTypeInstance 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 FieldTypeInstance
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
+ FieldTypePage.new(@version, response, @solution)
97
+ end
98
+
99
+ ##
100
+ # Retrieve a single page of FieldTypeInstance 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 FieldTypeInstance
104
+ def get_page(target_url)
105
+ response = @version.domain.request(
106
+ 'GET',
107
+ target_url
108
+ )
109
+ FieldTypePage.new(@version, response, @solution)
110
+ end
111
+
112
+ ##
113
+ # Retrieve a single page of FieldTypeInstance 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 be up to 255 characters long.
119
+ # @return [FieldTypeInstance] Newly created FieldTypeInstance
120
+ def create(unique_name: nil, friendly_name: :unset)
121
+ data = Twilio::Values.of({'UniqueName' => unique_name, 'FriendlyName' => friendly_name, })
122
+
123
+ payload = @version.create(
124
+ 'POST',
125
+ @uri,
126
+ data: data
127
+ )
128
+
129
+ FieldTypeInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
130
+ end
131
+
132
+ ##
133
+ # Provide a user friendly representation
134
+ def to_s
135
+ '#<Twilio.Autopilot.V1.FieldTypeList>'
136
+ end
137
+ end
138
+
139
+ ##
140
+ # 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.
141
+ class FieldTypePage < Page
142
+ ##
143
+ # Initialize the FieldTypePage
144
+ # @param [Version] version Version that contains the resource
145
+ # @param [Response] response Response from the API
146
+ # @param [Hash] solution Path solution for the resource
147
+ # @return [FieldTypePage] FieldTypePage
148
+ def initialize(version, response, solution)
149
+ super(version, response)
150
+
151
+ # Path Solution
152
+ @solution = solution
153
+ end
154
+
155
+ ##
156
+ # Build an instance of FieldTypeInstance
157
+ # @param [Hash] payload Payload response from the API
158
+ # @return [FieldTypeInstance] FieldTypeInstance
159
+ def get_instance(payload)
160
+ FieldTypeInstance.new(@version, payload, assistant_sid: @solution[:assistant_sid], )
161
+ end
162
+
163
+ ##
164
+ # Provide a user friendly representation
165
+ def to_s
166
+ '<Twilio.Autopilot.V1.FieldTypePage>'
167
+ end
168
+ end
169
+
170
+ ##
171
+ # 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.
172
+ class FieldTypeContext < InstanceContext
173
+ ##
174
+ # Initialize the FieldTypeContext
175
+ # @param [Version] version Version that contains the resource
176
+ # @param [String] assistant_sid The assistant_sid
177
+ # @param [String] sid The sid
178
+ # @return [FieldTypeContext] FieldTypeContext
179
+ def initialize(version, assistant_sid, sid)
180
+ super(version)
181
+
182
+ # Path Solution
183
+ @solution = {assistant_sid: assistant_sid, sid: sid, }
184
+ @uri = "/Assistants/#{@solution[:assistant_sid]}/FieldTypes/#{@solution[:sid]}"
185
+
186
+ # Dependents
187
+ @field_values = nil
188
+ end
189
+
190
+ ##
191
+ # Fetch a FieldTypeInstance
192
+ # @return [FieldTypeInstance] Fetched FieldTypeInstance
193
+ def fetch
194
+ params = Twilio::Values.of({})
195
+
196
+ payload = @version.fetch(
197
+ 'GET',
198
+ @uri,
199
+ params,
200
+ )
201
+
202
+ FieldTypeInstance.new(
203
+ @version,
204
+ payload,
205
+ assistant_sid: @solution[:assistant_sid],
206
+ sid: @solution[:sid],
207
+ )
208
+ end
209
+
210
+ ##
211
+ # Update the FieldTypeInstance
212
+ # @param [String] friendly_name A user-provided string that identifies this
213
+ # resource. It is non-unique and can be up to 255 characters long.
214
+ # @param [String] unique_name A user-provided string that uniquely identifies this
215
+ # resource as an alternative to the sid. Unique up to 64 characters long.
216
+ # @return [FieldTypeInstance] Updated FieldTypeInstance
217
+ def update(friendly_name: :unset, unique_name: :unset)
218
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, 'UniqueName' => unique_name, })
219
+
220
+ payload = @version.update(
221
+ 'POST',
222
+ @uri,
223
+ data: data,
224
+ )
225
+
226
+ FieldTypeInstance.new(
227
+ @version,
228
+ payload,
229
+ assistant_sid: @solution[:assistant_sid],
230
+ sid: @solution[:sid],
231
+ )
232
+ end
233
+
234
+ ##
235
+ # Deletes the FieldTypeInstance
236
+ # @return [Boolean] true if delete succeeds, true otherwise
237
+ def delete
238
+ @version.delete('delete', @uri)
239
+ end
240
+
241
+ ##
242
+ # Access the field_values
243
+ # @return [FieldValueList]
244
+ # @return [FieldValueContext] if sid was passed.
245
+ def field_values(sid=:unset)
246
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
247
+
248
+ if sid != :unset
249
+ return FieldValueContext.new(@version, @solution[:assistant_sid], @solution[:sid], sid, )
250
+ end
251
+
252
+ unless @field_values
253
+ @field_values = FieldValueList.new(
254
+ @version,
255
+ assistant_sid: @solution[:assistant_sid],
256
+ field_type_sid: @solution[:sid],
257
+ )
258
+ end
259
+
260
+ @field_values
261
+ end
262
+
263
+ ##
264
+ # Provide a user friendly representation
265
+ def to_s
266
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
267
+ "#<Twilio.Autopilot.V1.FieldTypeContext #{context}>"
268
+ end
269
+ end
270
+
271
+ ##
272
+ # 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.
273
+ class FieldTypeInstance < InstanceResource
274
+ ##
275
+ # Initialize the FieldTypeInstance
276
+ # @param [Version] version Version that contains the resource
277
+ # @param [Hash] payload payload that contains response from Twilio
278
+ # @param [String] assistant_sid The unique ID of the Assistant.
279
+ # @param [String] sid The sid
280
+ # @return [FieldTypeInstance] FieldTypeInstance
281
+ def initialize(version, payload, assistant_sid: nil, sid: nil)
282
+ super(version)
283
+
284
+ # Marshaled Properties
285
+ @properties = {
286
+ 'account_sid' => payload['account_sid'],
287
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
288
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
289
+ 'friendly_name' => payload['friendly_name'],
290
+ 'links' => payload['links'],
291
+ 'assistant_sid' => payload['assistant_sid'],
292
+ 'sid' => payload['sid'],
293
+ 'unique_name' => payload['unique_name'],
294
+ 'url' => payload['url'],
295
+ }
296
+
297
+ # Context
298
+ @instance_context = nil
299
+ @params = {'assistant_sid' => assistant_sid, 'sid' => sid || @properties['sid'], }
300
+ end
301
+
302
+ ##
303
+ # Generate an instance context for the instance, the context is capable of
304
+ # performing various actions. All instance actions are proxied to the context
305
+ # @return [FieldTypeContext] FieldTypeContext for this FieldTypeInstance
306
+ def context
307
+ unless @instance_context
308
+ @instance_context = FieldTypeContext.new(@version, @params['assistant_sid'], @params['sid'], )
309
+ end
310
+ @instance_context
311
+ end
312
+
313
+ ##
314
+ # @return [String] The unique ID of the Account that created this Field Type.
315
+ def account_sid
316
+ @properties['account_sid']
317
+ end
318
+
319
+ ##
320
+ # @return [Time] The date that this resource was created
321
+ def date_created
322
+ @properties['date_created']
323
+ end
324
+
325
+ ##
326
+ # @return [Time] The date that this resource was last updated
327
+ def date_updated
328
+ @properties['date_updated']
329
+ end
330
+
331
+ ##
332
+ # @return [String] A user-provided string that identifies this resource. It is non-unique and can be up to 255 characters long.
333
+ def friendly_name
334
+ @properties['friendly_name']
335
+ end
336
+
337
+ ##
338
+ # @return [String] The links
339
+ def links
340
+ @properties['links']
341
+ end
342
+
343
+ ##
344
+ # @return [String] The unique ID of the Assistant.
345
+ def assistant_sid
346
+ @properties['assistant_sid']
347
+ end
348
+
349
+ ##
350
+ # @return [String] A 34 character string that uniquely identifies this resource.
351
+ def sid
352
+ @properties['sid']
353
+ end
354
+
355
+ ##
356
+ # @return [String] A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.
357
+ def unique_name
358
+ @properties['unique_name']
359
+ end
360
+
361
+ ##
362
+ # @return [String] The url
363
+ def url
364
+ @properties['url']
365
+ end
366
+
367
+ ##
368
+ # Fetch a FieldTypeInstance
369
+ # @return [FieldTypeInstance] Fetched FieldTypeInstance
370
+ def fetch
371
+ context.fetch
372
+ end
373
+
374
+ ##
375
+ # Update the FieldTypeInstance
376
+ # @param [String] friendly_name A user-provided string that identifies this
377
+ # resource. It is non-unique and can be up to 255 characters long.
378
+ # @param [String] unique_name A user-provided string that uniquely identifies this
379
+ # resource as an alternative to the sid. Unique up to 64 characters long.
380
+ # @return [FieldTypeInstance] Updated FieldTypeInstance
381
+ def update(friendly_name: :unset, unique_name: :unset)
382
+ context.update(friendly_name: friendly_name, unique_name: unique_name, )
383
+ end
384
+
385
+ ##
386
+ # Deletes the FieldTypeInstance
387
+ # @return [Boolean] true if delete succeeds, true otherwise
388
+ def delete
389
+ context.delete
390
+ end
391
+
392
+ ##
393
+ # Access the field_values
394
+ # @return [field_values] field_values
395
+ def field_values
396
+ context.field_values
397
+ end
398
+
399
+ ##
400
+ # Provide a user friendly representation
401
+ def to_s
402
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
403
+ "<Twilio.Autopilot.V1.FieldTypeInstance #{values}>"
404
+ end
405
+
406
+ ##
407
+ # Provide a detailed, user friendly representation
408
+ def inspect
409
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
410
+ "<Twilio.Autopilot.V1.FieldTypeInstance #{values}>"
411
+ end
412
+ end
413
+ end
414
+ end
415
+ end
416
+ end
417
+ end