8000 Update URLs and allow Activities fetch by default · senthgit/twilio-java@af5afd3 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit af5afd3

Browse files
committed
Update URLs and allow Activities fetch by default
1 parent e307845 commit af5afd3

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/main/java/com/twilio/sdk/taskrouter/TaskRouterCapability.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public TaskRouterCapability(final String accountSid, final String authToken, fin
3838
this.workerSid = workerSid;
3939
this.policies = new ArrayList<Policy>();
4040
addEventBridgePolicies();
41+
allowActivityListFetch();
4142
}
4243

4344
/**
@@ -112,7 +113,7 @@ public String generateToken(long ttl) throws DomainException {
112113
}
113114

114115
private String getWorkspaceUrl() {
115-
return TASKROUTER_BASE_URL + "/" + TASKROUTER_VERSION + "/Accounts/" + accountSid + "/Workspaces/" + workspaceSid;
116+
return TASKROUTER_BASE_URL + "/" + TASKROUTER_VERSION + "/Workspaces/" + workspaceSid;
116117
}
117118

118119
private String getWorkerUrl() {
@@ -126,6 +127,11 @@ private void addEventBridgePolicies() {
126127
addPolicy(new Policy(eventBridgeUrl, "POST", true));
127128
}
128129

130+
private void allowActivityListFetch() {
131+
String url = getWorkspaceUrl() + "/Activities";
132+
addPolicy(new Policy(url, "GET", true));
133+
}
134+
129135
public class Policy implements JSONAware {
130136
private String url;
131137
private String method;

src/test/java/com/twilio/sdk/taskrouter/TaskRouterCapabilityTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import static org.junit.Assert.assertEquals;
1313
import static org.junit.Assert.assertNotNull;
14+
import static org.junit.Assert.assertTrue;
1415

1516
public class TaskRouterCapabilityTest {
1617

@@ -34,15 +35,19 @@ public void testGenerateToken() throws Exception {
3435
assertEquals("v1", o.get("version"));
3536
assertEquals("WS456", o.get("workspace_sid"));
3637
JSONArray policies = (JSONArray) o.get("policies");
37-
assertEquals(3, policies.size());
38+
assertEquals(4, policies.size());
3839
JSONObject p = (JSONObject) policies.get(0);
3940
assertEquals("https://event-bridge.twilio.com/v1/wschannels/AC123/WK789", p.get("url"));
4041
assertEquals("GET", p.get("method"));
4142
p = (JSONObject) policies.get(1);
4243
assertEquals("https://event-bridge.twilio.com/v1/wschannels/AC123/WK789", p.get("url"));
4344
assertEquals("POST", p.get("method"));
4445
p = (JSONObject) policies.get(2);
45-
assertEquals("https://taskrouter.twilio.com/v1/Accounts/AC123/Workspaces/WS456/Workers/WK789", p.get("url"));
46+
assertEquals("https://taskrouter.twilio.com/v1/Workspaces/WS456/Activities", p.get("url"));
47+
assertEquals("GET", p.get("method"));
48+
assertTrue((Boolean)p.get("allow"));
49+
p = (JSONObject) policies.get(3);
50+
assertEquals("https://taskrouter.twilio.com/v1/Workspaces/WS456/Workers/WK789", p.get("url"));
4651
assertEquals("POST", p.get("method"));
4752
JSONObject filters = (JSONObject) p.get("post_filter");
4853
assertEquals(1, filters.size());

0 commit comments

Comments
 (0)
0