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 SID of the Workspace with the WorkerChannel to update.

  • worker_sid (String)

    The SID of the Worker with the WorkerChannel to update.

  • sid (String)

    The SID of the WorkerChannel to update.



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

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 the WorkerChannelInstance

Returns:



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

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    WorkerChannelInstance.new(
        @version,
        payload,
        workspace_sid: @solution[:workspace_sid],
        worker_sid: @solution[:worker_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataWorkerChannelInstance

Fetch the WorkerChannelInstanceMetadata

Returns:



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

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    worker_channel_instance = WorkerChannelInstance.new(
        @version,
        response.body,
        workspace_sid: @solution[:workspace_sid],
        worker_sid: @solution[:worker_sid],
        sid: @solution[:sid],
    )
    WorkerChannelInstanceMetadata.new(
        @version,
        worker_channel_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



300
301
302
303
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 300

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

#to_sObject

Provide a user friendly representation



293
294
295
296
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 293

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 that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created.

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

    Whether the WorkerChannel is available. Set to false to prevent the Worker from receiving any new Tasks of this TaskChannel type.

Returns:



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 227

def update(
    capacity: :unset, 
    available: :unset
)

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    WorkerChannelInstance.new(
        @version,
        payload,
        workspace_sid: @solution[:workspace_sid],
        worker_sid: @solution[:worker_sid],
        sid: @solution[:sid],
    )
end

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

Update the WorkerChannelInstanceMetadata

Parameters:

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

    The total number of Tasks that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created.

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

    Whether the WorkerChannel is available. Set to false to prevent the Worker from receiving any new Tasks of this TaskChannel type.

Returns:



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 258

def (
  capacity: :unset, 
  available: :unset
)

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    worker_channel_instance = WorkerChannelInstance.new(
        @version,
        response.body,
        workspace_sid: @solution[:workspace_sid],
        worker_sid: @solution[:worker_sid],
        sid: @solution[:sid],
    )
    WorkerChannelInstanceMetadata.new(
        @version,
        worker_channel_instance,
        response.headers,
        response.status_code
    )
end