diff --git a/CHANGELOG.md b/CHANGELOG.md index f862754..a088761 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ 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.7.0] - 2024-08-?? + +### Added +- Numbers API + ## [0.6.0] - 2024-07-30 ### Added diff --git a/README.md b/README.md index a3f884e..088b948 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ You'll need to have [created a Vonage account](https://dashboard.nexmo.com/sign- - [Voice](https://developer.vonage.com/en/voice/voice-api/overview) - [SIM Swap](https://developer.vonage.com/en/sim-swap/overview) - [Number Verification](https://developer.vonage.com/en/number-verification/overview) +- [Number Management](https://developer.vonage.com/en/numbers/overview) - [Number Insight](https://developer.vonage.com/en/number-insight/overview) - [SMS](https://developer.vonage.com/en/messaging/sms/overview) - [Conversion](https://developer.vonage.com/en/messaging/conversion-api/overview) diff --git a/pom.xml b/pom.xml index 14ebdf1..859036c 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.vonage server-sdk-kotlin - 0.6.0 + 0.7.0 Vonage Kotlin Server SDK Kotlin client for Vonage APIs @@ -59,7 +59,7 @@ com.vonage server-sdk - 8.9.4 + 8.10.0 org.jetbrains.kotlin diff --git a/src/main/kotlin/com/vonage/client/kt/Numbers.kt b/src/main/kotlin/com/vonage/client/kt/Numbers.kt new file mode 100644 index 0000000..4f8f269 --- /dev/null +++ b/src/main/kotlin/com/vonage/client/kt/Numbers.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2024 Vonage + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.vonage.client.kt + +import com.vonage.client.numbers.* + +class Numbers(private val numbersClient: NumbersClient) { + + inner class ExistingNumber(val countryCode: String, val msisdn: String) { + + fun buy(targetApiKey: String? = null) = + numbersClient.buyNumber(countryCode, msisdn, targetApiKey) + + fun cancel(targetApiKey: String? = null) = + numbersClient.cancelNumber(countryCode, msisdn, targetApiKey) + + fun update(properties: UpdateNumberRequest.Builder.() -> Unit) = + numbersClient.updateNumber(UpdateNumberRequest.builder(msisdn, countryCode).apply(properties).build()) + } + + fun listOwned(filter: ListNumbersFilter.Builder.() -> Unit = {}) = + numbersClient.listNumbers(ListNumbersFilter.builder().apply(filter).build()) + + fun searchAvailable(filter: SearchNumbersFilter.Builder.() -> Unit) = + numbersClient.searchNumbers(SearchNumbersFilter.builder().apply(filter).build()) +} diff --git a/src/main/kotlin/com/vonage/client/kt/Vonage.kt b/src/main/kotlin/com/vonage/client/kt/Vonage.kt index 9688632..5fa5a7b 100644 --- a/src/main/kotlin/com/vonage/client/kt/Vonage.kt +++ b/src/main/kotlin/com/vonage/client/kt/Vonage.kt @@ -28,8 +28,9 @@ class Vonage(init: VonageClient.Builder.() -> Unit) { val redact = Redact(vonageClient.redactClient) val verifyLegacy = VerifyLegacy(vonageClient.verifyClient) val numberInsight = NumberInsight(vonageClient.insightClient) - val simSwap = SimSwap(vonageClient.simSwapClient) + val numbers = Numbers(vonageClient.numbersClient) val numberVerification = NumberVerification(vonageClient.numberVerificationClient) + val simSwap = SimSwap(vonageClient.simSwapClient) } fun VonageClient.Builder.authFromEnv(): VonageClient.Builder { diff --git a/src/test/kotlin/com/vonage/client/kt/NumberVerificationTest.kt b/src/test/kotlin/com/vonage/client/kt/NumberVerificationTest.kt index d2e439e..b549219 100644 --- a/src/test/kotlin/com/vonage/client/kt/NumberVerificationTest.kt +++ b/src/test/kotlin/com/vonage/client/kt/NumberVerificationTest.kt @@ -62,8 +62,7 @@ class NumberVerificationTest : AbstractTest() { URLEncoder.encode(redirectUrl, "UTF-8") }&response_type=code" - val expectedUrlWithoutState = URI.create("$expectedUrlStr&state=null") - assertEquals(expectedUrlWithoutState, nvClient.createVerificationUrl(toNumber, redirectUrl)) + assertEquals(URI.create(expectedUrlStr), nvClient.createVerificationUrl(toNumber, redirectUrl)) val expectedUrlWithState = URI.create("$expectedUrlStr&state=$state") assertEquals(expectedUrlWithState, nvClient.createVerificationUrl(toNumber, redirectUrl, state)) diff --git a/src/test/kotlin/com/vonage/client/kt/NumbersTest.kt b/src/test/kotlin/com/vonage/client/kt/NumbersTest.kt new file mode 100644 index 0000000..21ed9ec --- /dev/null +++ b/src/test/kotlin/com/vonage/client/kt/NumbersTest.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2024 Vonage + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.vonage.client.kt + +import com.vonage.client.numbers.* +import kotlin.test.* + +class NumbersTest : AbstractTest() { + private val numbersClient = vonage.numbers + private val numbersBaseUrl = "/numbers" + private val country = "GB" + private val baseRequestParams = mapOf( + "country" to country, + "msisdn" to toNumber + ) + private val successResponseJson = """ + { + "error-code": "200", + "error-code-label": "success" + } + """.trimIndent() + + + +} \ No newline at end of file