class Restcomm::REST::TaskRouterClient
Constants
- API_VERSION
- DEFAULTS
Attributes
Public Class Methods
Instantiate a new HTTP TaskRouter
client to talk to Restcomm
. The parameters account_sid
, auth_token
and +workspace_sid are required, unless you have configured them already using the block configure syntax, and used to generate the HTTP basic auth header in each request. The options
parameter is a hash of connection configuration options. the following keys are supported:
host: 'taskrouter.restcomm.com'
¶ ↑
The domain to which you’d like the client to make HTTP requests. Useful for testing. Defaults to ‘api.restcomm.com’.
port: 443
¶ ↑
The port on which to connect to the above domain. Defaults to 443 and should be left that way except in testing environments.
use_ssl: true
¶ ↑
Declare whether ssl should be used for connections to the above domain. Defaults to true and should be left alone except when testing.
ssl_verify_peer: true
¶ ↑
Declare whether to verify the host’s ssl cert when setting up the connection to the above domain. Defaults to true, but can be turned off to avoid ssl certificate verification failures in environments without the necessary ca certificates.
ssl_ca_file: '/path/to/ca/file'
¶ ↑
Specify the path to the certificate authority bundle you’d like to use to verify Restcomm’s SSL certificate on each request. If not specified, a certificate bundle extraced from Firefox is packaged with the gem and used by default.
timeout: 30
¶ ↑
Set the time in seconds to wait before timing out the HTTP request. Defaults to 30 seconds. If you aren’t fetching giant pages of call or SMS
logs you can safely decrease this to something like 3 seconds or lower. In paricular if you are sending SMS
you can set this to 1 second or less and swallow the exception if you don’t care about the response.
proxy_addr: 'proxy.host.domain'
¶ ↑
The domain of a proxy through which you’d like the client to make HTTP requests. Defaults to nil.
proxy_port: 3128
¶ ↑
The port on which to connect to the above proxy. Defaults to nil.
proxy_user: 'username'
¶ ↑
The user name to use for authentication with the proxy. Defaults to nil.
proxy_pass: 'password'
¶ ↑
The password to use for authentication with the proxy. Defaults to nil.
retry_limit: 1
¶ ↑
The number of times to retry a request that has failed before throwing an exception. Defaults to one.
Restcomm::REST::BaseClient::new
# File lib/restcomm-ruby/rest/client.rb 439 def initialize(*args) 440 @workspace_sid = args[2] 441 if @workspace_sid.nil? 442 raise ArgumentError, 'Workspace SID is required' 443 end 444 super(*args) 445 end
Public Instance Methods
Delegate workspace methods from the client. This saves having to call client.workspace
every time for resources on the default workspace.
# File lib/restcomm-ruby/rest/client.rb 476 def method_missing(method_name, *args, &block) 477 if workspace.respond_to?(method_name) 478 workspace.send(method_name, *args, &block) 479 else 480 super 481 end 482 end
# File lib/restcomm-ruby/rest/client.rb 484 def respond_to?(method_name, include_private=false) 485 if workspace.respond_to?(method_name, include_private) 486 true 487 else 488 super 489 end 490 end
Get statistics of a task queue.
# File lib/restcomm-ruby/rest/client.rb 494 def task_queue_statistics(task_queue_sid, *args) # :doc: 495 if task_queue_sid.nil? 496 raise ArgumentError, 'Task queue SID is required' 497 end 498 path = "/#{API_VERSION}/Workspaces/#{@workspace_sid}/TaskQueues/#{task_queue_sid}/Statistics" 499 response = get path, args, true 500 Restcomm::REST::TaskRouter::TaskQueueStatistics.new path, self, response 501 end
Get statistics of task queues.
# File lib/restcomm-ruby/rest/client.rb 505 def task_queues_statistics(*args) # :doc: 506 path = "/#{API_VERSION}/Workspaces/#{@workspace_sid}/TaskQueues/Statistics" 507 stats = Restcomm::REST::TaskRouter::TaskQueuesStatistics.new path, self 508 stats.list args, true 509 end
Get statistics of a worker.
# File lib/restcomm-ruby/rest/client.rb 513 def worker_statistics(worker_sid, *args) # :doc: 514 if worker_sid.nil? 515 raise ArgumentError, 'Worker SID is required' 516 end 517 path = "/#{API_VERSION}/Workspaces/#{@workspace_sid}/Workers/#{worker_sid}/Statistics" 518 response = get path, args, true 519 Restcomm::REST::TaskRouter::WorkerStatistics.new path, self, response 520 end
Get statistics of workers.
# File lib/restcomm-ruby/rest/client.rb 524 def workers_statistics(*args) # :doc: 525 path = "/#{API_VERSION}/Workspaces/#{@workspace_sid}/Workers/Statistics" 526 response = get path, args, true 527 Restcomm::REST::TaskRouter::WorkersStatistics.new path, self, response 528 end
Get statistics of a workflow.
# File lib/restcomm-ruby/rest/client.rb 532 def workflow_statistics(workflow_sid, *args) # :doc: 533 if workflow_sid.nil? 534 raise ArgumentError, 'Workflow SID is required' 535 end 536 path = "/#{API_VERSION}/Workspaces/#{@workspace_sid}/Workflows/#{workflow_sid}/Statistics" 537 response = get path, args, true 538 Restcomm::REST::TaskRouter::WorkflowStatistics.new path, self, response 539 end
Get statistics of a workspace.
# File lib/restcomm-ruby/rest/client.rb 543 def workspace_statistics(*args) # :doc: 544 path = "/#{API_VERSION}/Workspaces/#{@workspace_sid}/Statistics" 545 response = get path, args, true 546 Restcomm::REST::TaskRouter::WorkspaceStatistics.new path, self, response 547 end
Protected Instance Methods
Get the default config values.
# File lib/restcomm-ruby/rest/client.rb 553 def get_defaults 554 DEFAULTS 555 end
Set up workspace
and workspaces
attributes.
# File lib/restcomm-ruby/rest/client.rb 559 def set_up_subresources # :doc: 560 @workspaces = Restcomm::REST::TaskRouter::Workspaces.new "/#{API_VERSION}/Workspaces", self 561 @workspace = @workspaces.get @workspace_sid 562 end