Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::WorkspaceRealTimeStatisticsInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, workspace_sid: nil) ⇒ WorkspaceRealTimeStatisticsInstance

Initialize the WorkspaceRealTimeStatisticsInstance

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

  • sid (String)

    The SID of the Call resource to fetch.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 139

def initialize(version, payload , workspace_sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'activity_statistics' => payload['activity_statistics'],
        'longest_task_waiting_age' => payload['longest_task_waiting_age'] == nil ? payload['longest_task_waiting_age'] : payload['longest_task_waiting_age'].to_i,
        'longest_task_waiting_sid' => payload['longest_task_waiting_sid'],
        'tasks_by_priority' => payload['tasks_by_priority'],
        'tasks_by_status' => payload['tasks_by_status'],
        'total_tasks' => payload['total_tasks'] == nil ? payload['total_tasks'] : payload['total_tasks'].to_i,
        'total_workers' => payload['total_workers'] == nil ? payload['total_workers'] : payload['total_workers'].to_i,
        'workspace_sid' => payload['workspace_sid'],
        'url' => payload['url'],
    }

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

Instance Method Details

#account_sidString

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

Returns:



174
175
176
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 174

def 
    @properties['account_sid']
end

#activity_statisticsArray<Hash>

Returns The number of current Workers by Activity.

Returns:

  • (Array<Hash>)

    The number of current Workers by Activity.



180
181
182
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 180

def activity_statistics
    @properties['activity_statistics']
end

#contextWorkspaceRealTimeStatisticsContext

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

Returns:



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

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

#fetch(task_channel: :unset) ⇒ WorkspaceRealTimeStatisticsInstance

Fetch the WorkspaceRealTimeStatisticsInstance

Parameters:

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

    Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel’s SID or its ‘unique_name`, such as `voice`, `sms`, or `default`.

Returns:



236
237
238
239
240
241
242
243
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 236

def fetch(
    task_channel: :unset
)

    context.fetch(
        task_channel: task_channel, 
    )
end

#inspectObject

Provide a detailed, user friendly representation



254
255
256
257
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 254

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

#longest_task_waiting_ageString

Returns The age of the longest waiting Task.

Returns:

  • (String)

    The age of the longest waiting Task.



186
187
188
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 186

def longest_task_waiting_age
    @properties['longest_task_waiting_age']
end

#longest_task_waiting_sidString

Returns The SID of the longest waiting Task.

Returns:

  • (String)

    The SID of the longest waiting Task.



192
193
194
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 192

def longest_task_waiting_sid
    @properties['longest_task_waiting_sid']
end

#tasks_by_priorityHash

Returns The number of Tasks by priority. For example: ‘"10", "99": "5"` shows 10 Tasks at priority 0 and 5 at priority 99.

Returns:

  • (Hash)

    The number of Tasks by priority. For example: ‘"10", "99": "5"` shows 10 Tasks at priority 0 and 5 at priority 99.



198
199
200
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 198

def tasks_by_priority
    @properties['tasks_by_priority']
end

#tasks_by_statusHash

Returns The number of Tasks by their current status. For example: ‘"1", "reserved": "3", "assigned": "2", "completed": "5"`.

Returns:

  • (Hash)

    The number of Tasks by their current status. For example: ‘"1", "reserved": "3", "assigned": "2", "completed": "5"`.



204
205
206
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 204

def tasks_by_status
    @properties['tasks_by_status']
end

#to_sObject

Provide a user friendly representation



247
248
249
250
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 247

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

#total_tasksString

Returns The total number of Tasks.

Returns:

  • (String)

    The total number of Tasks.



210
211
212
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 210

def total_tasks
    @properties['total_tasks']
end

#total_workersString

Returns The total number of Workers in the Workspace.

Returns:

  • (String)

    The total number of Workers in the Workspace.



216
217
218
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 216

def total_workers
    @properties['total_workers']
end

#urlString

Returns The absolute URL of the Workspace statistics resource.

Returns:

  • (String)

    The absolute URL of the Workspace statistics resource.



228
229
230
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 228

def url
    @properties['url']
end

#workspace_sidString

Returns The SID of the Workspace.

Returns:

  • (String)

    The SID of the Workspace.



222
223
224
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb', line 222

def workspace_sid
    @properties['workspace_sid']
end