Class: Twilio::JWT::TaskRouterCapability::TaskRouterUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/twilio-ruby/jwt/task_router.rb

Constant Summary collapse

TASK_ROUTER_VERSION =
'v1'.freeze
TASK_ROUTER_BASE_URL =
'https://taskrouter.twilio.com'.freeze
TASK_ROUTER_WEBSOCKET_BASE_URL =
'https://event-bridge.twilio.com/v1/wschannels'.freeze

Class Method Summary collapse

Class Method Details

.activities(workspace_sid) ⇒ Object



117
118
119
# File 'lib/twilio-ruby/jwt/task_router.rb', line 117

def self.activities(workspace_sid)
  [workspace(workspace_sid), 'Activities'].join('/')
end

.activity(workspace_sid, activity_sid) ⇒ Object



121
122
123
# File 'lib/twilio-ruby/jwt/task_router.rb', line 121

def self.activity(workspace_sid, activity_sid)
  [workspace(workspace_sid), 'Activities', activity_sid].join('/')
end

.all_activities(workspace_sid) ⇒ Object



125
126
127
# File 'lib/twilio-ruby/jwt/task_router.rb', line 125

def self.all_activities(workspace_sid)
  [workspace(workspace_sid), 'Activities', '**'].join('/')
end

.all_reservations(workspace_sid, worker_sid) ⇒ Object



149
150
151
# File 'lib/twilio-ruby/jwt/task_router.rb', line 149

def self.all_reservations(workspace_sid, worker_sid)
  [worker(workspace_sid, worker_sid), 'Reservations', '**'].join('/')
end

.all_task_queues(workspace_sid) ⇒ Object



113
114
115
# File 'lib/twilio-ruby/jwt/task_router.rb', line 113

def self.all_task_queues(workspace_sid)
  [workspace(workspace_sid), 'TaskQueues', '**'].join('/')
end

.all_tasks(workspace_sid) ⇒ Object



101
102
103
# File 'lib/twilio-ruby/jwt/task_router.rb', line 101

def self.all_tasks(workspace_sid)
  [workspace(workspace_sid), 'Tasks', '**'].join('/')
end

.all_workers(workspace_sid) ⇒ Object



137
138
139
# File 'lib/twilio-ruby/jwt/task_router.rb', line 137

def self.all_workers(workspace_sid)
  [workspace(workspace_sid), 'Workers', '**'].join('/')
end

.all_workspacesObject



89
90
91
# File 'lib/twilio-ruby/jwt/task_router.rb', line 89

def self.all_workspaces
  [TASK_ROUTER_BASE_URL, TASK_ROUTER_VERSION, 'Workspaces', '**'].join('/')
end

.reservation(workspace_sid, worker_sid, reservation_sid) ⇒ Object



145
146
147
# File 'lib/twilio-ruby/jwt/task_router.rb', line 145

def self.reservation(workspace_sid, worker_sid, reservation_sid)
  [worker(workspace_sid, worker_sid), 'Reservations', reservation_sid].join('/')
end

.reservations(workspace_sid, worker_sid) ⇒ Object



141
142
143
# File 'lib/twilio-ruby/jwt/task_router.rb', line 141

def self.reservations(workspace_sid, worker_sid)
  [worker(workspace_sid, worker_sid), 'Reservations'].join('/')
end

.task(workspace_sid, tasks_sid) ⇒ Object



97
98
99
# File 'lib/twilio-ruby/jwt/task_router.rb', line 97

def self.task(workspace_sid, tasks_sid)
  [workspace(workspace_sid), 'Tasks', tasks_sid].join('/')
end

.task_queue(workspace_sid, taskqueue_sid) ⇒ Object



109
110
111
# File 'lib/twilio-ruby/jwt/task_router.rb', line 109

def self.task_queue(workspace_sid, taskqueue_sid)
  [workspace(workspace_sid), 'TaskQueues', taskqueue_sid].join('/')
end

.task_queues(workspace_sid) ⇒ Object



105
106
107
# File 'lib/twilio-ruby/jwt/task_router.rb', line 105

def self.task_queues(workspace_sid)
  [workspace(workspace_sid), 'TaskQueues'].join('/')
end

.tasks(workspace_sid) ⇒ Object



93
94
95
# File 'lib/twilio-ruby/jwt/task_router.rb', line 93

def self.tasks(workspace_sid)
  [workspace(workspace_sid), 'Tasks'].join('/')
end

.web_socket_policies(account_sid, channel_sid) ⇒ Object



153
154
155
156
157
158
# File 'lib/twilio-ruby/jwt/task_router.rb', line 153

def self.web_socket_policies(, channel_sid)
  url = [TASK_ROUTER_WEBSOCKET_BASE_URL, , channel_sid].join('/')
  get = Policy.new(url, 'GET', true)
  post = Policy.new(url, 'POST', true)
  [get, post]
end

.worker(workspace_sid, worker_sid) ⇒ Object



133
134
135
# File 'lib/twilio-ruby/jwt/task_router.rb', line 133

def self.worker(workspace_sid, worker_sid)
  [workspace(workspace_sid), 'Workers', worker_sid].join('/')
end

.worker_policies(workspace_sid, worker_sid) ⇒ Object



160
161
162
163
164
165
166
# File 'lib/twilio-ruby/jwt/task_router.rb', line 160

def self.worker_policies(workspace_sid, worker_sid)
  activities = Policy.new(self.activities(workspace_sid), 'GET', true)
  tasks = Policy.new(all_tasks(workspace_sid), 'GET', true)
  reservations = Policy.new(all_reservations(workspace_sid, worker_sid), 'GET', true)
  fetch = Policy.new(worker(workspace_sid, worker_sid), 'GET', true)
  [activities, tasks, reservations, fetch]
end

.workers(workspace_sid) ⇒ Object



129
130
131
# File 'lib/twilio-ruby/jwt/task_router.rb', line 129

def self.workers(workspace_sid)
  [workspace(workspace_sid), 'Workers'].join('/')
end

.workspace(worskspace_sid) ⇒ Object



85
86
87
# File 'lib/twilio-ruby/jwt/task_router.rb', line 85

def self.workspace(worskspace_sid)
  [TASK_ROUTER_BASE_URL, TASK_ROUTER_VERSION, 'Workspaces', worskspace_sid].join('/')
end

.workspacesObject



81
82
83
# File 'lib/twilio-ruby/jwt/task_router.rb', line 81

def self.workspaces
  [TASK_ROUTER_BASE_URL, TASK_ROUTER_VERSION, 'Workspaces'].join('/')
end