Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::EventList

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

Instance Method Summary collapse

Constructor Details

#initialize(version, workspace_sid: nil) ⇒ EventList

Initialize the EventList

Parameters:

  • version (Version)

    Version that contains the resource

  • workspace_sid (String) (defaults to: nil)

    The SID of the Workspace that contains the Event.


20
21
22
23
24
25
26
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb', line 20

def initialize(version, workspace_sid: nil)
  super(version)

  # Path Solution
  @solution = {workspace_sid: workspace_sid}
  @uri = "/Workspaces/#{@solution[:workspace_sid]}/Events"
end

Instance Method Details

#eachObject

When passed a block, yields EventInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.


143
144
145
146
147
148
149
150
151
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb', line 143

def each
  limits = @version.read_limits

  page = self.page(page_size: limits[:page_size], )

  @version.stream(page,
                  limit: limits[:limit],
                  page_limit: limits[:page_limit]).each {|x| yield x}
end

#get_page(target_url) ⇒ Page

Retrieve a single page of EventInstance records from the API. Request is executed immediately.

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of EventInstance


213
214
215
216
217
218
219
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb', line 213

def get_page(target_url)
  response = @version.domain.request(
      'GET',
      target_url
  )
  EventPage.new(@version, response, @solution)
end

#list(end_date: :unset, event_type: :unset, minutes: :unset, reservation_sid: :unset, start_date: :unset, task_queue_sid: :unset, task_sid: :unset, worker_sid: :unset, workflow_sid: :unset, task_channel: :unset, sid: :unset, limit: nil, page_size: nil) ⇒ Array

Lists EventInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning.

Parameters:

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

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

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

    The type of Events to read. Returns only Events of the type specified.

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

    The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted.

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

    The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation.

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

    Only include Events from on or after this date and time, specified in ISO 8601 format. Task Attributes for Events older than 30 days will be redacted.

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

    The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue.

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

    The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task.

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

    The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker.

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

    The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow.

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

    The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel.

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

    The SID of the Event resource to read.

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)

Returns:

  • (Array)

    Array of up to limit results


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb', line 64

def list(end_date: :unset, event_type: :unset, minutes: :unset, reservation_sid: :unset, start_date: :unset, task_queue_sid: :unset, task_sid: :unset, worker_sid: :unset, workflow_sid: :unset, task_channel: :unset, sid: :unset, limit: nil, page_size: nil)
  self.stream(
      end_date: end_date,
      event_type: event_type,
      minutes: minutes,
      reservation_sid: reservation_sid,
      start_date: start_date,
      task_queue_sid: task_queue_sid,
      task_sid: task_sid,
      worker_sid: worker_sid,
      workflow_sid: workflow_sid,
      task_channel: task_channel,
      sid: sid,
      limit: limit,
      page_size: page_size
  ).entries
end

#page(end_date: :unset, event_type: :unset, minutes: :unset, reservation_sid: :unset, start_date: :unset, task_queue_sid: :unset, task_sid: :unset, worker_sid: :unset, workflow_sid: :unset, task_channel: :unset, sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset) ⇒ Page

Retrieve a single page of EventInstance records from the API. Request is executed immediately.

Parameters:

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

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

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

    The type of Events to read. Returns only Events of the type specified.

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

    The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted.

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

    The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation.

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

    Only include Events from on or after this date and time, specified in ISO 8601 format. Task Attributes for Events older than 30 days will be redacted.

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

    The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue.

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

    The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task.

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

    The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker.

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

    The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow.

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

    The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel.

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

    The SID of the Event resource to read.

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

    PageToken provided by the API

  • page_number (Integer) (defaults to: :unset)

    Page Number, this value is simply for client state

  • page_size (Integer) (defaults to: :unset)

    Number of records to return, defaults to 50

Returns:

  • (Page)

    Page of EventInstance


185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb', line 185

def page(end_date: :unset, event_type: :unset, minutes: :unset, reservation_sid: :unset, start_date: :unset, task_queue_sid: :unset, task_sid: :unset, worker_sid: :unset, workflow_sid: :unset, task_channel: :unset, sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
  params = Twilio::Values.of({
      'EndDate' => Twilio.serialize_iso8601_datetime(end_date),
      'EventType' => event_type,
      'Minutes' => minutes,
      'ReservationSid' => reservation_sid,
      'StartDate' => Twilio.serialize_iso8601_datetime(start_date),
      'TaskQueueSid' => task_queue_sid,
      'TaskSid' => task_sid,
      'WorkerSid' => worker_sid,
      'WorkflowSid' => workflow_sid,
      'TaskChannel' => task_channel,
      'Sid' => sid,
      'PageToken' => page_token,
      'Page' => page_number,
      'PageSize' => page_size,
  })

  response = @version.page('GET', @uri, params: params)

  EventPage.new(@version, response, @solution)
end

#stream(end_date: :unset, event_type: :unset, minutes: :unset, reservation_sid: :unset, start_date: :unset, task_queue_sid: :unset, task_sid: :unset, worker_sid: :unset, workflow_sid: :unset, task_channel: :unset, sid: :unset, limit: nil, page_size: nil) ⇒ Enumerable

Streams EventInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached.

Parameters:

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

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

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

    The type of Events to read. Returns only Events of the type specified.

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

    The period of events to read in minutes. Returns only Events that occurred since this many minutes in the past. The default is `15` minutes. Task Attributes for Events occuring more 43,200 minutes ago will be redacted.

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

    The SID of the Reservation with the Events to read. Returns only Events that pertain to the specified Reservation.

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

    Only include Events from on or after this date and time, specified in ISO 8601 format. Task Attributes for Events older than 30 days will be redacted.

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

    The SID of the TaskQueue with the Events to read. Returns only the Events that pertain to the specified TaskQueue.

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

    The SID of the Task with the Events to read. Returns only the Events that pertain to the specified Task.

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

    The SID of the Worker with the Events to read. Returns only the Events that pertain to the specified Worker.

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

    The SID of the Workflow with the Events to read. Returns only the Events that pertain to the specified Workflow.

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

    The TaskChannel with the Events to read. Returns only the Events that pertain to the specified TaskChannel.

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

    The SID of the Event resource to read.

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit.

  • page_size (Integer) (defaults to: nil)

    Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)

Returns:

  • (Enumerable)

    Enumerable that will yield up to limit results


118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb', line 118

def stream(end_date: :unset, event_type: :unset, minutes: :unset, reservation_sid: :unset, start_date: :unset, task_queue_sid: :unset, task_sid: :unset, worker_sid: :unset, workflow_sid: :unset, task_channel: :unset, sid: :unset, limit: nil, page_size: nil)
  limits = @version.read_limits(limit, page_size)

  page = self.page(
      end_date: end_date,
      event_type: event_type,
      minutes: minutes,
      reservation_sid: reservation_sid,
      start_date: start_date,
      task_queue_sid: task_queue_sid,
      task_sid: task_sid,
      worker_sid: worker_sid,
      workflow_sid: workflow_sid,
      task_channel: task_channel,
      sid: sid,
      page_size: limits[:page_size],
  )

  @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
end

#to_sObject

Provide a user friendly representation


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

def to_s
  '#<Twilio.Taskrouter.V1.EventList>'
end