-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ChatGrant, deprecate IpMessagingGrant (#382)
- Loading branch information
Showing
3 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.twilio.jwt.accesstoken; | ||
|
||
/** | ||
* Grant used to access Twilio Chat. | ||
* | ||
* <p> | ||
* For more information see: | ||
* <a href="https://www.twilio.com/docs/api/rest/access-tokens"> | ||
* https://www.twilio.com/docs/api/rest/access-tokens | ||
* </a> | ||
* </p> | ||
*/ | ||
public class ChatGrant implements Grant { | ||
|
||
private String serviceSid; | ||
private String deploymentRoleSid; | ||
private String pushCredentialSid; | ||
private String endpointId; | ||
|
||
public String getServiceSid() { | ||
return serviceSid; | ||
} | ||
|
||
public ChatGrant setServiceSid(String serviceSid) { | ||
this.serviceSid = serviceSid; | ||
return this; | ||
} | ||
|
||
|
||
public String getPushCredentialSid() { | ||
return pushCredentialSid; | ||
} | ||
|
||
public ChatGrant setPushCredentialSid(String pushCredentialSid) { | ||
this.pushCredentialSid = pushCredentialSid; | ||
return this; | ||
} | ||
|
||
public String getDeploymentRoleSid() { | ||
return deploymentRoleSid; | ||
} | ||
|
||
public ChatGrant setDeploymentRoleSid(String deploymentRoleSid) { | ||
this.deploymentRoleSid = deploymentRoleSid; | ||
return this; | ||
} | ||
|
||
public String getEndpointId() { | ||
return endpointId; | ||
} | ||
|
||
public ChatGrant setEndpointId(String endpointId) { | ||
this.endpointId = endpointId; | ||
return this; | ||
} | ||
|
||
public String getGrantKey() { | ||
return "chat"; | ||
} | ||
|
||
public Object getPayload() { | ||
return new Payload(this); | ||
} | ||
|
||
@SuppressWarnings("checkstyle:membername") | ||
public class Payload { | ||
public final String service_sid; | ||
public final String deployment_role_sid; | ||
public final String endpoint_id; | ||
public final String push_credential_sid; | ||
|
||
/** | ||
* Create the grant payload. | ||
* | ||
* @param grant IP Messaging grant | ||
*/ | ||
public Payload(ChatGrant grant) { | ||
this.service_sid = grant.serviceSid; | ||
this.deployment_role_sid = grant.deploymentRoleSid; | ||
this.endpoint_id = grant.endpointId; | ||
this.push_credential_sid = grant.pushCredentialSid; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters