Class: Twilio::REST::Studio::V2::FlowInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/studio/v2/flow.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ FlowInstance

Initialize the FlowInstance

Parameters:

  • version (Version) —

    Version that contains the resource

  • payload (Hash) —

    payload that contains response from Twilio

  • sid (String) (defaults to: nil) —

    The SID of the Flow resource to fetch.



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 285

def initialize(version, payload, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'friendly_name' => payload['friendly_name'],
      'definition' => payload['definition'],
      'status' => payload['status'],
      'revision' => payload['revision'] == nil ? payload['revision'] : payload['revision'].to_i,
      'commit_message' => payload['commit_message'],
      'valid' => payload['valid'],
      'errors' => payload['errors'],
      'warnings' => payload['warnings'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'webhook_url' => payload['webhook_url'],
      'url' => payload['url'],
      'links' => payload['links'],
  }

  # Context
  @instance_context = nil
  @params = {'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sid ⇒ String

Returns The SID of the Account that created the resource.

Returns:

  • (String) —

    The SID of the Account that created the resource



331
332
333
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 331

def 
  @properties['account_sid']
end

#commit_message ⇒ String

Returns Description of change made in the revision.

Returns:

  • (String) —

    Description of change made in the revision



361
362
363
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 361

def commit_message
  @properties['commit_message']
end

#context ⇒ FlowContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



316
317
318
319
320
321
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 316

def context
  unless @instance_context
    @instance_context = FlowContext.new(@version, @params['sid'], )
  end
  @instance_context
end

#date_created ⇒ Time

Returns The ISO 8601 date and time in GMT when the resource was created.

Returns:

  • (Time) —

    The ISO 8601 date and time in GMT when the resource was created



385
386
387
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 385

def date_created
  @properties['date_created']
end

#date_updated ⇒ Time

Returns The ISO 8601 date and time in GMT when the resource was last updated.

Returns:

  • (Time) —

    The ISO 8601 date and time in GMT when the resource was last updated



391
392
393
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 391

def date_updated
  @properties['date_updated']
end

#definition ⇒ Hash

Returns JSON representation of flow definition.

Returns:

  • (Hash) —

    JSON representation of flow definition



343
344
345
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 343

def definition
  @properties['definition']
end

#delete ⇒ Boolean

Delete the FlowInstance

Returns:

  • (Boolean) —

    true if delete succeeds, false otherwise



440
441
442
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 440

def delete
  context.delete
end

#errors ⇒ Array[Hash]

Returns List of error in the flow definition.

Returns:

  • (Array[Hash]) —

    List of error in the flow definition



373
374
375
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 373

def errors
  @properties['errors']
end

#executions ⇒ executions

Access the executions

Returns:



461
462
463
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 461

def executions
  context.executions
end

#fetch ⇒ FlowInstance

Fetch the FlowInstance

Returns:



433
434
435
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 433

def fetch
  context.fetch
end

#friendly_name ⇒ String

Returns The string that you assigned to describe the Flow.

Returns:

  • (String) —

    The string that you assigned to describe the Flow



337
338
339
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 337

def friendly_name
  @properties['friendly_name']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



474
475
476
477
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 474

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Studio.V2.FlowInstance #{values}>"
end

Returns Nested resource URLs.

Returns:

  • (String) —

    Nested resource URLs



409
410
411
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 409

def links
  @properties['links']
end

#revision ⇒ String

Returns The latest revision number of the Flow's definition.

Returns:

  • (String) —

    The latest revision number of the Flow's definition



355
356
357
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 355

def revision
  @properties['revision']
end

#revisions ⇒ revisions

Access the revisions

Returns:



447
448
449
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 447

def revisions
  context.revisions
end

#sid ⇒ String

Returns The unique string that identifies the resource.

Returns:

  • (String) —

    The unique string that identifies the resource



325
326
327
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 325

def sid
  @properties['sid']
end

#status ⇒ flow.Status

Returns The status of the Flow.

Returns:

  • (flow.Status) —

    The status of the Flow



349
350
351
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 349

def status
  @properties['status']
end

#test_users ⇒ test_users

Access the test_users

Returns:



454
455
456
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 454

def test_users
  context.test_users
end

#to_s ⇒ Object

Provide a user friendly representation



467
468
469
470
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 467

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Studio.V2.FlowInstance #{values}>"
end

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

Update the FlowInstance

Parameters:

  • status (flow.Status) (defaults to: nil) —

    The status of the Flow. Can be: draft or published.

  • friendly_name (String) (defaults to: :unset) —

    The string that you assigned to describe the Flow.

  • definition (Hash) (defaults to: :unset) —

    JSON representation of flow definition.

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

    Description of change made in the revision.

Returns:



421
422
423
424
425
426
427
428
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 421

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

#url ⇒ String

Returns The absolute URL of the resource.

Returns:

  • (String) —

    The absolute URL of the resource



403
404
405
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 403

def url
  @properties['url']
end

#valid ⇒ Boolean

Returns Boolean if the flow definition is valid.

Returns:

  • (Boolean) —

    Boolean if the flow definition is valid



367
368
369
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 367

def valid
  @properties['valid']
end

#warnings ⇒ Array[Hash]

Returns List of warnings in the flow definition.

Returns:

  • (Array[Hash]) —

    List of warnings in the flow definition



379
380
381
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 379

def warnings
  @properties['warnings']
end

#webhook_url ⇒ String

Returns The webhook_url.

Returns:

  • (String) —

    The webhook_url



397
398
399
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 397

def webhook_url
  @properties['webhook_url']
end