twilio-ruby 5.12.0 → 5.12.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.
@@ -1,350 +0,0 @@
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 Studio < Version
13
- class FlowContext < InstanceContext
14
- class EngagementContext < InstanceContext
15
- ##
16
- # 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.
17
- class StepList < ListResource
18
- ##
19
- # Initialize the StepList
20
- # @param [Version] version Version that contains the resource
21
- # @param [String] flow_sid The unique SID identifier of the Flow.
22
- # @param [String] engagement_sid The unique SID identifier of the Engagement.
23
- # @return [StepList] StepList
24
- def initialize(version, flow_sid: nil, engagement_sid: nil)
25
- super(version)
26
-
27
- # Path Solution
28
- @solution = {flow_sid: flow_sid, engagement_sid: engagement_sid}
29
- @uri = "/Flows/#{@solution[:flow_sid]}/Engagements/#{@solution[:engagement_sid]}/Steps"
30
- end
31
-
32
- ##
33
- # Lists StepInstance records from the API as a list.
34
- # Unlike stream(), this operation is eager and will load `limit` records into
35
- # memory before returning.
36
- # @param [Integer] limit Upper limit for the number of records to return. stream()
37
- # guarantees to never return more than limit. Default is no limit
38
- # @param [Integer] page_size Number of records to fetch per request, when
39
- # not set will use the default value of 50 records. If no page_size is defined
40
- # but a limit is defined, stream() will attempt to read the limit with the most
41
- # efficient page size, i.e. min(limit, 1000)
42
- # @return [Array] Array of up to limit results
43
- def list(limit: nil, page_size: nil)
44
- self.stream(limit: limit, page_size: page_size).entries
45
- end
46
-
47
- ##
48
- # Streams StepInstance records from the API as an Enumerable.
49
- # This operation lazily loads records as efficiently as possible until the limit
50
- # is reached.
51
- # @param [Integer] limit Upper limit for the number of records to return. stream()
52
- # guarantees to never return more than limit. Default is no limit.
53
- # @param [Integer] page_size Number of records to fetch per request, when
54
- # not set will use the default value of 50 records. If no page_size is defined
55
- # but a limit is defined, stream() will attempt to read the limit with the most
56
- # efficient page size, i.e. min(limit, 1000)
57
- # @return [Enumerable] Enumerable that will yield up to limit results
58
- def stream(limit: nil, page_size: nil)
59
- limits = @version.read_limits(limit, page_size)
60
-
61
- page = self.page(page_size: limits[:page_size], )
62
-
63
- @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
64
- end
65
-
66
- ##
67
- # When passed a block, yields StepInstance records from the API.
68
- # This operation lazily loads records as efficiently as possible until the limit
69
- # is reached.
70
- def each
71
- limits = @version.read_limits
72
-
73
- page = self.page(page_size: limits[:page_size], )
74
-
75
- @version.stream(page,
76
- limit: limits[:limit],
77
- page_limit: limits[:page_limit]).each {|x| yield x}
78
- end
79
-
80
- ##
81
- # Retrieve a single page of StepInstance records from the API.
82
- # Request is executed immediately.
83
- # @param [String] page_token PageToken provided by the API
84
- # @param [Integer] page_number Page Number, this value is simply for client state
85
- # @param [Integer] page_size Number of records to return, defaults to 50
86
- # @return [Page] Page of StepInstance
87
- def page(page_token: :unset, page_number: :unset, page_size: :unset)
88
- params = Twilio::Values.of({
89
- 'PageToken' => page_token,
90
- 'Page' => page_number,
91
- 'PageSize' => page_size,
92
- })
93
- response = @version.page(
94
- 'GET',
95
- @uri,
96
- params
97
- )
98
- StepPage.new(@version, response, @solution)
99
- end
100
-
101
- ##
102
- # Retrieve a single page of StepInstance records from the API.
103
- # Request is executed immediately.
104
- # @param [String] target_url API-generated URL for the requested results page
105
- # @return [Page] Page of StepInstance
106
- def get_page(target_url)
107
- response = @version.domain.request(
108
- 'GET',
109
- target_url
110
- )
111
- StepPage.new(@version, response, @solution)
112
- end
113
-
114
- ##
115
- # Provide a user friendly representation
116
- def to_s
117
- '#<Twilio.Preview.Studio.StepList>'
118
- end
119
- end
120
-
121
- ##
122
- # 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.
123
- class StepPage < Page
124
- ##
125
- # Initialize the StepPage
126
- # @param [Version] version Version that contains the resource
127
- # @param [Response] response Response from the API
128
- # @param [Hash] solution Path solution for the resource
129
- # @return [StepPage] StepPage
130
- def initialize(version, response, solution)
131
- super(version, response)
132
-
133
- # Path Solution
134
- @solution = solution
135
- end
136
-
137
- ##
138
- # Build an instance of StepInstance
139
- # @param [Hash] payload Payload response from the API
140
- # @return [StepInstance] StepInstance
141
- def get_instance(payload)
142
- StepInstance.new(
143
- @version,
144
- payload,
145
- flow_sid: @solution[:flow_sid],
146
- engagement_sid: @solution[:engagement_sid],
147
- )
148
- end
149
-
150
- ##
151
- # Provide a user friendly representation
152
- def to_s
153
- '<Twilio.Preview.Studio.StepPage>'
154
- end
155
- end
156
-
157
- ##
158
- # 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.
159
- class StepContext < InstanceContext
160
- ##
161
- # Initialize the StepContext
162
- # @param [Version] version Version that contains the resource
163
- # @param [String] flow_sid The flow_sid
164
- # @param [String] engagement_sid The engagement_sid
165
- # @param [String] sid The sid
166
- # @return [StepContext] StepContext
167
- def initialize(version, flow_sid, engagement_sid, sid)
168
- super(version)
169
-
170
- # Path Solution
171
- @solution = {flow_sid: flow_sid, engagement_sid: engagement_sid, sid: sid, }
172
- @uri = "/Flows/#{@solution[:flow_sid]}/Engagements/#{@solution[:engagement_sid]}/Steps/#{@solution[:sid]}"
173
- end
174
-
175
- ##
176
- # Fetch a StepInstance
177
- # @return [StepInstance] Fetched StepInstance
178
- def fetch
179
- params = Twilio::Values.of({})
180
-
181
- payload = @version.fetch(
182
- 'GET',
183
- @uri,
184
- params,
185
- )
186
-
187
- StepInstance.new(
188
- @version,
189
- payload,
190
- flow_sid: @solution[:flow_sid],
191
- engagement_sid: @solution[:engagement_sid],
192
- sid: @solution[:sid],
193
- )
194
- end
195
-
196
- ##
197
- # Provide a user friendly representation
198
- def to_s
199
- context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
200
- "#<Twilio.Preview.Studio.StepContext #{context}>"
201
- end
202
- end
203
-
204
- ##
205
- # 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.
206
- class StepInstance < InstanceResource
207
- ##
208
- # Initialize the StepInstance
209
- # @param [Version] version Version that contains the resource
210
- # @param [Hash] payload payload that contains response from Twilio
211
- # @param [String] flow_sid The unique SID identifier of the Flow.
212
- # @param [String] engagement_sid The unique SID identifier of the Engagement.
213
- # @param [String] sid The sid
214
- # @return [StepInstance] StepInstance
215
- def initialize(version, payload, flow_sid: nil, engagement_sid: nil, sid: nil)
216
- super(version)
217
-
218
- # Marshaled Properties
219
- @properties = {
220
- 'sid' => payload['sid'],
221
- 'account_sid' => payload['account_sid'],
222
- 'flow_sid' => payload['flow_sid'],
223
- 'engagement_sid' => payload['engagement_sid'],
224
- 'name' => payload['name'],
225
- 'context' => payload['context'],
226
- 'transitioned_from' => payload['transitioned_from'],
227
- 'transitioned_to' => payload['transitioned_to'],
228
- 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
229
- 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
230
- 'url' => payload['url'],
231
- }
232
-
233
- # Context
234
- @instance_context = nil
235
- @params = {
236
- 'flow_sid' => flow_sid,
237
- 'engagement_sid' => engagement_sid,
238
- 'sid' => sid || @properties['sid'],
239
- }
240
- end
241
-
242
- ##
243
- # Generate an instance context for the instance, the context is capable of
244
- # performing various actions. All instance actions are proxied to the context
245
- # @return [StepContext] StepContext for this StepInstance
246
- def context
247
- unless @instance_context
248
- @instance_context = StepContext.new(
249
- @version,
250
- @params['flow_sid'],
251
- @params['engagement_sid'],
252
- @params['sid'],
253
- )
254
- end
255
- @instance_context
256
- end
257
-
258
- ##
259
- # @return [String] A string that uniquely identifies this Step.
260
- def sid
261
- @properties['sid']
262
- end
263
-
264
- ##
265
- # @return [String] Account Sid.
266
- def account_sid
267
- @properties['account_sid']
268
- end
269
-
270
- ##
271
- # @return [String] Flow Sid.
272
- def flow_sid
273
- @properties['flow_sid']
274
- end
275
-
276
- ##
277
- # @return [String] Engagement Sid.
278
- def engagement_sid
279
- @properties['engagement_sid']
280
- end
281
-
282
- ##
283
- # @return [String] The Widget that implemented this Step.
284
- def name
285
- @properties['name']
286
- end
287
-
288
- ##
289
- # @return [Hash] Nested resource URLs.
290
- def context
291
- @properties['context']
292
- end
293
-
294
- ##
295
- # @return [String] The Widget that preceded the Widget for this Step.
296
- def transitioned_from
297
- @properties['transitioned_from']
298
- end
299
-
300
- ##
301
- # @return [String] The Widget that will follow the Widget for this Step.
302
- def transitioned_to
303
- @properties['transitioned_to']
304
- end
305
-
306
- ##
307
- # @return [Time] The date this Step was created
308
- def date_created
309
- @properties['date_created']
310
- end
311
-
312
- ##
313
- # @return [Time] The date this Step was updated
314
- def date_updated
315
- @properties['date_updated']
316
- end
317
-
318
- ##
319
- # @return [String] The URL of this resource.
320
- def url
321
- @properties['url']
322
- end
323
-
324
- ##
325
- # Fetch a StepInstance
326
- # @return [StepInstance] Fetched StepInstance
327
- def fetch
328
- context.fetch
329
- end
330
-
331
- ##
332
- # Provide a user friendly representation
333
- def to_s
334
- values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
335
- "<Twilio.Preview.Studio.StepInstance #{values}>"
336
- end
337
-
338
- ##
339
- # Provide a detailed, user friendly representation
340
- def inspect
341
- values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
342
- "<Twilio.Preview.Studio.StepInstance #{values}>"
343
- end
344
- end
345
- end
346
- end
347
- end
348
- end
349
- end
350
- end
@@ -1,98 +0,0 @@
1
- ##
2
- # This code was generated by
3
- # \ / _ _ _| _ _
4
- # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
- # / /
6
- #
7
- # frozen_string_literal: true
8
-
9
- require 'spec_helper.rb'
10
-
11
- describe 'Step' do
12
- it "can read" do
13
- @holodeck.mock(Twilio::Response.new(500, ''))
14
-
15
- expect {
16
- @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
17
- .engagements('FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
18
- .steps.list()
19
- }.to raise_exception(Twilio::REST::TwilioError)
20
-
21
- values = {}
22
- expect(
23
- @holodeck.has_request?(Holodeck::Request.new(
24
- method: 'get',
25
- url: 'https://preview.twilio.com/Studio/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Engagements/FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Steps',
26
- ))).to eq(true)
27
- end
28
-
29
- it "receives read_empty responses" do
30
- @holodeck.mock(Twilio::Response.new(
31
- 200,
32
- %q[
33
- {
34
- "meta": {
35
- "previous_page_url": null,
36
- "next_page_url": null,
37
- "url": "https://preview.twilio.com/Studio/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Steps?PageSize=50&Page=0",
38
- "page": 0,
39
- "first_page_url": "https://preview.twilio.com/Studio/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Steps?PageSize=50&Page=0",
40
- "page_size": 50,
41
- "key": "steps"
42
- },
43
- "steps": []
44
- }
45
- ]
46
- ))
47
-
48
- actual = @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
49
- .engagements('FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
50
- .steps.list()
51
-
52
- expect(actual).to_not eq(nil)
53
- end
54
-
55
- it "can fetch" do
56
- @holodeck.mock(Twilio::Response.new(500, ''))
57
-
58
- expect {
59
- @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
60
- .engagements('FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
61
- .steps('FTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
62
- }.to raise_exception(Twilio::REST::TwilioError)
63
-
64
- values = {}
65
- expect(
66
- @holodeck.has_request?(Holodeck::Request.new(
67
- method: 'get',
68
- url: 'https://preview.twilio.com/Studio/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Engagements/FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Steps/FTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
69
- ))).to eq(true)
70
- end
71
-
72
- it "receives fetch responses" do
73
- @holodeck.mock(Twilio::Response.new(
74
- 200,
75
- %q[
76
- {
77
- "sid": "FTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
78
- "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
79
- "flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
80
- "engagement_sid": "FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
81
- "name": "incomingRequest",
82
- "context": {},
83
- "transitioned_from": "Trigger",
84
- "transitioned_to": "Ended",
85
- "date_created": "2017-11-06T12:00:00Z",
86
- "date_updated": null,
87
- "url": "https://preview.twilio.com/Studio/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Steps/FTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
88
- }
89
- ]
90
- ))
91
-
92
- actual = @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
93
- .engagements('FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
94
- .steps('FTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
95
-
96
- expect(actual).to_not eq(nil)
97
- end
98
- end
@@ -1,145 +0,0 @@
1
- ##
2
- # This code was generated by
3
- # \ / _ _ _| _ _
4
- # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
- # / /
6
- #
7
- # frozen_string_literal: true
8
-
9
- require 'spec_helper.rb'
10
-
11
- describe 'Engagement' do
12
- it "can read" do
13
- @holodeck.mock(Twilio::Response.new(500, ''))
14
-
15
- expect {
16
- @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
17
- .engagements.list()
18
- }.to raise_exception(Twilio::REST::TwilioError)
19
-
20
- values = {}
21
- expect(
22
- @holodeck.has_request?(Holodeck::Request.new(
23
- method: 'get',
24
- url: 'https://preview.twilio.com/Studio/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Engagements',
25
- ))).to eq(true)
26
- end
27
-
28
- it "receives read_empty responses" do
29
- @holodeck.mock(Twilio::Response.new(
30
- 200,
31
- %q[
32
- {
33
- "meta": {
34
- "previous_page_url": null,
35
- "next_page_url": null,
36
- "url": "https://preview.twilio.com/Studio/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements?PageSize=50&Page=0",
37
- "page": 0,
38
- "first_page_url": "https://preview.twilio.com/Studio/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements?PageSize=50&Page=0",
39
- "page_size": 50,
40
- "key": "engagements"
41
- },
42
- "engagements": []
43
- }
44
- ]
45
- ))
46
-
47
- actual = @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
48
- .engagements.list()
49
-
50
- expect(actual).to_not eq(nil)
51
- end
52
-
53
- it "can fetch" do
54
- @holodeck.mock(Twilio::Response.new(500, ''))
55
-
56
- expect {
57
- @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
58
- .engagements('FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
59
- }.to raise_exception(Twilio::REST::TwilioError)
60
-
61
- values = {}
62
- expect(
63
- @holodeck.has_request?(Holodeck::Request.new(
64
- method: 'get',
65
- url: 'https://preview.twilio.com/Studio/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Engagements/FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
66
- ))).to eq(true)
67
- end
68
-
69
- it "receives fetch responses" do
70
- @holodeck.mock(Twilio::Response.new(
71
- 200,
72
- %q[
73
- {
74
- "sid": "FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
75
- "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
76
- "flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
77
- "contact_sid": "FCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
78
- "contact_channel_address": "+14155555555",
79
- "status": "ended",
80
- "context": {},
81
- "date_created": "2017-11-06T12:00:00Z",
82
- "date_updated": null,
83
- "url": "https://preview.twilio.com/Studio/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
84
- "links": {
85
- "steps": "https://preview.twilio.com/Studio/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Steps"
86
- }
87
- }
88
- ]
89
- ))
90
-
91
- actual = @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
92
- .engagements('FNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch()
93
-
94
- expect(actual).to_not eq(nil)
95
- end
96
-
97
- it "can create" do
98
- @holodeck.mock(Twilio::Response.new(500, ''))
99
-
100
- expect {
101
- @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
102
- .engagements.create(to: '+15558675310', from: '+15017122661')
103
- }.to raise_exception(Twilio::REST::TwilioError)
104
-
105
- values = {'To' => '+15558675310', 'From' => '+15017122661', }
106
- expect(
107
- @holodeck.has_request?(Holodeck::Request.new(
108
- method: 'post',
109
- url: 'https://preview.twilio.com/Studio/Flows/FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Engagements',
110
- data: values,
111
- ))).to eq(true)
112
- end
113
-
114
- it "receives create responses" do
115
- @holodeck.mock(Twilio::Response.new(
116
- 201,
117
- %q[
118
- {
119
- "url": "https://preview.twilio.com/Studio/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
120
- "sid": "FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
121
- "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
122
- "flow_sid": "FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
123
- "context": {
124
- "flow": {
125
- "first_name": "Foo"
126
- }
127
- },
128
- "contact_sid": "FCaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
129
- "contact_channel_address": "+18001234567",
130
- "status": "active",
131
- "date_created": "2015-07-30T20:00:00Z",
132
- "date_updated": "2015-07-30T20:00:00Z",
133
- "links": {
134
- "steps": "https://preview.twilio.com/Studio/Flows/FWaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Engagements/FNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Steps"
135
- }
136
- }
137
- ]
138
- ))
139
-
140
- actual = @client.preview.studio.flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') \
141
- .engagements.create(to: '+15558675310', from: '+15017122661')
142
-
143
- expect(actual).to_not eq(nil)
144
- end
145
- end