Skip to content

Commit

Permalink
refactor!: Use boolean param for Messages sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jul 30, 2024
1 parent da8f54e commit f4f1dfe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Number Verification API

### Changed
- `InputAction.Builder.dtmf` extension method uses `DtmfSettings` builder instead of setters
- `InputAction.Builder#dtmf` extension method uses `DtmfSettings` builder instead of setters
- `Messages#send` now uses optional Boolean parameter for sandbox instead of separate method

## [0.5.0] - 2024-07-25

Expand Down
10 changes: 4 additions & 6 deletions src/main/kotlin/com/vonage/client/kt/Messages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ import com.vonage.client.messages.messenger.*
import com.vonage.client.messages.viber.*
import java.util.UUID

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

fun sendSandbox(message: MessageRequest): UUID =
client.useSandboxEndpoint().sendMessage(message).messageUuid
class Messages(private val messagesClient: MessagesClient) {
fun send(message: MessageRequest, sandbox: Boolean = false): UUID =
(if (sandbox) messagesClient.useSandboxEndpoint()
else messagesClient.useRegularEndpoint()).sendMessage(message).messageUuid
}

fun smsText(init: SmsTextRequest.Builder.() -> Unit): SmsTextRequest =
Expand Down
5 changes: 0 additions & 5 deletions src/test/kotlin/com/vonage/client/kt/MessagesTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ class MessagesTest : AbstractTest() {
status = status, expectedResponseParams = expectedResponseParams
)
assertEquals(messageUuid, messagesClient.send(req))

// TODO fix mocking full url
//val sandboxUrl = "https://messages-sandbox.nexmo.com$sendUrl"
//mockJsonJwtPost(sandboxUrl, expectedBodyParams, status, expectedResponseParams)
//assertEquals(messageUuid, messagesClient.sendSandbox(req))
}

private fun baseBody(messageType: String, channel: String): Map<String, Any> =
Expand Down

0 comments on commit f4f1dfe

Please sign in to comment.