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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, workspace_sid, worker_sid, sid) ⇒ WorkerChannelContext

Initialize the WorkerChannelContext

Parameters:

  • version (Version)

    Version that contains the resource

  • workspace_sid (String)

    The workspace_sid

  • worker_sid (String)

    The worker_sid

  • sid (String)

    The sid



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

def initialize(version, workspace_sid, worker_sid, sid)
  super(version)

  # Path Solution
  @solution = {workspace_sid: workspace_sid, worker_sid: worker_sid, sid: sid, }
  @uri = "/Workspaces/#{@solution[:workspace_sid]}/Workers/#{@solution[:worker_sid]}/Channels/#{@solution[:sid]}"
end

Instance Method Details

#fetchWorkerChannelInstance

Fetch a WorkerChannelInstance

Returns:



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 174

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  WorkerChannelInstance.new(
      @version,
      payload,
      workspace_sid: @solution[:workspace_sid],
      worker_sid: @solution[:worker_sid],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#to_sObject

Provide a user friendly representation



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

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

#update(capacity: :unset, available: :unset) ⇒ WorkerChannelInstance

Update the WorkerChannelInstance

Parameters:

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

    The total number of Tasks worker should handle for this TaskChannel type. TaskRouter will only create reservations for Tasks of this TaskChannel type up to the capacity configured. If the capacity is 0, no new reservations will be created

  • available (Boolean) (defaults to: :unset)

    Toggle the availability of the WorkerChannel. Set this to ‘False’ to make worker unavailable to receive any new Tasks of this TaskChannel type.

Returns:



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 202

def update(capacity: :unset, available: :unset)
  data = Twilio::Values.of({'Capacity' => capacity, 'Available' => available, })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  WorkerChannelInstance.new(
      @version,
      payload,
      workspace_sid: @solution[:workspace_sid],
      worker_sid: @solution[:worker_sid],
      sid: @solution[:sid],
  )
end