Class: Twilio::REST::Webhooks::V1::OperationInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/webhooks/v1/operation.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, operation_id: nil) ⇒ OperationInstance

Initialize the OperationInstance

Parameters:

  • version (Version) —

    Version that contains the resource

  • payload (Hash) —

    payload that contains response from Twilio

  • account_sid (String) —

    The SID of the Account that created this Operation resource.

  • sid (String) —

    The SID of the Call resource to fetch.



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 406

def initialize(version, payload , operation_id: nil)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    
    # Marshaled Properties
    @properties = { 
        'id' => payload['id'],
        'status_url' => payload['status_url'],
        'status' => payload['status'],
        'error' => payload['error'],
        'resource_id' => payload['resource_id'],
        'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
        'completed_at' => Twilio.deserialize_iso8601_datetime(payload['completed_at']),
        'retention_period' => payload['retention_period'],
    }

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

Instance Method Details

#completed_at ⇒ Time

Returns:

  • (Time)


477
478
479
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 477

def completed_at
    @properties['completed_at']
end

#context ⇒ OperationContext

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

Returns:



432
433
434
435
436
437
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 432

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

#created_at ⇒ Time

Returns:

  • (Time)


471
472
473
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 471

def created_at
    @properties['created_at']
end

#error ⇒ OperationError

Returns Present only when status is FAILED.

Returns:

  • (OperationError) —

    Present only when status is FAILED



459
460
461
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 459

def error
    @properties['error']
end

#fetch ⇒ OperationInstance

Fetch the OperationInstance

Returns:



490
491
492
493
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 490

def fetch

    context.fetch
end

#id ⇒ String

Returns Unique operation identifier (TypeID/TTID format).

Returns:

  • (String) —

    Unique operation identifier (TypeID/TTID format)



441
442
443
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 441

def id
    @properties['id']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



504
505
506
507
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 504

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

#resource_id ⇒ String

Returns ID of the affected resource.

Returns:

  • (String) —

    ID of the affected resource



465
466
467
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 465

def resource_id
    @properties['resource_id']
end

#retention_period ⇒ String

Returns ISO-8601 duration for how long this Operation record is retained after creation (fixed at 7 days).

Returns:

  • (String) —

    ISO-8601 duration for how long this Operation record is retained after creation (fixed at 7 days)



483
484
485
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 483

def retention_period
    @properties['retention_period']
end

#status ⇒ String

Returns Current state of the operation: - PENDING: Accepted, not yet started - RUNNING: Propagating to all regions (typically 30-60 seconds) - COMPLETED: Rule active globally - CANCELLED: Operation was cancelled before completion - FAILED: Operation could not complete; see error field for details.

Returns:

  • (String) —

    Current state of the operation: - PENDING: Accepted, not yet started - RUNNING: Propagating to all regions (typically 30-60 seconds) - COMPLETED: Rule active globally - CANCELLED: Operation was cancelled before completion - FAILED: Operation could not complete; see error field for details



453
454
455
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 453

def status
    @properties['status']
end

#status_url ⇒ String

Returns URL to poll for operation status (same as Location header in 202 response).

Returns:

  • (String) —

    URL to poll for operation status (same as Location header in 202 response)



447
448
449
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 447

def status_url
    @properties['status_url']
end

#to_s ⇒ Object

Provide a user friendly representation



497
498
499
500
# File 'lib/twilio-ruby/rest/webhooks/v1/operation.rb', line 497

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