Skip to content

Commit 14e3d7b

Browse files
authored
Merge pull request #527 from Vonage/verify-cap
feat: Add Verify capability to Application API
2 parents 0e0952d + 3efc4e8 commit 14e3d7b

File tree

14 files changed

+202
-133
lines changed

14 files changed

+202
-133
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7-
# [8.6.0] - 2024-04-19
7+
# [8.6.0] - 2024-04-18
88
- Added Experience Composer to Video API
9-
- Fixed regression in `createSession` endpoint which caused the API to return XML instead of JSON.
9+
- Fixed regression in `createSession` Video endpoint
10+
- `muteSession` Video endpoint now returns `ProjectDetails`
11+
- Added Verify capability to Application API
1012

1113
# [8.5.0] - 2024-04-12
1214
- Added Live Captions and Audio Connector endpoints to Video API

src/main/java/com/vonage/client/application/Application.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public Application build() {
225225
*
226226
* @since 7.7.0
227227
*/
228-
public static class Privacy extends JsonableBaseObject {
228+
public static class Privacy extends JsonableBaseObject {
229229
private Boolean improveAi;
230230

231231
/**
@@ -244,7 +244,7 @@ public Boolean getImproveAi() {
244244
/**
245245
* Represents the cryptographic keys of an Application.
246246
*/
247-
public static class Keys extends JsonableBaseObject {
247+
public static class Keys extends JsonableBaseObject {
248248
private String publicKey, privateKey;
249249

250250
/**
@@ -273,6 +273,7 @@ public static class Capabilities extends JsonableBaseObject {
273273
private Messages messages;
274274
private Rtc rtc;
275275
private Vbc vbc;
276+
private Verify verify;
276277

277278
/**
278279
* Voice capability.
@@ -314,6 +315,18 @@ public Vbc getVbc() {
314315
return vbc;
315316
}
316317

318+
/**
319+
* Verify capability.
320+
*
321+
* @return The Verify capability, or {@code null} if absent.
322+
*
323+
* @since 8.6.0
324+
*/
325+
@JsonProperty("verify")
326+
public Verify getVerify() {
327+
return verify;
328+
}
329+
317330
private void setCapability(Capability.Type type, Capability capability) {
318331
switch (type) {
319332
case VOICE:
@@ -328,6 +341,9 @@ private void setCapability(Capability.Type type, Capability capability) {
328341
case VBC:
329342
vbc = (Vbc) capability;
330343
break;
344+
case VERIFY:
345+
verify = (Verify) capability;
346+
break;
331347
}
332348
}
333349

src/main/java/com/vonage/client/application/capabilities/Capability.java

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import com.fasterxml.jackson.annotation.JsonIgnore;
1919
import com.fasterxml.jackson.annotation.JsonInclude;
2020
import com.fasterxml.jackson.annotation.JsonProperty;
21-
import com.fasterxml.jackson.databind.ObjectMapper;
2221
import com.vonage.client.JsonableBaseObject;
2322
import com.vonage.client.common.HttpMethod;
2423
import com.vonage.client.common.Webhook;
@@ -28,15 +27,15 @@
2827
/**
2928
* Represents a capability of a Vonage Application
3029
*/
30+
@JsonInclude(JsonInclude.Include.NON_ABSENT)
3131
public abstract class Capability extends JsonableBaseObject {
3232
protected Map<Webhook.Type, Webhook> webhooks;
3333

3434
protected Capability() {
3535
}
3636

37-
@Override
38-
protected ObjectMapper createJsonObjectMapper() {
39-
return super.createJsonObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
37+
protected Capability(Builder<?, ?> builder) {
38+
webhooks = builder.webhooks;
4039
}
4140

4241
/**
@@ -57,20 +56,46 @@ public Map<Webhook.Type, Webhook> getWebhooks() {
5756
return webhooks;
5857
}
5958

59+
/**
60+
* Represents the API this capability relates to.
61+
*/
6062
public enum Type {
63+
64+
/**
65+
* Voice API
66+
*/
6167
VOICE,
68+
69+
/**
70+
* RTC
71+
*/
6272
RTC,
73+
74+
/**
75+
* Messages API
76+
*/
6377
MESSAGES,
64-
VBC
78+
79+
/**
80+
* VBC
81+
*/
82+
VBC,
83+
84+
/**
85+
* Verify API
86+
*
87+
* @since 8.6.0
88+
*/
89+
VERIFY
6590
}
6691

6792
@SuppressWarnings("unchecked")
68-
static abstract class Builder<C extends Capability, B extends Builder<C, B>> {
93+
protected static abstract class Builder<C extends Capability, B extends Builder<C, B>> {
6994
Map<Webhook.Type, Webhook> webhooks;
7095

7196
/**
7297
* Add a webhook for the Vonage API to use. Each Capability can only have a single webhook of each type.
73-
* See <a href="https://developer.nexmo.com/concepts/guides/webhooks"> the webhooks guide</a> for details.
98+
* See <a href="https://developer.vonage.com/concepts/guides/webhooks"> the webhooks guide</a> for details.
7499
*
75100
* @param type The {@link Webhook.Type} of webhook to add.
76101
* @param webhook The webhook containing the URL and {@link HttpMethod}.

src/main/java/com/vonage/client/application/capabilities/Messages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
/**
2121
* Messages capability configuration settings.
2222
*/
23-
public class Messages extends Capability {
23+
public final class Messages extends Capability {
2424

2525
private Messages() {
2626
}
2727

2828
private Messages(Builder builder) {
29-
webhooks = builder.webhooks;
29+
super(builder);
3030
}
3131

3232
@Override

src/main/java/com/vonage/client/application/capabilities/Rtc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
/**
2121
* Rtc capability configuration settings.
2222
*/
23-
public class Rtc extends Capability {
23+
public final class Rtc extends Capability {
2424

2525
private Rtc() {
2626
}
2727

2828
private Rtc(Builder builder) {
29-
webhooks = builder.webhooks;
29+
super(builder);
3030
}
3131

3232
@Override

src/main/java/com/vonage/client/application/capabilities/Vbc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
/**
2020
* VBC capability configuration settings.
2121
*/
22-
public class Vbc extends Capability {
22+
public final class Vbc extends Capability {
2323

2424
private Vbc() {
2525
}
2626

2727
private Vbc(Builder builder) {
28-
28+
super(builder);
2929
}
3030

3131
@Override
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright 2024 Vonage
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.vonage.client.application.capabilities;
17+
18+
import com.vonage.client.common.Webhook;
19+
20+
/**
21+
* Verify capability configuration settings.
22+
*
23+
* @since 8.6.0
24+
*/
25+
public final class Verify extends Capability {
26+
27+
private Verify() {
28+
}
29+
30+
private Verify(Builder builder) {
31+
super(builder);
32+
}
33+
34+
@Override
35+
public Type getType() {
36+
return Type.VERIFY;
37+
}
38+
39+
/**
40+
* Entry point for constructing an instance of this class.
41+
*
42+
* @return A new Builder.
43+
*/
44+
public static Builder builder() {
45+
return new Builder();
46+
}
47+
48+
public static final class Builder extends Capability.Builder<Verify, Builder> {
49+
50+
private Builder() {}
51+
52+
@Override
53+
public Builder addWebhook(Webhook.Type type, Webhook webhook) {
54+
return super.addWebhook(type, webhook);
55+
}
56+
57+
/**
58+
* Builds the Verify object with this builder's properties.
59+
*
60+
* @return A new Verify capability.
61+
*/
62+
@Override
63+
public Verify build() {
64+
return new Verify(this);
65+
}
66+
}
67+
}

src/main/java/com/vonage/client/application/capabilities/Voice.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* Voice capability configuration settings.
2323
*/
24-
public class Voice extends Capability {
24+
public final class Voice extends Capability {
2525
private Region region;
2626
private Boolean signedCallbacks;
2727
private Integer conversationsTtl;
@@ -30,7 +30,7 @@ private Voice() {
3030
}
3131

3232
private Voice(Builder builder) {
33-
webhooks = builder.webhooks;
33+
super(builder);
3434
region = builder.region;
3535
signedCallbacks = builder.signedCallbacks;
3636
if ((conversationsTtl = builder.conversationsTtl) != null && (conversationsTtl < 0 || conversationsTtl > 744)) {

src/main/java/com/vonage/client/video/MuteSessionResponse.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/main/java/com/vonage/client/video/ProjectDetails.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
package com.vonage.client.video;
1717

1818
import com.fasterxml.jackson.annotation.JsonProperty;
19-
import com.fasterxml.jackson.databind.ObjectMapper;
19+
import com.vonage.client.Jsonable;
2020
import com.vonage.client.JsonableBaseObject;
21-
import com.vonage.client.VonageUnexpectedException;
22-
import java.io.IOException;
2321

2422
/**
2523
* Represents properties of a video project.
@@ -72,7 +70,7 @@ public ProjectEnvironment getEnvironment() {
7270
public Long getCreatedAt() {
7371
return createdAt;
7472
}
75-
73+
7674
/**
7775
* Creates an instance of this class from a JSON payload.
7876
*
@@ -83,12 +81,6 @@ public static ProjectDetails fromJson(String json) {
8381
if (json == null || json.trim().isEmpty()) {
8482
return new ProjectDetails();
8583
}
86-
try {
87-
ObjectMapper mapper = new ObjectMapper();
88-
return mapper.readValue(json, ProjectDetails.class);
89-
}
90-
catch (IOException ex) {
91-
throw new VonageUnexpectedException("Failed to produce MuteResponse from json.", ex);
92-
}
84+
return Jsonable.fromJson(json);
9385
}
9486
}

0 commit comments

Comments
 (0)