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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, workspace_sid: nil, worker_sid: nil) ⇒ WorkerStatisticsInstance

Initialize the WorkerStatisticsInstance

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

  • sid (String)

    The SID of the Call resource to fetch.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 147

def initialize(version, payload , workspace_sid: nil, worker_sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'cumulative' => payload['cumulative'],
        'worker_sid' => payload['worker_sid'],
        'workspace_sid' => payload['workspace_sid'],
        'url' => payload['url'],
    }

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

Instance Method Details

#account_sidString

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

Returns:



177
178
179
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 177

def 
    @properties['account_sid']
end

#contextWorkerStatisticsContext

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

Returns:



168
169
170
171
172
173
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 168

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

#cumulativeHash

Returns An object that contains the cumulative statistics for the Worker.

Returns:

  • (Hash)

    An object that contains the cumulative statistics for the Worker.



183
184
185
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 183

def cumulative
    @properties['cumulative']
end

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

Fetch the WorkerStatisticsInstance

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 include usage that occurred on or before this date, specified in GMT as an [ISO 8601](en.wikipedia.org/wiki/ISO_8601) date-time.

  • 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:



212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 212

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

    context.fetch(
        minutes: minutes, 
        start_date: start_date, 
        end_date: end_date, 
        task_channel: task_channel, 
    )
end

#inspectObject

Provide a detailed, user friendly representation



236
237
238
239
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 236

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

#to_sObject

Provide a user friendly representation



229
230
231
232
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 229

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

#urlString

Returns The absolute URL of the WorkerChannel statistics resource.

Returns:

  • (String)

    The absolute URL of the WorkerChannel statistics resource.



201
202
203
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 201

def url
    @properties['url']
end

#worker_sidString

Returns The SID of the Worker that contains the WorkerChannel.

Returns:

  • (String)

    The SID of the Worker that contains the WorkerChannel.



189
190
191
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 189

def worker_sid
    @properties['worker_sid']
end

#workspace_sidString

Returns The SID of the Workspace that contains the WorkerChannel.

Returns:

  • (String)

    The SID of the Workspace that contains the WorkerChannel.



195
196
197
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb', line 195

def workspace_sid
    @properties['workspace_sid']
end