Skip to content

Commit 4aadab9

Browse files
committed
fix: Update snippets to work with v9.0.0
1 parent 5ea1e65 commit 4aadab9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+288
-1057
lines changed

SNIPPETS.md

+210-173
Large diffs are not rendered by default.

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ java {
1414

1515
dependencies {
1616
implementation 'io.github.cdimascio:dotenv-java:3.+'
17-
implementation 'com.vonage:server-sdk:8.+'
17+
implementation 'com.vonage:server-sdk:9.+'
1818
implementation 'com.vonage:jwt:2.+'
1919
implementation 'com.sparkjava:spark-core:2.+'
2020
implementation 'com.fasterxml.jackson.core:jackson-databind:2.+'

src/main/java/com/vonage/quickstart/EnvironmentVariables.java

+7-11
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@
2323

2424
import com.vonage.client.ApiRegion;
2525
import com.vonage.client.conversations.MemberState;
26-
import com.vonage.client.numbers.Feature;
27-
import com.vonage.client.numbers.SearchPattern;
28-
import com.vonage.client.numbers.Type;
29-
import com.vonage.client.numbers.UpdateNumberRequest;
26+
import com.vonage.client.numbers.*;
3027
import com.vonage.client.verify.Psd2Request;
3128
import com.vonage.client.verify.VerifyRequest;
29+
import com.vonage.client.verify.Workflow;
3230
import com.vonage.client.voice.TextToSpeechLanguage;
3331
import io.github.cdimascio.dotenv.Dotenv;
3432
import java.time.Instant;
@@ -199,14 +197,12 @@ public static String envVar(String key) {
199197
public static final SearchPattern
200198
NUMBER_SEARCH_PATTERN = SearchPattern.values()[Integer.parseInt(envVar("NUMBER_SEARCH_PATTERN"))];
201199

202-
public static final UpdateNumberRequest.CallbackType
203-
NUMBER_VOICE_CALLBACK_TYPE = UpdateNumberRequest.CallbackType.fromString(envVar("NUMBER_VOICE_CALLBACK_TYPE"));
200+
public static final CallbackType
201+
NUMBER_VOICE_CALLBACK_TYPE = CallbackType.fromString(envVar("NUMBER_VOICE_CALLBACK_TYPE"));
204202

205-
public static final VerifyRequest.Workflow
206-
VERIFY_WORKFLOW_ID = VerifyRequest.Workflow.values()[Integer.parseInt(envVar("VERIFY_WORKFLOW_ID")) + 1];
207-
208-
public static final Psd2Request.Workflow
209-
VERIFY_PSD2_WORKFLOW_ID = Psd2Request.Workflow.values()[Integer.parseInt(envVar("VERIFY_WORKFLOW_ID")) + 1];
203+
public static final Workflow
204+
VERIFY_WORKFLOW_ID = Workflow.values()[Integer.parseInt(envVar("VERIFY_WORKFLOW_ID")) + 1],
205+
VERIFY_PSD2_WORKFLOW_ID = Workflow.values()[Integer.parseInt(envVar("VERIFY_WORKFLOW_ID")) + 1];
210206

211207
public static final TextToSpeechLanguage
212208
VOICE_LANGUAGE = TextToSpeechLanguage.valueOf(envVar("VOICE_LANGUAGE"));

src/main/java/com/vonage/quickstart/account/ListSecrets.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
package com.vonage.quickstart.account;
2323

2424
import com.vonage.client.VonageClient;
25-
import com.vonage.client.account.ListSecretsResponse;
2625
import com.vonage.client.account.SecretResponse;
2726
import static com.vonage.quickstart.EnvironmentVariables.*;
27+
import java.util.List;
2828

2929
public class ListSecrets {
3030
public static void main(String[] args) {
@@ -33,9 +33,9 @@ public static void main(String[] args) {
3333
.apiSecret(VONAGE_API_SECRET)
3434
.build();
3535

36-
ListSecretsResponse response = client.getAccountClient().listSecrets(ACCOUNT_ID);
36+
List<SecretResponse> response = client.getAccountClient().listSecrets(ACCOUNT_ID);
3737

38-
for (SecretResponse secret : response.getSecrets()) {
38+
for (SecretResponse secret : response) {
3939
System.out.println(secret.getId() + " created at " + secret.getCreated());
4040
}
4141
}

src/main/java/com/vonage/quickstart/application/CreateApplication.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import com.vonage.client.VonageClient;
2525
import com.vonage.client.application.Application;
2626
import com.vonage.client.application.capabilities.Messages;
27+
import com.vonage.client.application.capabilities.Webhook;
2728
import com.vonage.client.common.HttpMethod;
28-
import com.vonage.client.common.Webhook;
2929

3030
import static com.vonage.quickstart.EnvironmentVariables.*;
3131

@@ -40,10 +40,16 @@ public static void main(String... args) {
4040
Application.builder()
4141
.name(APPLICATION_NAME)
4242
.addCapability(Messages.builder()
43-
.addWebhook(Webhook.Type.INBOUND,
44-
new Webhook("https://example.com/webhooks/inbound", HttpMethod.POST))
45-
.addWebhook(Webhook.Type.STATUS,
46-
new Webhook("https://example.com/webhooks/status", HttpMethod.POST))
43+
.inbound(Webhook.builder()
44+
.address("https://example.com/webhooks/inbound")
45+
.method(HttpMethod.POST)
46+
.build()
47+
)
48+
.status(Webhook.builder()
49+
.address("https://example.com/webhooks/status")
50+
.method(HttpMethod.POST)
51+
.build()
52+
)
4753
.build()
4854
)
4955
.build()

src/main/java/com/vonage/quickstart/application/UpdateApplication.java

+25-11
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.vonage.client.application.ApplicationClient;
2727
import com.vonage.client.application.capabilities.*;
2828
import com.vonage.client.common.HttpMethod;
29-
import com.vonage.client.common.Webhook;
3029

3130
import static com.vonage.quickstart.EnvironmentVariables.*;
3231

@@ -41,22 +40,37 @@ public static void main(String... args) {
4140
Application existingApplication = applicationClient.getApplication(VONAGE_APPLICATION_ID);
4241

4342
Capability messages = Messages.builder()
44-
.addWebhook(Webhook.Type.INBOUND,
45-
new Webhook("https://example.com/webhooks/inbound", HttpMethod.POST))
46-
.addWebhook(Webhook.Type.STATUS,
47-
new Webhook("https://example.com/webhooks/status", HttpMethod.POST))
43+
.inbound(Webhook.builder()
44+
.address("https://example.com/webhooks/inbound")
45+
.method(HttpMethod.POST)
46+
.build()
47+
)
48+
.status(Webhook.builder()
49+
.address("https://example.com/webhooks/status")
50+
.method(HttpMethod.POST)
51+
.build()
52+
)
4853
.build();
4954

5055
Capability voice = Voice.builder()
51-
.addWebhook(Webhook.Type.ANSWER,
52-
new Webhook("https://example.com/webhooks/answer", HttpMethod.POST))
53-
.addWebhook(Webhook.Type.EVENT,
54-
new Webhook("https://example.com/webhooks/event", HttpMethod.POST))
56+
.answer(Webhook.builder()
57+
.address("https://example.com/webhooks/answer")
58+
.method(HttpMethod.POST)
59+
.build()
60+
)
61+
.event(Webhook.builder()
62+
.address("https://example.com/webhooks/event")
63+
.method(HttpMethod.POST)
64+
.build()
65+
)
5566
.build();
5667

5768
Capability rtc = Rtc.builder()
58-
.addWebhook(Webhook.Type.EVENT,
59-
new Webhook("https://example.com/webhooks/event", HttpMethod.POST))
69+
.event(Webhook.builder()
70+
.address("https://example.com/webhooks/event")
71+
.method(HttpMethod.POST)
72+
.build()
73+
)
6074
.build();
6175

6276
Capability vbc = Vbc.builder().build();

src/main/java/com/vonage/quickstart/conversation/CreateCustomEvent.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void main(String[] args) throws Exception {
3434
.build();
3535

3636
var event = client.getConversationsClient().createEvent(
37-
CONV_ID, CustomEvent.builder()
37+
CONV_ID, CustomEvent.builder("my_custom_event_name")
3838
.from(CONV_MEMBER_ID)
3939
.body(Map.of("your", "data"))
4040
.build()

src/main/java/com/vonage/quickstart/insight/AdvancedInsight.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.vonage.client.VonageClient;
2525
import com.vonage.client.insight.AdvancedInsightResponse;
2626
import com.vonage.client.insight.RoamingDetails;
27+
import com.vonage.client.insight.RoamingStatus;
2728
import static com.vonage.quickstart.EnvironmentVariables.*;
2829

2930
public class AdvancedInsight {
@@ -59,7 +60,7 @@ public static void main(String[] args) throws Exception {
5960
}
6061
else {
6162
System.out.println("Roaming status: " + roaming.getStatus());
62-
if (response.getRoaming().getStatus() == RoamingDetails.RoamingStatus.ROAMING) {
63+
if (response.getRoaming().getStatus() == RoamingStatus.ROAMING) {
6364
System.out.print(" Currently roaming in: " + roaming.getRoamingCountryCode());
6465
System.out.println(" on the network " + roaming.getRoamingNetworkName());
6566
}

src/main/java/com/vonage/quickstart/insight/AdvancedInsightAsync.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
package com.vonage.quickstart.insight;
2323

2424
import com.vonage.client.VonageClient;
25+
import com.vonage.client.insight.AdvancedInsightAsyncRequest;
2526
import com.vonage.client.insight.AdvancedInsightRequest;
2627
import static com.vonage.quickstart.EnvironmentVariables.*;
2728

@@ -32,9 +33,11 @@ public static void main(String... args) {
3233
.apiSecret(VONAGE_API_SECRET)
3334
.build();
3435

35-
client.getInsightClient().getAdvancedNumberInsight(
36-
AdvancedInsightRequest.builder(INSIGHT_NUMBER)
37-
.async(true).callback(INSIGHT_CALLBACK_URL).build()
36+
var response = client.getInsightClient().getAdvancedAsyncNumberInsight(
37+
AdvancedInsightAsyncRequest.builder()
38+
.number(INSIGHT_NUMBER)
39+
.callback(INSIGHT_CALLBACK_URL)
40+
.build()
3841
);
3942
}
4043
}

src/main/java/com/vonage/quickstart/insight/AdvancedInsightWithCnam.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.vonage.client.insight.AdvancedInsightResponse;
2727
import com.vonage.client.insight.RoamingDetails;
2828

29+
import com.vonage.client.insight.RoamingStatus;
2930
import static com.vonage.quickstart.EnvironmentVariables.*;
3031

3132
public class AdvancedInsightWithCnam {
@@ -61,7 +62,7 @@ public static void main(String[] args) throws Exception {
6162
}
6263
else {
6364
System.out.println("Roaming status: " + roaming.getStatus());
64-
if (response.getRoaming().getStatus() == RoamingDetails.RoamingStatus.ROAMING) {
65+
if (response.getRoaming().getStatus() == RoamingStatus.ROAMING) {
6566
System.out.print(" Currently roaming in: " + roaming.getRoamingCountryCode());
6667
System.out.println(" on the network " + roaming.getRoamingNetworkName());
6768
}

src/main/java/com/vonage/quickstart/insight/AsyncInsightTrigger.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222
package com.vonage.quickstart.insight;
2323

24+
import com.vonage.client.Jsonable;
2425
import com.vonage.client.insight.AdvancedInsightResponse;
2526
import spark.Spark;
2627

@@ -30,7 +31,7 @@ public class AsyncInsightTrigger {
3031
public static void main(String... args) {
3132
port(3000);
3233
Spark.post("/webhooks/insight", (req, res) -> {
33-
AdvancedInsightResponse response = AdvancedInsightResponse.fromJson(req.body());
34+
AdvancedInsightResponse response = Jsonable.fromJson(req.body());
3435
System.out.println("Country: " + response.getCountryName());
3536

3637
res.status(204);

src/main/java/com/vonage/quickstart/meetings/CreateInstantRoom.java

-42
This file was deleted.

src/main/java/com/vonage/quickstart/meetings/CreateLongTermRoom.java

-47
This file was deleted.

src/main/java/com/vonage/quickstart/meetings/CreateTheme.java

-42
This file was deleted.

0 commit comments

Comments
 (0)