Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::WorkerList::WorkersStatisticsContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, workspace_sid) ⇒ WorkersStatisticsContext

Initialize the WorkersStatisticsContext

Parameters:

  • version (Version)

    Version that contains the resource

  • workspace_sid (String)

    The SID of the Workspace with the Worker to fetch.



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

def initialize(version, workspace_sid)
    super(version)
    

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

    
end

Instance Method Details

#fetch(minutes: :unset, start_date: :unset, end_date: :unset, task_queue_sid: :unset, task_queue_name: :unset, friendly_name: :unset, task_channel: :unset) ⇒ WorkersStatisticsInstance

Fetch the WorkersStatisticsInstance

Parameters:

  • minutes (String) (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.

  • start_date (Time) (defaults to: :unset)

    Only calculate statistics from this date and time and later, specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

  • end_date (Time) (defaults to: :unset)

    Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date-time.

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

    The SID of the TaskQueue for which to fetch Worker statistics.

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

    The friendly_name of the TaskQueue for which to fetch Worker statistics.

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

    Only include Workers with friendly_name values that match this parameter.

  • task_channel (String) (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:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb', line 73

def fetch(
    minutes: :unset, 
    start_date: :unset, 
    end_date: :unset, 
    task_queue_sid: :unset, 
    task_queue_name: :unset, 
    friendly_name: :unset, 
    task_channel: :unset
)

    params = Twilio::Values.of({
        'Minutes' => minutes,
        'StartDate' => Twilio.serialize_iso8601_datetime(start_date),
        'EndDate' => Twilio.serialize_iso8601_datetime(end_date),
        'TaskQueueSid' => task_queue_sid,
        'TaskQueueName' => task_queue_name,
        'FriendlyName' => friendly_name,
        'TaskChannel' => task_channel,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, params: params, headers: headers)
    WorkersStatisticsInstance.new(
        @version,
        payload,
        workspace_sid: @solution[:workspace_sid],
    )
end

#fetch_with_metadata(minutes: :unset, start_date: :unset, end_date: :unset, task_queue_sid: :unset, task_queue_name: :unset, friendly_name: :unset, task_channel: :unset) ⇒ WorkersStatisticsInstance

Fetch the WorkersStatisticsInstanceMetadata

Parameters:

  • minutes (String) (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.

  • start_date (Time) (defaults to: :unset)

    Only calculate statistics from this date and time and later, specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

  • end_date (Time) (defaults to: :unset)

    Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date-time.

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

    The SID of the TaskQueue for which to fetch Worker statistics.

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

    The friendly_name of the TaskQueue for which to fetch Worker statistics.

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

    Only include Workers with friendly_name values that match this parameter.

  • task_channel (String) (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:



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb', line 116

def (
  minutes: :unset, 
  start_date: :unset, 
  end_date: :unset, 
  task_queue_sid: :unset, 
  task_queue_name: :unset, 
  friendly_name: :unset, 
  task_channel: :unset
)

    params = Twilio::Values.of({
        'Minutes' => minutes,
        'StartDate' => Twilio.serialize_iso8601_datetime(start_date),
        'EndDate' => Twilio.serialize_iso8601_datetime(end_date),
        'TaskQueueSid' => task_queue_sid,
        'TaskQueueName' => task_queue_name,
        'FriendlyName' => friendly_name,
        'TaskChannel' => task_channel,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, params: params, headers: headers)
    workers_statistics_instance = WorkersStatisticsInstance.new(
        @version,
        response.body,
        workspace_sid: @solution[:workspace_sid],
    )
    .new(
        @version,
        workers_statistics_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



165
166
167
168
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb', line 165

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

#to_sObject

Provide a user friendly representation



158
159
160
161
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb', line 158

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