Skip to content

Commit edfd357

Browse files
authored
Merge pull request TwilioDevEd#351 from TwilioDevEd/fix-java-samples
Fixing java snippets
2 parents 423002c + 44a353d commit edfd357

File tree

8 files changed

+23
-15
lines changed

8 files changed

+23
-15
lines changed

rest/access-tokens/video-example/video-example.7.x.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import com.twilio.jwt.accesstoken.VideoGrant;
33

44
public class TokenGenerator {
5-
5+
66
public static void main(String[] args) {
77
// Required for all types of tokens
88
String twilioAccountSid = "ACxxxxxxxxxxxx";
@@ -11,11 +11,10 @@ public static void main(String[] args) {
1111

1212
// Required for Video
1313
String identity = "user";
14-
14+
1515
// Create Video grant
16-
VideoGrant grant = new VideoGrant();
17-
grant.setRoom("cool room");
18-
16+
VideoGrant grant = new VideoGrant().setRoom("cool room");
17+
1918
// Create access token
2019
AccessToken token = new AccessToken.Builder(
2120
twilioAccountSid,

rest/change-call-state/list-get-example-2/list-get-example-2.7.x.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ public static void main(String[] args) {
1212

1313
// Get an object from its sid. If you do not have a sid,
1414
// check out the list resource examples on this page
15-
Call call = Call.updater("CAe1644a7eed5088b159577c5802d8be38").setStatus(Call.UpdateStatus.COMPLETED)
16-
.update();
15+
Call call = Call.updater("CAe1644a7eed5088b159577c5802d8be38")
16+
.setStatus(Call.UpdateStatus.COMPLETED)
17+
.update();
1718

1819
System.out.println(call.getDateUpdated());
1920
}

rest/message/instance-post-example-1/instance-post-example-1.7.x.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ public static void main(String[] args) {
1313

1414
// Get an object from its sid. If you do not have a sid,
1515
// check out the list resource examples on this page
16-
Message message = Message.updater("MM5ef8732a3c49700934481addd5ce1659").setBody("").update();
16+
String messageSid = "MM5ef8732a3c49700934481addd5ce1659";
17+
String body = "";
18+
Message message = Message.updater(messageSid, body).update();
1719

1820
System.out.println(message.getBody()); // will be empty string
1921
}
2022
}
21-

rest/queue/list-post-example-1/list-post-example-1.7.x.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class Example {
1010
public static void main(String[] args) {
1111
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
1212

13-
Queue queue = Queue.creator().setFriendlyName("newqueue").create();
13+
Queue queue = Queue.creator("newqueue").create();
1414

1515
System.out.println(queue.getSid());
1616
}

rest/taskrouter/activities/instance/post/example-1/example-1.7.x.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ public class Example {
1212
public static void main(String[] args) {
1313
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
1414

15-
Activity activity =
16-
Activity.updater(WORKSPACE_SID, ACTIVITY_SID, "NewAvailableFriendlyName").update();
15+
Activity activity = Activity.updater(WORKSPACE_SID, ACTIVITY_SID)
16+
.setFriendlyName("NewAvailableFriendlyName")
17+
.update();
18+
1719
}
1820
}

rest/taskrouter/tasks/list/get/example-2/example-2.7.x.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public static void main(String[] args) {
1818
System.out.println(task.getAttributes());
1919
}
2020

21-
tasks = Task.reader(WORKSPACE_SID).setAssignmentStatus(Task.Status.PENDING).read();
21+
tasks = Task.reader(WORKSPACE_SID)
22+
.setAssignmentStatus(Task.Status.PENDING.toString())
23+
.read();
2224

2325
for (Task task : tasks) {
2426
System.out.println(task.getAttributes());

rest/taskrouter/tasks/list/post/example-1/example-1.7.x.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ public class Example {
1111
public static void main(String[] args) {
1212
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
1313

14-
Task task = Task.creator(WORKSPACE_SID, "{\"type\":\"support\"}", WORKFLOW_SID).create();
14+
Task task = Task.creator(WORKSPACE_SID)
15+
.setWorkflowSid( WORKFLOW_SID)
16+
.setAttributes("{\"type\":\"support\"}")
17+
.create();
1518

1619
System.out.println(task.getAttributes());
1720
}

tools/snippet-testing/language_handler/file-templates/build.7.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88
}
99

1010
dependencies {
11-
compile group: 'com.twilio.sdk', name: 'twilio', version: '7.1.0-alpha-1'
11+
compile group: 'com.twilio.sdk', name: 'twilio', version: '7.9.1-alpha-1'
1212
}
1313

1414
task wrapper(type: Wrapper) {

0 commit comments

Comments
 (0)