class Twilio::REST::Taskrouter::V1::WorkspaceContext::ActivityList

Public Class Methods

new(version, workspace_sid: nil) click to toggle source

Initialize the ActivityList @param [Version] version Version that contains the resource @param [String] workspace_sid The SID of the Workspace that contains the

Activity.

@return [ActivityList] ActivityList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb
21 def initialize(version, workspace_sid: nil)
22   super(version)
23 
24   # Path Solution
25   @solution = {workspace_sid: workspace_sid}
26   @uri = "/Workspaces/#{@solution[:workspace_sid]}/Activities"
27 end

Public Instance Methods

create(friendly_name: nil, available: :unset) click to toggle source

Create the ActivityInstance @param [String] friendly_name A descriptive string that you create to describe

the Activity resource. It can be up to 64 characters long. These names are used
to calculate and expose statistics about Workers, and provide visibility into
the state of each Worker. Examples of friendly names include: `on-call`,
`break`, and `email`.

@param [Boolean] available Whether the Worker should be eligible to receive a

Task when it occupies the Activity. A value of `true`, `1`, or `yes` specifies
the Activity is available. All other values specify that it is not. The value
cannot be changed after the Activity is created.

@return [ActivityInstance] Created ActivityInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb
146 def create(friendly_name: nil, available: :unset)
147   data = Twilio::Values.of({'FriendlyName' => friendly_name, 'Available' => available, })
148 
149   payload = @version.create('POST', @uri, data: data)
150 
151   ActivityInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid], )
152 end
each() { |x| ... } click to toggle source

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

   # File lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb
84 def each
85   limits = @version.read_limits
86 
87   page = self.page(page_size: limits[:page_size], )
88 
89   @version.stream(page,
90                   limit: limits[:limit],
91                   page_limit: limits[:page_limit]).each {|x| yield x}
92 end
get_page(target_url) click to toggle source

Retrieve a single page of ActivityInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of ActivityInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb
126 def get_page(target_url)
127   response = @version.domain.request(
128       'GET',
129       target_url
130   )
131   ActivityPage.new(@version, response, @solution)
132 end
list(friendly_name: :unset, available: :unset, limit: nil, page_size: nil) click to toggle source

Lists ActivityInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] friendly_name The `friendly_name` of the Activity resources to

read.

@param [String] available Whether return only Activity resources that are

available or unavailable. A value of `true` returns only available activities.
Values of '1' or `yes` also indicate `true`. All other values represent `false`
and return activities that are unavailable.

@param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size 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)

@return [Array] Array of up to limit results

   # File lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb
46 def list(friendly_name: :unset, available: :unset, limit: nil, page_size: nil)
47   self.stream(
48       friendly_name: friendly_name,
49       available: available,
50       limit: limit,
51       page_size: page_size
52   ).entries
53 end
page(friendly_name: :unset, available: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of ActivityInstance records from the API. Request is executed immediately. @param [String] friendly_name The `friendly_name` of the Activity resources to

read.

@param [String] available Whether return only Activity resources that are

available or unavailable. A value of `true` returns only available activities.
Values of '1' or `yes` also indicate `true`. All other values represent `false`
and return activities that are unavailable.

@param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of ActivityInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb
107 def page(friendly_name: :unset, available: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
108   params = Twilio::Values.of({
109       'FriendlyName' => friendly_name,
110       'Available' => available,
111       'PageToken' => page_token,
112       'Page' => page_number,
113       'PageSize' => page_size,
114   })
115 
116   response = @version.page('GET', @uri, params: params)
117 
118   ActivityPage.new(@version, response, @solution)
119 end
stream(friendly_name: :unset, available: :unset, limit: nil, page_size: nil) click to toggle source

Streams ActivityInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] friendly_name The `friendly_name` of the Activity resources to

read.

@param [String] available Whether return only Activity resources that are

available or unavailable. A value of `true` returns only available activities.
Values of '1' or `yes` also indicate `true`. All other values represent `false`
and return activities that are unavailable.

@param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size 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)

@return [Enumerable] Enumerable that will yield up to limit results

   # File lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb
72 def stream(friendly_name: :unset, available: :unset, limit: nil, page_size: nil)
73   limits = @version.read_limits(limit, page_size)
74 
75   page = self.page(friendly_name: friendly_name, available: available, page_size: limits[:page_size], )
76 
77   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
78 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb
156 def to_s
157   '#<Twilio.Taskrouter.V1.ActivityList>'
158 end