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



119
120
121
# File 'lib/twilio-ruby/jwt/task_router.rb', line 119

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

.activity(workspace_sid, activity_sid) ⇒ Object



123
124
125
# File 'lib/twilio-ruby/jwt/task_router.rb', line 123

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

.all_activities(workspace_sid) ⇒ Object



127
128
129
# File 'lib/twilio-ruby/jwt/task_router.rb', line 127

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

.all_reservations(workspace_sid, worker_sid) ⇒ Object



151
152
153
# File 'lib/twilio-ruby/jwt/task_router.rb', line 151

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

.all_task_queues(workspace_sid) ⇒ Object



115
116
117
# File 'lib/twilio-ruby/jwt/task_router.rb', line 115

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

.all_tasks(workspace_sid) ⇒ Object



103
104
105
# File 'lib/twilio-ruby/jwt/task_router.rb', line 103

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

.all_workers(workspace_sid) ⇒ Object



139
140
141
# File 'lib/twilio-ruby/jwt/task_router.rb', line 139

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

.all_workspacesObject



91
92
93
# File 'lib/twilio-ruby/jwt/task_router.rb', line 91

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

.reservation(workspace_sid, worker_sid, reservation_sid) ⇒ Object



147
148
149
# File 'lib/twilio-ruby/jwt/task_router.rb', line 147

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



143
144
145
# File 'lib/twilio-ruby/jwt/task_router.rb', line 143

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

.task(workspace_sid, tasks_sid) ⇒ Object



99
100
101
# File 'lib/twilio-ruby/jwt/task_router.rb', line 99

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

.task_queue(workspace_sid, taskqueue_sid) ⇒ Object



111
112
113
# File 'lib/twilio-ruby/jwt/task_router.rb', line 111

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

.task_queues(workspace_sid) ⇒ Object



107
108
109
# File 'lib/twilio-ruby/jwt/task_router.rb', line 107

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

.tasks(workspace_sid) ⇒ Object



95
96
97
# File 'lib/twilio-ruby/jwt/task_router.rb', line 95

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

.web_socket_policies(account_sid, channel_sid) ⇒ Object



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

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



135
136
137
# File 'lib/twilio-ruby/jwt/task_router.rb', line 135

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

.worker_policies(workspace_sid, worker_sid) ⇒ Object



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

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



131
132
133
# File 'lib/twilio-ruby/jwt/task_router.rb', line 131

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

.workspace(workspace_sid) ⇒ Object



87
88
89
# File 'lib/twilio-ruby/jwt/task_router.rb', line 87

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

.workspacesObject



83
84
85
# File 'lib/twilio-ruby/jwt/task_router.rb', line 83

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