Skip to content

Commit 6191d72

Browse files
authored
feat: Add domain/user parameters in Voice.connectToSip method (#26)
* feat: connectToSip domain/user parameters * connectToSip user explicitly nullable to avoid signature clash * Bump version to 1.1.4
1 parent e816d0d commit 6191d72

File tree

7 files changed

+78
-22
lines changed

7 files changed

+78
-22
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [1.1.4] - 2025-02-28
8+
9+
### Added
10+
- `Voice.connectToSip` overload with `domain` and `user` parameters
11+
12+
### Changed
13+
- Bumped Java SDK version to 8.17.0
14+
15+
### Deprecated
16+
- `Voice.dateStart` and `Voice.dateEnd` methods (redundant since Java SDK v8.17)
17+
718
## [1.1.3] - 2025-01-31
819

920
### Added

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ See all of our SDKs and integrations on the [Vonage Developer portal](https://de
5353
## Installation
5454
Releases are published to [Maven Central](https://central.sonatype.com/artifact/com.vonage/server-sdk-kotlin).
5555
Instructions for your build system can be found in the snippets section.
56-
They're also available from [here](https://search.maven.org/artifact/com.vonage/server-sdk-kotlin/1.1.3/jar).
56+
They're also available from [here](https://search.maven.org/artifact/com.vonage/server-sdk-kotlin/1.1.4/jar).
5757
Release notes for each version can be found in the [changelog](CHANGELOG.md).
5858

5959
Here are the instructions for including the SDK in your project:
@@ -63,7 +63,7 @@ Add the following to your `build.gradle` or `build.gradle.kts` file:
6363

6464
```groovy
6565
dependencies {
66-
implementation("com.vonage:server-sdk-kotlin:1.1.3")
66+
implementation("com.vonage:server-sdk-kotlin:1.1.4")
6767
}
6868
```
6969

@@ -74,7 +74,7 @@ Add the following to the `<dependencies>` section of your `pom.xml` file:
7474
<dependency>
7575
<groupId>com.vonage</groupId>
7676
<artifactId>server-sdk-kotlin</artifactId>
77-
<version>1.1.3</version>
77+
<version>1.1.4</version>
7878
</dependency>
7979
```
8080

@@ -160,8 +160,8 @@ including [**a searchable list of snippets**](https://github.com/Vonage/vonage-k
160160

161161
The SDK is fully documented with [KDocs](https://kotlinlang.org/docs/kotlin-doc.html), so you should have complete
162162
documentation from your IDE. You may need to click "Download Sources" in IntelliJ to get the full documentation.
163-
Alternatively, you can browse the documentation using a service like [Javadoc.io](https://javadoc.io/doc/com.vonage/server-sdk-kotlin/1.1.3/index.html),
164-
which renders the documentation for you from [the artifacts on Maven Central](https://repo.maven.apache.org/maven2/com/vonage/server-sdk-kotlin/1.1.3/).
163+
Alternatively, you can browse the documentation using a service like [Javadoc.io](https://javadoc.io/doc/com.vonage/server-sdk-kotlin/1.1.4/index.html),
164+
which renders the documentation for you from [the artifacts on Maven Central](https://repo.maven.apache.org/maven2/com/vonage/server-sdk-kotlin/1.1.4/).
165165

166166
For help with any specific APIs, refer to the relevant documentation on our [developer portal](https://developer.vonage.com/en/documentation),
167167
using the links provided in the [Supported APIs](#supported-apis) section. For completeness, you can also consult the

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.vonage</groupId>
77
<artifactId>server-sdk-kotlin</artifactId>
8-
<version>1.1.3</version>
8+
<version>1.1.4</version>
99

1010
<name>Vonage Kotlin Server SDK</name>
1111
<description>Kotlin client for Vonage APIs</description>
@@ -55,7 +55,7 @@
5555
<dependency>
5656
<groupId>com.vonage</groupId>
5757
<artifactId>server-sdk</artifactId>
58-
<version>8.16.2</version>
58+
<version>8.17.0</version>
5959
</dependency>
6060
<dependency>
6161
<groupId>org.jetbrains.kotlin</groupId>

src/main/kotlin/com/vonage/client/kt/Voice.kt

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ class Voice internal constructor(private val client: VoiceClient) {
190190
*
191191
* @return The updated [CallsFilter.Builder].
192192
*/
193-
fun CallsFilter.Builder.dateStart(dateStart: Instant): CallsFilter.Builder = dateStart(Date.from(dateStart))
193+
@Deprecated("Use CallsFilter.Builder.startDate instead.", replaceWith = ReplaceWith("startDate(dateStart)"))
194+
fun CallsFilter.Builder.dateStart(dateStart: Instant): CallsFilter.Builder = startDate(dateStart)
194195

195196
/**
196197
* Sets the end date for the [Voice.listCalls] filter.
@@ -199,7 +200,8 @@ fun CallsFilter.Builder.dateStart(dateStart: Instant): CallsFilter.Builder = dat
199200
*
200201
* @return The updated [CallsFilter.Builder].
201202
*/
202-
fun CallsFilter.Builder.dateEnd(dateEnd: Instant): CallsFilter.Builder = dateEnd(Date.from(dateEnd))
203+
@Deprecated("Use CallsFilter.Builder.endDate instead.", replaceWith = ReplaceWith("endDate(dateEnd)"))
204+
fun CallsFilter.Builder.dateEnd(dateEnd: Instant): CallsFilter.Builder = endDate(dateEnd)
203205

204206
/**
205207
* Configure the behavior of Advanced Machine Detection. This overrides [Call.Builder#machineDetection] setting
@@ -410,6 +412,22 @@ fun connectToWebsocket(uri: String, contentType: Websocket.ContentType, headers:
410412
.headers(headers).build(), properties
411413
)
412414

415+
private fun connectToSip(
416+
customHeaders: Map<String, Any>?,
417+
userToUserHeader: String?,
418+
connectProperties: ConnectAction.Builder.() -> Unit,
419+
sipProperties: com.vonage.client.voice.ncco.SipEndpoint.Builder.() -> Unit
420+
) : ConnectAction {
421+
val builder = com.vonage.client.voice.ncco.SipEndpoint.builder().apply(sipProperties)
422+
if (customHeaders != null) {
423+
builder.headers(customHeaders)
424+
}
425+
if (userToUserHeader != null) {
426+
builder.userToUserHeader(userToUserHeader)
427+
}
428+
return connectAction(builder.build(), connectProperties)
429+
}
430+
413431
/**
414432
* Builds an NCCO action to connect the call to a SIP endpoint.
415433
*
@@ -421,16 +439,26 @@ fun connectToWebsocket(uri: String, contentType: Websocket.ContentType, headers:
421439
* @return A new [ConnectAction] with the [com.vonage.client.voice.ncco.SipEndpoint] and specified properties.
422440
*/
423441
fun connectToSip(uri: String, customHeaders: Map<String, Any>? = null, userToUserHeader: String? = null,
424-
properties: ConnectAction.Builder.() -> Unit = {}) : ConnectAction {
425-
val builder = com.vonage.client.voice.ncco.SipEndpoint.builder(uri)
426-
if (customHeaders != null) {
427-
builder.headers(customHeaders)
428-
}
429-
if (userToUserHeader != null) {
430-
builder.userToUserHeader(userToUserHeader)
431-
}
432-
return connectAction(builder.build(), properties)
433-
}
442+
properties: ConnectAction.Builder.() -> Unit = {}) : ConnectAction =
443+
connectToSip(customHeaders, userToUserHeader, properties) { uri(uri) }
444+
445+
/**
446+
* Builds an NCCO action to connect the call to a SIP endpoint.
447+
*
448+
* @param domain Identifier of the SIP domain provisioned using the Programmable SIP API or SIP trunking dashboard.
449+
* @param user (OPTIONAL) The SIP domain user, which will be used in conjunction with the domain to create the SIP URI.
450+
* @param customHeaders (OPTIONAL) A map of custom metadata to send with the SIP connection.
451+
* @param userToUserHeader (OPTIONAL) A string to send as the User-to-User header, as per RFC 7433.
452+
* @param properties (OPTIONAL) A lambda function for additional configuration of the connect action parameters.
453+
*
454+
* @return A new [ConnectAction] with the [com.vonage.client.voice.ncco.SipEndpoint] and specified properties.
455+
*
456+
* @since 1.1.4
457+
*/
458+
fun connectToSip(domain: String, user: String?,
459+
customHeaders: Map<String, Any>? = null, userToUserHeader: String? = null,
460+
properties: ConnectAction.Builder.() -> Unit = {}) : ConnectAction =
461+
connectToSip(customHeaders, userToUserHeader, properties) { domain(domain).user(user) }
434462

435463
/**
436464
* Sets the call destination to a Public Switched Telephone Network (PSTN) or mobile number.

src/main/kotlin/com/vonage/client/kt/Vonage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.vonage.client.VonageClient
2121
/**
2222
* Denotes the version of the Vonage Kotlin SDK being used, in SemVer format.
2323
*/
24-
const val VONAGE_KOTLIN_SDK_VERSION = "1.1.3"
24+
const val VONAGE_KOTLIN_SDK_VERSION = "1.1.4"
2525

2626
/**
2727
* The non-overridable user agent string used by the SDK.

src/test/kotlin/com/vonage/client/kt/NumberInsightTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ class NumberInsightTest : AbstractTest() {
161161
expectedUrl = "/ni/${type.name.lowercase().replace('_', '/')}/json",
162162
expectedRequestParams = expectedRequestParams,
163163
expectedResponseParams = expectedResponseParams,
164-
authType = if (type == InsightType.BASIC)
165-
AuthType.API_KEY_SECRET_HEADER else AuthType.API_KEY_SECRET_QUERY_PARAMS
164+
authType = AuthType.API_KEY_SECRET_HEADER
166165
)
167166
}
168167

src/test/kotlin/com/vonage/client/kt/VoiceTest.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class VoiceTest : AbstractTest() {
4040
private val count = 89
4141
private val pageSize = 25
4242
private val recordIndex = 14
43+
private val sipDomainName = "my_example-domain"
4344
private val fromPstn = "14155550100"
4445
private val streamUrl = "$exampleUrlBase/waiting.mp3"
4546
private val onAnswerUrl = "$exampleUrlBase/ncco.json"
@@ -721,12 +722,29 @@ class VoiceTest : AbstractTest() {
721722
connectToSip(sipUri)
722723
)
723724

725+
testSingleNccoConnect(
726+
mapOf("domain" to sipDomainName),
727+
connectToSip(sipDomainName, user = null)
728+
)
729+
730+
testSingleNccoConnect(
731+
mapOf("domain" to sipDomainName, "user" to userName),
732+
connectToSip(sipDomainName, userName)
733+
)
734+
724735
testSingleNccoConnect(
725736
mapOf("uri" to sipUri, "headers" to customHeaders,
726737
"standardHeaders" to mapOf("User-to-User" to userToUserHeader)
727738
),
728739
connectToSip(sipUri, customHeaders, userToUserHeader)
729740
)
741+
742+
testSingleNccoConnect(
743+
mapOf("domain" to sipDomainName, "user" to userName, "headers" to customHeaders,
744+
"standardHeaders" to mapOf("User-to-User" to userToUserHeader)
745+
),
746+
connectToSip(sipDomainName, userName, customHeaders, userToUserHeader)
747+
)
730748
}
731749

732750
@Test

0 commit comments

Comments
 (0)