Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::WorkerContext::WorkerStatisticsContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, workspace_sid, worker_sid) ⇒ WorkerStatisticsContext

Initialize the WorkerStatisticsContext

Parameters:

  • Version that contains the resource

  • The SID of the Workspace with the WorkerChannel to fetch.

  • The SID of the Worker with the WorkerChannel to fetch.



52
53
54
55
56
57
58
59
60
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 52

def initialize(version, workspace_sid, worker_sid)
    super(version)

    # Path Solution
    @solution = { workspace_sid: workspace_sid, worker_sid: worker_sid,  }
    @uri = "/Workspaces/#{@solution[:workspace_sid]}/Workers/#{@solution[:worker_sid]}/Statistics"

    
end

Instance Method Details

#fetch(minutes: :unset, start_date: :unset, end_date: :unset, task_channel: :unset) ⇒ WorkerStatisticsInstance

Fetch the WorkerStatisticsInstance

Parameters:

  • (defaults to: :unset)

    Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.

  • (defaults to: :unset)

    Only calculate statistics from this date and time and later, specified in ISO 8601 format.

  • (defaults to: :unset)

    Only include usage that occurred on or before this date, specified in GMT as an ISO 8601 date-time.

  • (defaults to: :unset)

    Only calculate statistics on this TaskChannel. Can be the TaskChannel's SID or its unique_name, such as voice, sms, or default.

Returns:

  • Fetched WorkerStatisticsInstance



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 68

def fetch(
    minutes: :unset, 
    start_date: :unset, 
    end_date: :unset, 
    task_channel: :unset
)

    params = Twilio::Values.of({
        'Minutes' => minutes,
        'StartDate' => Twilio.serialize_iso8601_datetime(start_date),
        'EndDate' => Twilio.serialize_iso8601_datetime(end_date),
        'TaskChannel' => task_channel,
    })
    payload = @version.fetch('GET', @uri, params: params)
    WorkerStatisticsInstance.new(
        @version,
        payload,
        workspace_sid: @solution[:workspace_sid],
        worker_sid: @solution[:worker_sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



100
101
102
103
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 100

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Taskrouter.V1.WorkerStatisticsContext #{context}>"
end

#to_sObject

Provide a user friendly representation



93
94
95
96
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 93

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Taskrouter.V1.WorkerStatisticsContext #{context}>"
end