Class: Twilio::REST::Conversations::V2::ActionInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, conversation_id: nil, action_id: nil) ⇒ ActionInstance

Initialize the ActionInstance

Parameters:

  • Version that contains the resource

  • payload that contains response from Twilio

  • The SID of the Account that created this Action resource.

  • The SID of the Call resource to fetch.



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 400

def initialize(version, payload , conversation_id: nil, action_id: nil)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    
    # Marshaled Properties
    @properties = { 
        'id' => payload['id'],
        'type' => payload['type'],
        'status' => payload['status'],
        'conversation_id' => payload['conversation_id'],
        'related' => payload['related'],
        'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
        'updated_at' => Twilio.deserialize_iso8601_datetime(payload['updated_at']),
        'completed_at' => Twilio.deserialize_iso8601_datetime(payload['completed_at']),
    }

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

Instance Method Details

#completed_atTime

Returns Timestamp when the action reached a terminal status.

Returns:

  • Timestamp when the action reached a terminal status.



477
478
479
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 477

def completed_at
    @properties['completed_at']
end

#contextActionContext

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

Returns:

  • CallContext for this CallInstance



426
427
428
429
430
431
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 426

def context
    unless @instance_context
        @instance_context = ActionContext.new(@version , @params['conversation_id'], @params['action_id'])
    end
    @instance_context
end

#conversation_idString

Returns The conversation this action belongs to.

Returns:

  • The conversation this action belongs to.



453
454
455
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 453

def conversation_id
    @properties['conversation_id']
end

#created_atTime

Returns Timestamp when the action was created.

Returns:

  • Timestamp when the action was created.



465
466
467
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 465

def created_at
    @properties['created_at']
end

#fetchActionInstance

Fetch the ActionInstance

Returns:

  • Fetched ActionInstance



484
485
486
487
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 484

def fetch

    context.fetch
end

#idString

Returns Unique identifier for this Action.

Returns:

  • Unique identifier for this Action.



435
436
437
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 435

def id
    @properties['id']
end

#inspectObject

Provide a detailed, user friendly representation



498
499
500
501
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 498

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

Returns Named identifiers from downstream. For SEND_MESSAGE: - messageSid: The downstream message SID (present when PENDING or COMPLETED) - communicationId: The Communication ID (present when COMPLETED).

Returns:

  • Named identifiers from downstream. For SEND_MESSAGE: - messageSid: The downstream message SID (present when PENDING or COMPLETED) - communicationId: The Communication ID (present when COMPLETED)



459
460
461
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 459

def related
    @properties['related']
end

#statusString

Returns Current status of the Action. - PENDING: Action accepted, awaiting downstream confirmation - COMPLETED: Downstream backend confirmed the action - FAILED: Downstream backend reported a failure.

Returns:

  • Current status of the Action. - PENDING: Action accepted, awaiting downstream confirmation - COMPLETED: Downstream backend confirmed the action - FAILED: Downstream backend reported a failure



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

def status
    @properties['status']
end

#to_sObject

Provide a user friendly representation



491
492
493
494
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 491

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

#typeString

Returns The type of action. Accepted values: SEND_MESSAGE.

Returns:

  • The type of action. Accepted values: SEND_MESSAGE.



441
442
443
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 441

def type
    @properties['type']
end

#updated_atTime

Returns Timestamp when the action was last updated.

Returns:

  • Timestamp when the action was last updated.



471
472
473
# File 'lib/twilio-ruby/rest/conversations/v2/action.rb', line 471

def updated_at
    @properties['updated_at']
end