Skip to content

Commit eafd04e

Browse files
feat: Relaxed MMS caption length to 3000, can set RCS category, and new WhatsApp pricing info can be deserialized (#605)
1 parent 74690ca commit eafd04e

File tree

15 files changed

+174
-27
lines changed

15 files changed

+174
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
# [9.6.0] - 2025-12-04
6+
- MMS caption length increased on 3000
7+
- Added new RCS param for messages to set the category
8+
- Added additional whatsapp information for deserializing incoming messages that contain pricing.
9+
510
# [9.5.0] - 2025-12-04
611
- Added `trusted-number` to SMS
712

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Add the following to your `build.gradle` or `build.gradle.kts` file:
7474

7575
```groovy
7676
dependencies {
77-
implementation("com.vonage:server-sdk:9.5.0")
77+
implementation("com.vonage:server-sdk:9.6.0")
7878
}
7979
```
8080

@@ -85,7 +85,7 @@ Add the following to the `<dependencies>` section of your `pom.xml` file:
8585
<dependency>
8686
<groupId>com.vonage</groupId>
8787
<artifactId>server-sdk</artifactId>
88-
<version>9.5.0</version>
88+
<version>9.6.0</version>
8989
</dependency>
9090
```
9191

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.vonage</groupId>
77
<artifactId>server-sdk</artifactId>
8-
<version>9.5.0</version>
8+
<version>9.6.0</version>
99

1010
<name>Vonage Java Server SDK</name>
1111
<description>Java client for Vonage APIs</description>

src/main/java/com/vonage/client/HttpWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
public class HttpWrapper {
3838
private static final String
3939
CLIENT_NAME = "vonage-java-sdk",
40-
CLIENT_VERSION = "9.5.0",
40+
CLIENT_VERSION = "9.6.0",
4141
JAVA_VERSION = System.getProperty("java.version"),
4242
USER_AGENT = String.format("%s/%s java/%s", CLIENT_NAME, CLIENT_VERSION, JAVA_VERSION);
4343

src/main/java/com/vonage/client/messages/MessageStatus.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,47 @@ static class Origin extends JsonableBaseObject {
196196
@JsonProperty("id") String id;
197197
@JsonProperty("origin") Origin origin;
198198
}
199+
200+
/**
201+
* Represents WhatsApp pricing information in the status webhook.
202+
*
203+
* @since 9.5.0
204+
*/
205+
public static class Pricing extends JsonableBaseObject {
206+
@JsonProperty("type") String type;
207+
@JsonProperty("pricing_model") String pricingModel;
208+
@JsonProperty("category") String category;
209+
210+
/**
211+
* The pricing type.
212+
*
213+
* @return The pricing type as a string. Possible values: {@code regular}, {@code free_customer_service}, {@code free_entry_point}.
214+
*/
215+
public String getType() {
216+
return type;
217+
}
218+
219+
/**
220+
* The pricing model.
221+
*
222+
* @return The pricing model as a string. Possible values: {@code PMP}, {@code CBP}.
223+
*/
224+
public String getPricingModel() {
225+
return pricingModel;
226+
}
227+
228+
/**
229+
* The message category.
230+
*
231+
* @return The category as a string. Possible values: {@code authentication}, {@code authentication_international}, {@code marketing}, {@code utility}, {@code service}, {@code referral_conversion}, {@code marketing_lite}.
232+
*/
233+
public String getCategory() {
234+
return category;
235+
}
236+
}
237+
199238
@JsonProperty("conversation") Conversation conversation;
239+
@JsonProperty("pricing") Pricing pricing;
200240
}
201241

202242
protected MessageStatus() {
@@ -369,6 +409,19 @@ public String getWhatsappConversationId() {
369409
return whatsapp != null && whatsapp.conversation != null ? whatsapp.conversation.id : null;
370410
}
371411

412+
/**
413+
* If the {@linkplain #getChannel()} is {@linkplain Channel#WHATSAPP}, returns the pricing information
414+
* for the message.
415+
*
416+
* @return The WhatsApp pricing information, {@code null} if absent or not applicable.
417+
*
418+
* @since 9.5.0
419+
*/
420+
@JsonIgnore
421+
public Whatsapp.Pricing getWhatsappPricing() {
422+
return whatsapp != null ? whatsapp.pricing : null;
423+
}
424+
372425
/**
373426
* Catch-all for properties which are not mapped by this class during deserialization.
374427
*

src/main/java/com/vonage/client/messages/mms/Content.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Content(MessageType type, String url, String caption) {
5050
default: throw new IllegalArgumentException("Unsupported media type: " + type);
5151
}
5252
MessagePayload payload = new MessagePayload(url, caption);
53-
payload.validateCaptionLength(2000);
53+
payload.validateCaptionLength(3000);
5454
this.url = payload.getUrl();
5555
this.caption = payload.getCaption();
5656
}

src/main/java/com/vonage/client/messages/mms/MmsImageRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Builder url(String url) {
5454

5555
/**
5656
* (OPTIONAL)
57-
* Additional text to accompany the image. Must be between 1 and 2000 characters.
57+
* Additional text to accompany the image. Must be between 1 and 3000 characters.
5858
*
5959
* @param caption The caption string.
6060
* @return This builder.

src/main/java/com/vonage/client/messages/mms/MmsRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public abstract class MmsRequest extends MessageRequest {
2525
protected MmsRequest(Builder<?, ?> builder, MessageType messageType) {
2626
super(builder, Channel.MMS, messageType);
2727
if (media != null) {
28-
media.validateCaptionLength(2000);
28+
media.validateCaptionLength(3000);
2929
}
3030
int min = 300, max = 259200;
3131
if (ttl != null && (ttl < min || ttl > max)) {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2025 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.messages.rcs;
17+
18+
import com.fasterxml.jackson.annotation.JsonProperty;
19+
import com.vonage.client.JsonableBaseObject;
20+
21+
/**
22+
* RCS-specific parameters.
23+
*
24+
* @since 9.6.0
25+
*/
26+
public final class Rcs extends JsonableBaseObject {
27+
private String category;
28+
29+
Rcs() {}
30+
31+
/**
32+
* Creates an RCS options object with the specified category.
33+
*
34+
* @param category The RCS message category.
35+
*/
36+
public Rcs(String category) {
37+
this.category = category;
38+
}
39+
40+
/**
41+
* The RCS message category.
42+
*
43+
* @return The category as a string, or {@code null} if not set.
44+
*/
45+
@JsonProperty("category")
46+
public String getCategory() {
47+
return category;
48+
}
49+
}

src/main/java/com/vonage/client/messages/rcs/RcsRequest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,53 @@
2626
* @since 8.11.0
2727
*/
2828
public abstract class RcsRequest extends MessageRequest {
29+
protected Rcs rcs;
2930

3031
protected RcsRequest(Builder<?, ?> builder, MessageType messageType) {
3132
super(builder, Channel.RCS, messageType);
33+
this.rcs = builder.rcs;
3234
}
3335

3436
@JsonProperty("ttl")
3537
public Integer getTtl() {
3638
return ttl;
3739
}
3840

41+
@JsonProperty("rcs")
42+
public Rcs getRcs() {
43+
return rcs;
44+
}
45+
46+
@SuppressWarnings("unchecked")
3947
protected abstract static class Builder<M extends RcsRequest, B extends Builder<? extends M, ? extends B>> extends MessageRequest.Builder<M, B> {
48+
protected Rcs rcs;
49+
50+
/**
51+
* (OPTIONAL)
52+
* Sets RCS-specific parameters.
53+
*
54+
* @param rcs The RCS options object.
55+
* @return This builder.
56+
*
57+
* @since 9.5.0
58+
*/
59+
public B rcs(Rcs rcs) {
60+
this.rcs = rcs;
61+
return (B) this;
62+
}
63+
64+
/**
65+
* (OPTIONAL)
66+
* Sets the RCS message category.
67+
*
68+
* @param category The RCS category.
69+
* @return This builder.
70+
*
71+
* @since 9.5.0
72+
*/
73+
public B rcsCategory(String category) {
74+
return rcs(new Rcs(category));
75+
}
4076

4177
@Override
4278
protected B ttl(int ttl) {

0 commit comments

Comments
 (0)