Class: Twilio::REST::TaskRouterClient

Inherits:
BaseClient
  • Object
show all
Defined in:
lib/twilio-ruby/rest/task_router_client.rb

Constant Summary collapse

API_VERSION =
'v1'

Constants inherited from BaseClient

BaseClient::HTTP_HEADERS

Instance Attribute Summary collapse

Attributes inherited from BaseClient

#account_sid, #last_request, #last_response

Instance Method Summary collapse

Methods inherited from BaseClient

host, #method

Methods included from Utils

#detwilify, #twilify

Methods included from Util

#get_string, #url_encode

Constructor Details

#initialize(*args) ⇒ TaskRouterClient

Instantiate a new HTTP TaskRouter client to talk to Twilio. 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.twilio.com'

The domain to which you’d like the client to make HTTP requests. Useful for testing. Defaults to ‘api.twilio.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 Twilio’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.



77
78
79
80
81
82
83
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 77

def initialize(*args)
  @workspace_sid = args[2]
  if @workspace_sid.nil?
    raise ArgumentError, 'Workspace SID is required'
  end
  super(*args)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object

Delegate workspace methods from the client. This saves having to call client.workspace every time for resources on the default workspace.



93
94
95
96
97
98
99
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 93

def method_missing(method_name, *args, &block)
  if workspace.respond_to?(method_name)
    workspace.send(method_name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#workspaceObject (readonly)

Returns the value of attribute workspace.



7
8
9
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 7

def workspace
  @workspace
end

#workspace_sidObject (readonly)

Returns the value of attribute workspace_sid.



7
8
9
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 7

def workspace_sid
  @workspace_sid
end

#workspacesObject (readonly)

Returns the value of attribute workspaces.



7
8
9
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 7

def workspaces
  @workspaces
end

Instance Method Details

#inspectObject

:nodoc:



85
86
87
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 85

def inspect # :nodoc:
  "<Twilio::REST::TaskRouterClient @account_sid=#{@account_sid}>"
end

#respond_to?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
104
105
106
107
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 101

def respond_to?(method_name, include_private=false)
  if workspace.respond_to?(method_name, include_private)
    true
  else
    super
  end
end

#task_queue_statistics(task_queue_sid, *args) ⇒ Object

Get statistics of a task queue.



111
112
113
114
115
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 111

def task_queue_statistics(task_queue_sid, *args) # :doc:
  warn "[DEPRECATED] task_queue_statistics is deprecated. " \
       "Please call client.task_queue.get(sid).statistics."
  task_queues.get(task_queue_sid).statistics
end

#task_queues_statistics(*args) ⇒ Object

Get statistics of task queues.



119
120
121
122
123
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 119

def task_queues_statistics(*args) # :doc:
  warn "[DEPRECATED] task_queues_statistics is deprecated. " \
       "Please call client.task_queues.statistics."
  task_queues.statistics
end

#worker_statistics(worker_sid, *args) ⇒ Object

Get statistics of a worker.



127
128
129
130
131
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 127

def worker_statistics(worker_sid, *args) # :doc:
  warn "[DEPRECATED] worker_statistics is deprecated. " \
       "Please call client.worker.get(sid).statistics."
  workers.get(worker_sid).statistics
end

#workers_statistics(*args) ⇒ Object

Get statistics of workers.



135
136
137
138
139
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 135

def workers_statistics(*args) # :doc:
  warn "[DEPRECATED] workers_statistics is deprecated. " \
       "Please call client.workers.statistics."
  workers.statistics
end

#workflow_statistics(workflow_sid, *args) ⇒ Object

Get statistics of a workflow.



143
144
145
146
147
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 143

def workflow_statistics(workflow_sid, *args) # :doc:
  warn "[DEPRECATED] workflow_statistics is deprecated. " \
       "Please call client.workflow.get(sid).statistics."
  workflows.get(workflow_sid).statistics
end

#workspace_statistics(*args) ⇒ Object

Get statistics of a workspace.



151
152
153
154
155
# File 'lib/twilio-ruby/rest/task_router_client.rb', line 151

def workspace_statistics(*args) # :doc:
  warn "[DEPRECATED] worker_statistics is deprecated. " \
       "Please call client.workspace.statistics."
  workspace.statistics
end