Skip to content

Commit

Permalink
removing capability token and adding taskrouter grant
Browse files Browse the repository at this point in the history
  • Loading branch information
odv-caring committed Oct 6, 2021
1 parent 6326240 commit 6bd1f66
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 243 deletions.
37 changes: 37 additions & 0 deletions token/access_token_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const (
conversationsGrant = "rtc"
voiceGrant = "voice"
videoGrant = "video"
taskrouterGrant = "task_router"
keyWorkspaceSid = "workspace_sid"
keyWorkerSid = "worker_sid"
keyRole = "role"
keyServiceSid = "service_sid"
keyEndpointId = "endpoint_id"
keyDepRoleSide = "deployment_role_sid"
Expand All @@ -28,6 +32,39 @@ type Grant interface {
Key() string
}

// TaskrouterGrant is a grant for accessing Taskrouter
type TaskrouterGrant struct {
workspaceSid string
workerSid string
role string
}

func NewTaskRouterGrant(workspaceSid, workerSid, role string) *TaskrouterGrant {
return &TaskrouterGrant{
workspaceSid: workspaceSid,
workerSid: workerSid,
role: role,
}
}

func (gr *TaskrouterGrant) ToPayload() map[string]interface{} {
grant := make(map[string]interface{})
if len(gr.workspaceSid) > 0 {
grant[keyWorkspaceSid] = gr.workspaceSid
}
if len(gr.workerSid) > 0 {
grant[keyWorkerSid] = gr.workerSid
}
if len(gr.role) > 0 {
grant[keyRole] = gr.role
}
return grant
}

func (gr *TaskrouterGrant) Key() string {
return taskrouterGrant
}

// IPMessageGrant is a grant for accessing Twilio IP Messaging
type IPMessageGrant struct {
serviceSid string
Expand Down
199 changes: 0 additions & 199 deletions token/capability_token.go

This file was deleted.

44 changes: 0 additions & 44 deletions token/capability_token_test.go

This file was deleted.

0 comments on commit 6bd1f66

Please sign in to comment.