Skip to content

Commit 628cce1

Browse files
committed
Tidy up SNIPPETS.md
1 parent 07ce5cd commit 628cce1

File tree

3 files changed

+62
-43
lines changed

3 files changed

+62
-43
lines changed

SNIPPETS.md

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file was generated by running [AggregateSnippets.java](src/main/java/Aggreg
66
- [**Initialize**](#initialize)
77
- [**Account**](#account)
88
- [**Application**](#application)
9-
- [**Insight**](#insight)
9+
- [**Number Insight**](#number-insight)
1010
- [**JWT**](#jwt)
1111
- [**Meetings**](#meetings)
1212
- [**Messages**](#messages)
@@ -90,6 +90,7 @@ ListSecretsResponse response = client.getAccountClient().listSecrets(VONAGE_API_
9090

9191
for (SecretResponse secret : response.getSecrets()) {
9292
System.out.println(secret.getId() + " created at " + secret.getCreated());
93+
}
9394
```
9495
## Application
9596
### Delete Application
@@ -173,7 +174,7 @@ System.out.println("Application Updated:");
173174
System.out.println("Old: " + existingApplication.toJson());
174175
System.out.println("New: " + application.toJson());
175176
```
176-
## Insight
177+
## Number Insight
177178
### Basic Insight
178179

179180
```java
@@ -215,6 +216,8 @@ else {
215216
if (response.getRoaming().getStatus() == RoamingDetails.RoamingStatus.ROAMING) {
216217
System.out.print(" Currently roaming in: " + roaming.getRoamingCountryCode());
217218
System.out.println(" on the network " + roaming.getRoamingNetworkName());
219+
}
220+
}
218221
```
219222
### Standard Insight
220223

@@ -241,47 +244,46 @@ client.getInsightClient().getAdvancedNumberInsight(
241244
.async(true).callback(CALLBACK_URL).build()
242245
);
243246
```
244-
### Advanced Insight With Cnam
247+
### Advanced Insight With CNAM
245248

246249
```java
247-
AdvancedInsightRequest request = AdvancedInsightRequest.builder(INSIGHT_NUMBER).cnam(true).build();
250+
AdvancedInsightRequest request = AdvancedInsightRequest.builder(INSIGHT_NUMBER).cnam(true).build();
248251

249-
AdvancedInsightResponse response = client.getInsightClient().getAdvancedNumberInsight(request);
252+
AdvancedInsightResponse response = client.getInsightClient().getAdvancedNumberInsight(request);
250253

251-
printResults(response);
252-
}
254+
System.out.println(response);
253255

254-
private static void printResults(AdvancedInsightResponse response) {
255-
System.out.println("BASIC INFO:");
256-
System.out.println("International format: " + response.getInternationalFormatNumber());
257-
System.out.println("National format: " + response.getNationalFormatNumber());
258-
System.out.println("Country: " + response.getCountryName() + " (" + response.getCountryCodeIso3() + ", +"
259-
+ response.getCountryPrefix() + ")");
260-
System.out.println();
261-
System.out.println("STANDARD INFO:");
262-
System.out.println("Current carrier: " + response.getCurrentCarrier().getName());
263-
System.out.println("Original carrier: " + response.getOriginalCarrier().getName());
264-
265-
System.out.println();
266-
System.out.println("ADVANCED INFO:");
267-
System.out.println("Validity: " + response.getValidNumber());
268-
System.out.println("Reachability: " + response.getReachability());
269-
System.out.println("Ported status: " + response.getPorted());
270-
271-
RoamingDetails roaming = response.getRoaming();
272-
if (roaming == null) {
273-
System.out.println("- No Roaming Info -");
274-
} else {
275-
System.out.println("Roaming status: " + roaming.getStatus());
276-
if (response.getRoaming().getStatus() == RoamingDetails.RoamingStatus.ROAMING) {
277-
System.out.print(" Currently roaming in: " + roaming.getRoamingCountryCode());
278-
System.out.println(" on the network " + roaming.getRoamingNetworkName());
279-
}
256+
System.out.println("BASIC INFO:");
257+
System.out.println("International format: " + response.getInternationalFormatNumber());
258+
System.out.println("National format: " + response.getNationalFormatNumber());
259+
System.out.println("Country: " + response.getCountryName() + " (" + response.getCountryCodeIso3() + ", +"
260+
+ response.getCountryPrefix() + ")");
261+
System.out.println();
262+
System.out.println("STANDARD INFO:");
263+
System.out.println("Current carrier: " + response.getCurrentCarrier().getName());
264+
System.out.println("Original carrier: " + response.getOriginalCarrier().getName());
265+
266+
System.out.println();
267+
System.out.println("ADVANCED INFO:");
268+
System.out.println("Validity: " + response.getValidNumber());
269+
System.out.println("Reachability: " + response.getReachability());
270+
System.out.println("Ported status: " + response.getPorted());
271+
272+
RoamingDetails roaming = response.getRoaming();
273+
if (roaming == null) {
274+
System.out.println("- No Roaming Info -");
275+
}
276+
else {
277+
System.out.println("Roaming status: " + roaming.getStatus());
278+
if (response.getRoaming().getStatus() == RoamingDetails.RoamingStatus.ROAMING) {
279+
System.out.print(" Currently roaming in: " + roaming.getRoamingCountryCode());
280+
System.out.println(" on the network " + roaming.getRoamingNetworkName());
280281
}
282+
}
281283

282-
System.out.println("CNAM INFORMATION:");
283-
System.out.println("Name: " + response.getCallerIdentity().getName());
284-
System.out.println("Type: " + response.getCallerIdentity().getType());
284+
System.out.println("CNAM INFORMATION:");
285+
System.out.println("Name: " + response.getCallerIdentity().getName());
286+
System.out.println("Type: " + response.getCallerIdentity().getType());
285287
```
286288
### Async Insight Trigger
287289

@@ -1872,6 +1874,7 @@ System.out.println("Here are "
18721874
for (AvailableNumber number : response.getNumbers()) {
18731875
System.out.println("Tel: " + number.getMsisdn());
18741876
System.out.println("Cost: " + number.getCost());
1877+
}
18751878
```
18761879
### Update Number
18771880

@@ -1897,6 +1900,7 @@ for (OwnedNumber number : response.getNumbers()) {
18971900
System.out.println("Tel: " + number.getMsisdn());
18981901
System.out.println("Type: " + number.getType());
18991902
System.out.println("Country: " + number.getCountry());
1903+
}
19001904
```
19011905
## Redact
19021906
### RedactA Transaction
@@ -2042,6 +2046,7 @@ SmsSubmissionResponse responses = client.getSmsClient().submitMessage(message);
20422046

20432047
for (SmsSubmissionResponseMessage responseMessage : responses.getMessages()) {
20442048
System.out.println(message);
2049+
}
20452050
```
20462051
### Send Message
20472052

@@ -2057,6 +2062,7 @@ if (response.getMessages().get(0).getStatus() == MessageStatus.OK) {
20572062
System.out.println("Message sent successfully.");
20582063
} else {
20592064
System.out.println("Message failed with error: " + response.getMessages().get(0).getErrorText());
2065+
}
20602066
```
20612067
### Send Signed SMS
20622068

@@ -2118,6 +2124,7 @@ public class SendSignedSms {
21182124
System.out.println("Message sent successfully.");
21192125
} else {
21202126
System.out.println("Message failed with error: " + response.getMessages().get(0).getErrorText());
2127+
}
21212128
```
21222129
## Subaccounts
21232130
### Transfer Credit
@@ -2261,6 +2268,7 @@ if (errorText != null) {
22612268
}
22622269
else {
22632270
System.out.println("Verification cancelled.");
2271+
}
22642272
```
22652273
### Advance Verification
22662274

@@ -2273,6 +2281,7 @@ if (errorText != null) {
22732281
}
22742282
else {
22752283
System.out.println("Verification advanced to next stage!");
2284+
}
22762285
```
22772286
### Start Verification With Workflow
22782287

@@ -2286,6 +2295,7 @@ if (response.getStatus() == VerifyStatus.OK) {
22862295
}
22872296
else {
22882297
System.out.printf("ERROR! %s: %s", response.getStatus(), response.getErrorText());
2298+
}
22892299
```
22902300
### Search Verification
22912301

@@ -2295,6 +2305,7 @@ if (response.getStatus() == VerifyStatus.OK) {
22952305
response.getVerificationRequests().forEach(it -> {
22962306
System.out.println(it.getRequestId() + " " + it.getStatus());
22972307
});
2308+
}
22982309
```
22992310
### Check Verification
23002311

@@ -2306,6 +2317,7 @@ if (response.getStatus() == VerifyStatus.OK) {
23062317
}
23072318
else {
23082319
System.out.println("Verification failed: " + response.getErrorText());
2320+
}
23092321
```
23102322
### Start Verification
23112323

@@ -2317,6 +2329,7 @@ if (response.getStatus() == VerifyStatus.OK) {
23172329
}
23182330
else {
23192331
System.out.printf("ERROR! %s: %s", response.getStatus(), response.getErrorText());
2332+
}
23202333
```
23212334
### Start PSD2 Verification With Workflow
23222335

@@ -2330,6 +2343,7 @@ if (response.getStatus() == VerifyStatus.OK) {
23302343
}
23312344
else {
23322345
System.out.printf("Error: %s: %s", response.getStatus(), response.getErrorText());
2346+
}
23332347
```
23342348
### Start PSD2 Verification
23352349

@@ -2341,6 +2355,7 @@ if (response.getStatus() == VerifyStatus.OK) {
23412355
}
23422356
else {
23432357
System.out.printf("Error: %s: %s", response.getStatus(), response.getErrorText());
2358+
}
23442359
```
23452360
## Verify v2
23462361
### Send Request WhatsApp
@@ -2436,6 +2451,8 @@ catch (VerifyResponseException ex) {
24362451
case 429: // Rate limit exceeded
24372452
default: // Unknown or internal server error (500)
24382453
ex.printStackTrace();
2454+
}
2455+
}
24392456
```
24402457
### Get Template
24412458

src/main/java/AggregateSnippets.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static boolean isInitialize(File file) {
5353
static String toHeadingTitle(String title) {
5454
var acronyms = new String[]{
5555
"jwt", "id", "uuid", "url", "sim",
56-
"sms", "rcs", "mms", "psd2", "dlr",
56+
"sms", "rcs", "mms", "psd2", "dlr", "cnam",
5757
"dtmf", "asr", "tts", "ncco", "rtc"
5858
};
5959
var result = (title.substring(0, 1).toUpperCase() + title.substring(1))
@@ -69,6 +69,9 @@ static String toHeadingTitle(String title) {
6969
for (var ac : acronyms) {
7070
result = result.replaceAll("\\b(?i:"+ac+")\\b", ac.toUpperCase());
7171
}
72+
if ("Insight".equals(result)) {
73+
result = "Number Insight";
74+
}
7275
return result;
7376
}
7477

@@ -89,15 +92,15 @@ else if (level > 2 && path.getName().endsWith(".java")) {
8992
final var fileContent = Files.readString(path.toPath());
9093
final var clientInitEndStr = ".build();\n\n";
9194
final var clientInitStartStr = "VonageClient client";
92-
final int endIndex = fileContent.lastIndexOf(';') + 1;
95+
final int endIndex = fileContent.lastIndexOf('}', fileContent.lastIndexOf('}') - 1) - 1;
9396
final int startIndex = Math.min(endIndex, fileContent.contains(clientInitStartStr) ?
9497
(isInitialize(path.getParentFile()) ? fileContent.indexOf(clientInitStartStr) - 8 :
9598
fileContent.indexOf(clientInitEndStr) + clientInitEndStr.length()) :
9699
fileContent.indexOf('{', fileContent.indexOf('{') + 1) + 2
97100
);
98101

99102
final var nugget = fileContent.substring(startIndex, endIndex)
100-
.stripIndent().replace("\t", " ");
103+
.stripTrailing().stripIndent().replace("\t", " ");
101104
contentBuilder.append("\n```java\n").append(nugget).append("\n```\n");
102105
}
103106
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ public static void main(String[] args) throws Exception {
4343

4444
AdvancedInsightResponse response = client.getInsightClient().getAdvancedNumberInsight(request);
4545

46-
printResults(response);
47-
}
46+
System.out.println(response);
4847

49-
private static void printResults(AdvancedInsightResponse response) {
5048
System.out.println("BASIC INFO:");
5149
System.out.println("International format: " + response.getInternationalFormatNumber());
5250
System.out.println("National format: " + response.getNationalFormatNumber());
@@ -66,7 +64,8 @@ private static void printResults(AdvancedInsightResponse response) {
6664
RoamingDetails roaming = response.getRoaming();
6765
if (roaming == null) {
6866
System.out.println("- No Roaming Info -");
69-
} else {
67+
}
68+
else {
7069
System.out.println("Roaming status: " + roaming.getStatus());
7170
if (response.getRoaming().getStatus() == RoamingDetails.RoamingStatus.ROAMING) {
7271
System.out.print(" Currently roaming in: " + roaming.getRoamingCountryCode());

0 commit comments

Comments
 (0)