Class: Twilio::REST::Insights::V3::QueryJobInstance

Inherits:
Twilio::REST::InstanceResource show all
Defined in:
lib/twilio-ruby/rest/insights/v3/query_job.rb

Instance Method Summary collapse

Constructor Details

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

Initialize the QueryJobInstance

Parameters:

  • Version that contains the resource

  • payload that contains response from Twilio

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

  • The SID of the Call resource to fetch.



540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 540

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

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

Instance Method Details

#completed_at ⇒ Time

Returns The time when the operation reached a terminal state (CANCELLED, COMPLETED, or FAILED), in RFC 3339 UTC format. Null while the operation is still PENDING or RUNNING.

Returns:

  • The time when the operation reached a terminal state (CANCELLED, COMPLETED, or FAILED), in RFC 3339 UTC format. Null while the operation is still PENDING or RUNNING.



600
601
602
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 600

def completed_at
    @properties['completed_at']
end

#context ⇒ QueryJobContext

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



567
568
569
570
571
572
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 567

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

#created_at ⇒ Time

Returns The time when the operation was accepted, in RFC 3339 UTC format.

Returns:

  • The time when the operation was accepted, in RFC 3339 UTC format.



594
595
596
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 594

def created_at
    @properties['created_at']
end

#error ⇒ OperationError

Returns The error details, present only when status is FAILED.

Returns:

  • The error details, present only when status is FAILED.



606
607
608
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 606

def error
    @properties['error']
end

#fetch ⇒ QueryJobInstance

Fetch the QueryJobInstance

Returns:

  • Fetched QueryJobInstance



631
632
633
634
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 631

def fetch

    context.fetch
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



645
646
647
648
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 645

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

#operation_id ⇒ String

Returns The unique identifier for the asynchronous query operation, in TTID format.

Returns:

  • The unique identifier for the asynchronous query operation, in TTID format.



576
577
578
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 576

def operation_id
    @properties['operation_id']
end

#result_id ⇒ String

Returns The identifier of the results resource, present only when status is COMPLETED. Equal to operationId, since results are keyed by the operation ID.

Returns:

  • The identifier of the results resource, present only when status is COMPLETED. Equal to operationId, since results are keyed by the operation ID.



618
619
620
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 618

def result_id
    @properties['result_id']
end

#result_retention_period ⇒ String

Returns The duration for how long results are retained, in ISO 8601 format.

Returns:

  • The duration for how long results are retained, in ISO 8601 format.



624
625
626
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 624

def result_retention_period
    @properties['result_retention_period']
end

#result_url ⇒ String

Returns The URL to retrieve query results, present only when status is COMPLETED. Supports pagination via the pageSize and pageToken query parameters.

Returns:

  • The URL to retrieve query results, present only when status is COMPLETED. Supports pagination via the pageSize and pageToken query parameters.



612
613
614
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 612

def result_url
    @properties['result_url']
end

#status ⇒ LongRunningOperationStatus

Returns:



582
583
584
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 582

def status
    @properties['status']
end

#status_url ⇒ String

Returns The URI to poll for operation status.

Returns:

  • The URI to poll for operation status.



588
589
590
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 588

def status_url
    @properties['status_url']
end

#to_s ⇒ Object

Provide a user friendly representation



638
639
640
641
# File 'lib/twilio-ruby/rest/insights/v3/query_job.rb', line 638

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