Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::WorkflowInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, workspace_sid: nil, sid: nil) ⇒ WorkflowInstance

Initialize the WorkflowInstance

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 Workflow resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 636

def initialize(version, payload , workspace_sid: nil, sid: nil)
    super(version)
    
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'assignment_callback_url' => payload['assignment_callback_url'],
        'configuration' => payload['configuration'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'document_content_type' => payload['document_content_type'],
        'fallback_assignment_callback_url' => payload['fallback_assignment_callback_url'],
        'friendly_name' => payload['friendly_name'],
        'sid' => payload['sid'],
        'task_reservation_timeout' => payload['task_reservation_timeout'] == nil ? payload['task_reservation_timeout'] : payload['task_reservation_timeout'].to_i,
        'workspace_sid' => payload['workspace_sid'],
        'url' => payload['url'],
        'links' => payload['links'],
    }

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

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Workflow resource.

Returns:



675
676
677
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 675

def 
    @properties['account_sid']
end

#assignment_callback_urlString

Returns The URL that we call when a task managed by the Workflow is assigned to a Worker. See Assignment Callback URL for more information.

Returns:

  • (String)

    The URL that we call when a task managed by the Workflow is assigned to a Worker. See Assignment Callback URL for more information.



681
682
683
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 681

def assignment_callback_url
    @properties['assignment_callback_url']
end

#configurationString

Returns A JSON string that contains the Workflow’s configuration. See [Configuring Workflows](www.twilio.com/docs/taskrouter/workflow-configuration) for more information.

Returns:



687
688
689
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 687

def configuration
    @properties['configuration']
end

#contextWorkflowContext

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

Returns:



666
667
668
669
670
671
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 666

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

#cumulative_statisticscumulative_statistics

Access the cumulative_statistics

Returns:



805
806
807
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 805

def cumulative_statistics
    context.cumulative_statistics
end

#date_createdTime

Returns The date and time in GMT when the resource was created specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



693
694
695
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 693

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in GMT when the resource was last updated specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



699
700
701
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 699

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the WorkflowInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



754
755
756
757
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 754

def delete

    context.delete
end

#document_content_typeString

Returns The MIME type of the document.

Returns:

  • (String)

    The MIME type of the document.



705
706
707
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 705

def document_content_type
    @properties['document_content_type']
end

#fallback_assignment_callback_urlString

Returns The URL that we call when a call to the ‘assignment_callback_url` fails.

Returns:

  • (String)

    The URL that we call when a call to the ‘assignment_callback_url` fails.



711
712
713
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 711

def fallback_assignment_callback_url
    @properties['fallback_assignment_callback_url']
end

#fetchWorkflowInstance

Fetch the WorkflowInstance

Returns:



762
763
764
765
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 762

def fetch

    context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the Workflow resource. For example, ‘Customer Support` or `2014 Election Campaign`.

Returns:

  • (String)

    The string that you assigned to describe the Workflow resource. For example, ‘Customer Support` or `2014 Election Campaign`.



717
718
719
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 717

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



825
826
827
828
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 825

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

Returns The URLs of related resources.

Returns:

  • (Hash)

    The URLs of related resources.



747
748
749
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 747

def links
    @properties['links']
end

#real_time_statisticsreal_time_statistics

Access the real_time_statistics

Returns:



812
813
814
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 812

def real_time_statistics
    context.real_time_statistics
end

#sidString

Returns The unique string that we created to identify the Workflow resource.

Returns:

  • (String)

    The unique string that we created to identify the Workflow resource.



723
724
725
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 723

def sid
    @properties['sid']
end

#statisticsstatistics

Access the statistics

Returns:



798
799
800
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 798

def statistics
    context.statistics
end

#task_reservation_timeoutString

Returns How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to ‘86,400` (24 hours) and the default is `120`.

Returns:

  • (String)

    How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to ‘86,400` (24 hours) and the default is `120`.



729
730
731
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 729

def task_reservation_timeout
    @properties['task_reservation_timeout']
end

#to_sObject

Provide a user friendly representation



818
819
820
821
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 818

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

#update(friendly_name: :unset, assignment_callback_url: :unset, fallback_assignment_callback_url: :unset, configuration: :unset, task_reservation_timeout: :unset, re_evaluate_tasks: :unset) ⇒ WorkflowInstance

Update the WorkflowInstance

Parameters:

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

    A descriptive string that you create to describe the Workflow resource. For example, ‘Inbound Call Workflow` or `2014 Outbound Campaign`.

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

    The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details.

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

    The URL that we should call when a call to the ‘assignment_callback_url` fails.

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

    A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](www.twilio.com/docs/taskrouter/workflow-configuration) for more information.

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

    How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to ‘86,400` (24 hours) and the default is `120`.

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

    Whether or not to re-evaluate Tasks. The default is ‘false`, which means Tasks in the Workflow will not be processed through the assignment loop again.

Returns:



776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 776

def update(
  friendly_name: :unset, 
  assignment_callback_url: :unset, 
  fallback_assignment_callback_url: :unset, 
  configuration: :unset, 
  task_reservation_timeout: :unset, 
  re_evaluate_tasks: :unset
)

    context.update(
        friendly_name: friendly_name, 
        assignment_callback_url: assignment_callback_url, 
        fallback_assignment_callback_url: fallback_assignment_callback_url, 
        configuration: configuration, 
        task_reservation_timeout: task_reservation_timeout, 
        re_evaluate_tasks: re_evaluate_tasks, 
    )
end

#urlString

Returns The absolute URL of the Workflow resource.

Returns:

  • (String)

    The absolute URL of the Workflow resource.



741
742
743
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 741

def url
    @properties['url']
end

#workspace_sidString

Returns The SID of the Workspace that contains the Workflow.

Returns:

  • (String)

    The SID of the Workspace that contains the Workflow.



735
736
737
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 735

def workspace_sid
    @properties['workspace_sid']
end