Class: Twilio::REST::Studio::V2::FlowContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/studio/v2/flow.rb,
lib/twilio-ruby/rest/studio/v2/flow/execution.rb,
lib/twilio-ruby/rest/studio/v2/flow/flow_revision.rb,
lib/twilio-ruby/rest/studio/v2/flow/flow_test_user.rb,
lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb,
lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb,
lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb

Defined Under Namespace

Classes: ExecutionContext, ExecutionInstance, ExecutionList, ExecutionPage, FlowRevisionContext, FlowRevisionInstance, FlowRevisionList, FlowRevisionPage, FlowTestUserContext, FlowTestUserInstance, FlowTestUserList, FlowTestUserPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ FlowContext

Initialize the FlowContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the Flow resource to fetch.



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 170

def initialize(version, sid)
    super(version)

    # Path Solution
    @solution = { sid: sid,  }
    @uri = "/Flows/#{@solution[:sid]}"

    # Dependents
    @executions = nil
    @test_users = nil
    @revisions = nil
end

Instance Method Details

#deleteBoolean

Delete the FlowInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



185
186
187
188
189
190
191
192
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 185

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#executions(sid = :unset) ⇒ ExecutionList, ExecutionContext

Access the executions

Returns:

Raises:

  • (ArgumentError)


252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 252

def executions(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return ExecutionContext.new(@version, @solution[:sid],sid )
    end

    unless @executions
        @executions = ExecutionList.new(
            @version, flow_sid: @solution[:sid], )
    end

 @executions
end

#fetchFlowInstance

Fetch the FlowInstance

Returns:



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 197

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    FlowInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



306
307
308
309
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 306

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Studio.V2.FlowContext #{context}>"
end

#revisions(revision = :unset) ⇒ FlowRevisionList, FlowRevisionContext

Access the revisions

Returns:

Raises:

  • (ArgumentError)


281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 281

def revisions(revision=:unset)

    raise ArgumentError, 'revision cannot be nil' if revision.nil?

    if revision != :unset
        return FlowRevisionContext.new(@version, @solution[:sid],revision )
    end

    unless @revisions
        @revisions = FlowRevisionList.new(
            @version, sid: @solution[:sid], )
    end

 @revisions
end

#test_usersFlowTestUserList, FlowTestUserContext

Access the test_users



271
272
273
274
275
276
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 271

def test_users
    FlowTestUserContext.new(
            @version,
            @solution[:sid]
            )
end

#to_sObject

Provide a user friendly representation



299
300
301
302
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 299

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Studio.V2.FlowContext #{context}>"
end

#update(status: nil, friendly_name: :unset, definition: :unset, commit_message: :unset) ⇒ FlowInstance

Update the FlowInstance

Parameters:

  • status (Status) (defaults to: nil)
  • friendly_name (String) (defaults to: :unset)

    The string that you assigned to describe the Flow.

  • definition (Object) (defaults to: :unset)

    JSON representation of flow definition.

  • commit_message (String) (defaults to: :unset)

    Description of change made in the revision.

Returns:



220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 220

def update(
    status: nil, 
    friendly_name: :unset, 
    definition: :unset, 
    commit_message: :unset
)

    data = Twilio::Values.of({
        'Status' => status,
        'FriendlyName' => friendly_name,
        'Definition' => Twilio.serialize_object(definition),
        'CommitMessage' => commit_message,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    FlowInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end