From 8901314b26b826ec3c251b5e4ddb209abad791cc Mon Sep 17 00:00:00 2001 From: Sina Madani Date: Tue, 4 Mar 2025 17:58:49 +0000 Subject: [PATCH] feat: Add MMS text / file / content types --- .env-example | 10 ++--- .github/workflows/build.yml | 2 +- .github/workflows/codeql.yml | 4 +- SNIPPETS.md | 39 ++++++++++++++++-- gradle/wrapper/gradle-wrapper.properties | 2 +- src/main/kotlin/AggregateSnippets.kt | 2 + .../kt/messages/mms/SendMmsContent.kt | 41 +++++++++++++++++++ .../quickstart/kt/messages/mms/SendMmsFile.kt | 41 +++++++++++++++++++ .../quickstart/kt/messages/mms/SendMmsText.kt | 40 ++++++++++++++++++ 9 files changed, 169 insertions(+), 12 deletions(-) create mode 100644 src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsContent.kt create mode 100644 src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsFile.kt create mode 100644 src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsText.kt diff --git a/.env-example b/.env-example index e89e99c..b6c6197 100644 --- a/.env-example +++ b/.env-example @@ -23,11 +23,11 @@ MESSAGES_GEOSPECIFIC_API_URL="https://api-eu.nexmo.com/v1/messages" MESSAGES_GEOSPECIFIC_API_HOST="api-eu" MESSAGES_SANDBOX_URL="https://messages-sandbox.nexmo.com/v1/messages" MESSAGES_MESSAGE_ID="00000000-0000-4000-8000-000000000000" -MESSAGES_IMAGE_URL="https://example.org/image.jpg" -MESSAGES_AUDIO_URL="https://example.org/audio.mp3" -MESSAGES_VIDEO_URL="https://example.org/video.mp4" -MESSAGES_FILE_URL="https://example.org/file.pdf" -MESSAGES_VCARD_URL="https://example.org/vcard.vcf" +MESSAGES_IMAGE_URL="https://file-examples.com/storage/fe435d6a5467c753ca23df4/2017/10/file_example_JPG_100kB.jpg" +MESSAGES_AUDIO_URL="https://file-examples.com/wp-content/storage/2017/11/file_example_MP3_700KB.mp3" +MESSAGES_VIDEO_URL="https://file-examples.com/wp-content/storage/2017/04/file_example_MP4_480_1_5MG.mp4" +MESSAGES_FILE_URL="https://file-examples.com/wp-content/storage/2017/02/file-sample_100kB.doc" +MESSAGES_VCARD_URL="https://raw.githubusercontent.com/nuovo/vCard-parser/refs/heads/master/Example.vcf" MESSAGES_EMOJI="🐱" MESSAGES_CAPTION="Additional text to accompany the message" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c8e4bb..7fbdebd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,6 @@ jobs: distribution: 'temurin' java-version: ${{ matrix.java }} - name: Setup Gradle - uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b + uses: gradle/actions/setup-gradle@245c8a24de79c0dbeabaf19ebcbbd3b2c36f278d - name: Build with Gradle run: ./gradlew build diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ff1fbba..4302acb 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,11 +29,11 @@ jobs: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - name: Initialize CodeQL - uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a + uses: github/codeql-action/init@1bb15d06a6fbb5d9d9ffd228746bf8ee208caec8 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a + uses: github/codeql-action/analyze@1bb15d06a6fbb5d9d9ffd228746bf8ee208caec8 with: category: "/language:${{matrix.language}}" diff --git a/SNIPPETS.md b/SNIPPETS.md index be150e6..b89dffe 100644 --- a/SNIPPETS.md +++ b/SNIPPETS.md @@ -11,7 +11,6 @@ This file was generated by running [AggregateSnippets.kt](src/main/kotlin/Aggreg - [**Numbers**](#numbers) - [**SMS**](#sms) - [**Verify**](#verify) -- [**Number Verification**](#number-verification) - [**Redact**](#redact) - [**SIM Swap**](#sim-swap) - [**Voice**](#voice) @@ -560,6 +559,29 @@ val messageId = client.messages.send( ``` ### MMS +#### Send MMS Text +```kotlin +val messageId = client.messages.send( + mmsText { + to(MESSAGES_TO_NUMBER) + from(MMS_SENDER_ID) + text("This is an MMS text message sent using the Messages API") + } +) +``` + +#### Send MMS File +```kotlin +val messageId = client.messages.send( + mmsFile { + to(MESSAGES_TO_NUMBER) + from(MMS_SENDER_ID) + url(MESSAGES_FILE_URL) + caption(MESSAGES_CAPTION) + } +) +``` + #### Send MMS Video ```kotlin val messageId = client.messages.send( @@ -572,7 +594,7 @@ val messageId = client.messages.send( ) ``` -#### Send MMS Vcard +#### Send MMS vCard ```kotlin val messageId = client.messages.send( mmsVcard { @@ -608,6 +630,18 @@ val messageId = client.messages.send( ) ``` +#### Send MMS Content +```kotlin +val messageId = client.messages.send( + mmsContent { + to(MESSAGES_TO_NUMBER) + from(MMS_SENDER_ID) + addImage(MESSAGES_IMAGE_URL) + addFile(MESSAGES_FILE_URL) + } +) +``` + ### Messenger #### Send Messenger Audio ```kotlin @@ -1701,7 +1735,6 @@ val response = client.verify.sendVerification(VERIFY_BRAND_NAME) { println("Verification sent: ${response.requestId}") ``` -## Number Verification ## Redact ### Redact Insight ```kotlin diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e18bc25..37f853b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/kotlin/AggregateSnippets.kt b/src/main/kotlin/AggregateSnippets.kt index 4ddc13e..5c9fd7d 100644 --- a/src/main/kotlin/AggregateSnippets.kt +++ b/src/main/kotlin/AggregateSnippets.kt @@ -62,6 +62,8 @@ fun String.toHeadingTitle(): String { .replace("numberverification", "Number Verification", true) .replace("simswap", "SIM Swap", true) .replace("whatsapp", "WhatsApp", true) + .replace("vcard", "vCard", true) + .replace("callncco", "Call NCCO", true) val acronyms = arrayOf( "jwt", "id", "uuid", "url", "sim", diff --git a/src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsContent.kt b/src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsContent.kt new file mode 100644 index 0000000..3df56b9 --- /dev/null +++ b/src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsContent.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2025 Vonage + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.vonage.quickstart.kt.messages.mms + +import com.vonage.client.kt.* +import com.vonage.quickstart.kt.* + +fun main() { + val client = Vonage { + applicationId(VONAGE_APPLICATION_ID) + privateKeyPath(VONAGE_PRIVATE_KEY_PATH) + } + + val messageId = client.messages.send( + mmsContent { + to(MESSAGES_TO_NUMBER) + from(MMS_SENDER_ID) + addImage(MESSAGES_IMAGE_URL) + addFile(MESSAGES_FILE_URL) + } + ) +} diff --git a/src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsFile.kt b/src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsFile.kt new file mode 100644 index 0000000..635577a --- /dev/null +++ b/src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsFile.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2025 Vonage + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.vonage.quickstart.kt.messages.mms + +import com.vonage.client.kt.* +import com.vonage.quickstart.kt.* + +fun main() { + val client = Vonage { + applicationId(VONAGE_APPLICATION_ID) + privateKeyPath(VONAGE_PRIVATE_KEY_PATH) + } + + val messageId = client.messages.send( + mmsFile { + to(MESSAGES_TO_NUMBER) + from(MMS_SENDER_ID) + url(MESSAGES_FILE_URL) + caption(MESSAGES_CAPTION) + } + ) +} diff --git a/src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsText.kt b/src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsText.kt new file mode 100644 index 0000000..854a83d --- /dev/null +++ b/src/main/kotlin/com/vonage/quickstart/kt/messages/mms/SendMmsText.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2025 Vonage + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.vonage.quickstart.kt.messages.mms + +import com.vonage.client.kt.* +import com.vonage.quickstart.kt.* + +fun main() { + val client = Vonage { + applicationId(VONAGE_APPLICATION_ID) + privateKeyPath(VONAGE_PRIVATE_KEY_PATH) + } + + val messageId = client.messages.send( + mmsText { + to(MESSAGES_TO_NUMBER) + from(MMS_SENDER_ID) + text("This is an MMS text message sent using the Messages API") + } + ) +}