Skip to content

Commit f7b9733

Browse files
authored
feat: Add MMS text/file/content messages (#117)
* feat: Add MMS text/file/content messages * ci: Bump versions * docs: vCard casing * chore: Run AggregateSnippets
1 parent 63580a5 commit f7b9733

File tree

9 files changed

+179
-10
lines changed

9 files changed

+179
-10
lines changed

.env-example

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ MESSAGES_GEOSPECIFIC_API_URL="https://api-eu.nexmo.com/v1/messages"
2626
MESSAGES_GEOSPECIFIC_API_HOST="api-eu"
2727
MESSAGES_SANDBOX_URL="https://messages-sandbox.nexmo.com/v1/messages"
2828
MESSAGES_MESSAGE_ID="00000000-0000-4000-8000-000000000000"
29-
MESSAGES_IMAGE_URL="https://example.org/image.jpg"
30-
MESSAGES_AUDIO_URL="https://example.org/audio.mp3"
31-
MESSAGES_VIDEO_URL="https://example.org/video.mp4"
32-
MESSAGES_FILE_URL="https://example.org/file.pdf"
33-
MESSAGES_VCARD_URL="https://example.org/vcard.vcf"
29+
MESSAGES_IMAGE_URL="https://file-examples.com/storage/fe435d6a5467c753ca23df4/2017/10/file_example_JPG_100kB.jpg"
30+
MESSAGES_AUDIO_URL="https://file-examples.com/wp-content/storage/2017/11/file_example_MP3_700KB.mp3"
31+
MESSAGES_VIDEO_URL="https://file-examples.com/wp-content/storage/2017/04/file_example_MP4_480_1_5MG.mp4"
32+
MESSAGES_FILE_URL="https://file-examples.com/wp-content/storage/2017/02/file-sample_100kB.doc"
33+
MESSAGES_VCARD_URL="https://raw.githubusercontent.com/nuovo/vCard-parser/refs/heads/master/Example.vcf"
3434
MESSAGES_EMOJI="🐱"
3535
MESSAGES_CAPTION="Additional text to accompany the message"
3636

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ jobs:
2828
distribution: 'temurin'
2929
java-version: ${{ matrix.java }}
3030
- name: Setup Gradle
31-
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b
31+
uses: gradle/actions/setup-gradle@245c8a24de79c0dbeabaf19ebcbbd3b2c36f278d
3232
- name: Build with Gradle
3333
run: ./gradlew build

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ jobs:
2929
- name: Checkout repository
3030
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
3131
- name: Initialize CodeQL
32-
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a
32+
uses: github/codeql-action/init@1bb15d06a6fbb5d9d9ffd228746bf8ee208caec8
3333
with:
3434
languages: ${{ matrix.language }}
3535
build-mode: ${{ matrix.build-mode }}
3636
- name: Perform CodeQL Analysis
37-
uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a
37+
uses: github/codeql-action/analyze@1bb15d06a6fbb5d9d9ffd228746bf8ee208caec8
3838
with:
3939
category: "/language:${{matrix.language}}"

SNIPPETS.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,17 @@ var response = client.getMessagesClient().sendMessage(
806806
System.out.println("Message sent successfully. ID: " + response.getMessageUuid());
807807
```
808808
### MMS
809+
#### Send MMS Text
810+
811+
```java
812+
var response = client.getMessagesClient().sendMessage(
813+
MmsTextRequest.builder()
814+
.from(MMS_SENDER_ID).to(MESSAGES_TO_NUMBER)
815+
.text("This is an MMS message with text")
816+
.build()
817+
);
818+
System.out.println("Message sent successfully. ID: "+response.getMessageUuid());
819+
```
809820
#### Send MMS Video
810821

811822
```java
@@ -817,7 +828,7 @@ var response = client.getMessagesClient().sendMessage(
817828
);
818829
System.out.println("Message sent successfully. ID: "+response.getMessageUuid());
819830
```
820-
#### Send MMS Vcard
831+
#### Send MMS vCard
821832

822833
```java
823834
var response = client.getMessagesClient().sendMessage(
@@ -828,6 +839,29 @@ var response = client.getMessagesClient().sendMessage(
828839
);
829840
System.out.println("Message sent successfully. ID: "+response.getMessageUuid());
830841
```
842+
#### Send MMS Content
843+
844+
```java
845+
var response = client.getMessagesClient().sendMessage(
846+
MmsContentRequest.builder()
847+
.from(MMS_SENDER_ID).to(MESSAGES_TO_NUMBER)
848+
.addImage(MESSAGES_IMAGE_URL)
849+
.addFile(MESSAGES_FILE_URL)
850+
.build()
851+
);
852+
System.out.println("Message sent successfully. ID: "+response.getMessageUuid());
853+
```
854+
#### Send MMS File
855+
856+
```java
857+
var response = client.getMessagesClient().sendMessage(
858+
MmsFileRequest.builder()
859+
.from(MMS_SENDER_ID).to(MESSAGES_TO_NUMBER)
860+
.url(MESSAGES_FILE_URL)
861+
.build()
862+
);
863+
System.out.println("Message sent successfully. ID: "+response.getMessageUuid());
864+
```
831865
#### Send MMS Image
832866

833867
```java
@@ -2977,3 +3011,7 @@ Ncco ncco = new Ncco(TalkAction.builder("This is a text to speech call from Vona
29773011

29783012
client.getVoiceClient().createCall(new Call(VOICE_TO_NUMBER, VONAGE_VIRTUAL_NUMBER, ncco.getActions()));
29793013
```
3014+
age").build());
3015+
3016+
client.getVoiceClient().createCall(new Call(VOICE_TO_NUMBER, VONAGE_VIRTUAL_NUMBER, ncco.getActions()));
3017+
```

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
1+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStorePath=wrapper/dists

src/main/java/AggregateSnippets.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ private static String toHeadingTitle(String title) {
147147
var result = (title.substring(0, 1).toUpperCase() + title.substring(1))
148148
.replace("NCCO", "ncco") // To avoid adding spaces in the next regex
149149
.replaceAll("(?<!^)([A-Z])(?![A-Z])", " $1")
150+
.replace("Vcard", "vCard")
150151
.replace("Numberinsight2", "Fraud Detection")
151152
.replace("Numberinsight", "Number Insight")
152153
.replace("Verify\n", "Verify (Legacy)\n")
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2025 Vonage
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
package com.vonage.quickstart.messages.mms;
23+
24+
import com.vonage.client.VonageClient;
25+
import com.vonage.client.messages.mms.MmsContentRequest;
26+
import static com.vonage.quickstart.EnvironmentVariables.*;
27+
28+
public class SendMmsContent {
29+
public static void main(String[] args) throws Exception {
30+
VonageClient client = VonageClient.builder()
31+
.applicationId(VONAGE_APPLICATION_ID)
32+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
33+
.build();
34+
35+
var response = client.getMessagesClient().sendMessage(
36+
MmsContentRequest.builder()
37+
.from(MMS_SENDER_ID).to(MESSAGES_TO_NUMBER)
38+
.addImage(MESSAGES_IMAGE_URL)
39+
.addFile(MESSAGES_FILE_URL)
40+
.build()
41+
);
42+
System.out.println("Message sent successfully. ID: "+response.getMessageUuid());
43+
}
44+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2025 Vonage
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
package com.vonage.quickstart.messages.mms;
23+
24+
import com.vonage.client.VonageClient;
25+
import com.vonage.client.messages.mms.MmsFileRequest;
26+
import static com.vonage.quickstart.EnvironmentVariables.*;
27+
28+
public class SendMmsFile {
29+
public static void main(String[] args) throws Exception {
30+
VonageClient client = VonageClient.builder()
31+
.applicationId(VONAGE_APPLICATION_ID)
32+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
33+
.build();
34+
35+
var response = client.getMessagesClient().sendMessage(
36+
MmsFileRequest.builder()
37+
.from(MMS_SENDER_ID).to(MESSAGES_TO_NUMBER)
38+
.url(MESSAGES_FILE_URL)
39+
.build()
40+
);
41+
System.out.println("Message sent successfully. ID: "+response.getMessageUuid());
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2025 Vonage
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
package com.vonage.quickstart.messages.mms;
23+
24+
import com.vonage.client.VonageClient;
25+
import com.vonage.client.messages.mms.MmsTextRequest;
26+
import static com.vonage.quickstart.EnvironmentVariables.*;
27+
28+
public class SendMmsText {
29+
public static void main(String[] args) throws Exception {
30+
VonageClient client = VonageClient.builder()
31+
.applicationId(VONAGE_APPLICATION_ID)
32+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
33+
.build();
34+
35+
var response = client.getMessagesClient().sendMessage(
36+
MmsTextRequest.builder()
37+
.from(MMS_SENDER_ID).to(MESSAGES_TO_NUMBER)
38+
.text("This is an MMS message with text")
39+
.build()
40+
);
41+
System.out.println("Message sent successfully. ID: "+response.getMessageUuid());
42+
}
43+
}

0 commit comments

Comments
 (0)