Skip to content

Commit

Permalink
feat: Messages sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jun 26, 2024
1 parent a56fb6f commit b5f2800
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.0] - 2024-07-??

### Added
- Sandbox support in Messages


## [0.1.0] - 2024-06-25

Initial version.
Expand Down
8 changes: 5 additions & 3 deletions src/main/kotlin/com/vonage/client/kt/Messages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import com.vonage.client.messages.viber.*
import java.util.UUID

class Messages(private val client: MessagesClient) {
fun send(message: MessageRequest): UUID {
return client.sendMessage(message).messageUuid
}
fun send(message: MessageRequest): UUID =
client.useRegularEndpoint().sendMessage(message).messageUuid

fun sendSandbox(message: MessageRequest): UUID =
client.useSandboxEndpoint().sendMessage(message).messageUuid
}

fun parseInboundMessage(json: String) : InboundMessage {
Expand Down
9 changes: 8 additions & 1 deletion src/test/kotlin/com/vonage/client/kt/MessagesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import kotlin.test.assertNotNull
class MessagesTest : AbstractTest() {
private val messagesClient = vonageClient.messages
private val sendUrl = "/v1/messages"
private val sandboxUrl = "https://messages-sandbox.nexmo.com$sendUrl"
private val messageUuid = testUuid
private val mmsChannel = "mms"
private val whatsappChannel = "whatsapp"
Expand All @@ -31,7 +32,13 @@ class MessagesTest : AbstractTest() {


private fun testSend(expectedBodyParams: Map<String, Any>, req: MessageRequest) {
mockJsonJwtPost(sendUrl, expectedBodyParams, 202, mapOf("message_uuid" to messageUuid))
val status = 202
val expectedResponseParams = mapOf("message_uuid" to messageUuid)

mockJsonJwtPost(sendUrl, expectedBodyParams, status, expectedResponseParams)
assertEquals(messageUuid, messagesClient.send(req))

mockJsonJwtPost(sandboxUrl, expectedBodyParams, status, expectedResponseParams)
assertEquals(messageUuid, messagesClient.send(req))
}

Expand Down

0 comments on commit b5f2800

Please sign in to comment.