Skip to content

Commit 0cb4764

Browse files
committed
refactor!: Sms.wasSuccessfully extension function
1 parent 04999ae commit 0cb4764

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ 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.0.0] - 2024-10-?? (expected)
8+
First stable GA release
9+
10+
### Changed
11+
- `Sms.wasSuccessfullySent()` now an extension function rather than being part of the client
12+
713
## [1.0.0-RC2] - 2024-09-26
814
Messages API updates based on Java SDK v8.11.0
915

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.0.0-RC2</version>
8+
<version>1.0.0</version>
99

1010
<name>Vonage Kotlin Server SDK</name>
1111
<description>Kotlin client for Vonage APIs</description>
@@ -249,7 +249,7 @@
249249
<plugins>
250250
<plugin>
251251
<artifactId>maven-gpg-plugin</artifactId>
252-
<version>3.2.6</version>
252+
<version>3.2.7</version>
253253
<executions>
254254
<execution>
255255
<id>sign-artifacts</id>

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,12 @@ class Sms internal constructor(private val client: SmsClient) {
122122
if (protocolId != null) msgObj.protocolId = protocolId
123123
return send(msgObj, statusReport, ttl, messageClass, clientRef, contentId, entityId, callbackUrl)
124124
}
125-
126-
/**
127-
* Convenience method to check if all messages were sent successfully.
128-
*
129-
* @param response The list of [SmsSubmissionResponseMessage] objects returned when sending a message.
130-
*
131-
* @return `true` if all messages responses have a status of [MessageStatus.OK], `false` otherwise.
132-
*/
133-
fun wasSuccessfullySent(response: List<SmsSubmissionResponseMessage>): Boolean =
134-
response.all { ssrm -> ssrm.status == MessageStatus.OK }
135125
}
126+
127+
/**
128+
* Convenience method to check if all messages were sent successfully.
129+
*
130+
* @return `true` if all messages responses have a status of [MessageStatus.OK], `false` otherwise.
131+
*/
132+
fun List<SmsSubmissionResponseMessage>.wasSuccessfullySent(): Boolean =
133+
isNotEmpty() && all { it.status == MessageStatus.OK }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.vonage.client.kt
1818
import com.vonage.client.HttpConfig
1919
import com.vonage.client.VonageClient
2020

21-
const val VONAGE_KOTLIN_SDK_VERSION = "1.0.0-RC2"
21+
const val VONAGE_KOTLIN_SDK_VERSION = "1.0.0"
2222
private const val SDK_USER_AGENT = "vonage-kotlin-sdk/$VONAGE_KOTLIN_SDK_VERSION"
2323

2424
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SmsTest : AbstractTest() {
7070
assertEquals(network, first.network)
7171
assertEquals(clientRef, first.clientRef)
7272
assertEquals(accountRef, first.accountRef)
73-
assertTrue(client.wasSuccessfullySent(response))
73+
assertTrue(response.wasSuccessfullySent())
7474
}
7575

7676
private fun errorStatus(code: Int, text: String) = mapOf("status" to code, "error-text" to text)
@@ -185,7 +185,7 @@ class SmsTest : AbstractTest() {
185185
)
186186
val response = client.sendText(from, toNumber, text)
187187
assertNotNull(response)
188-
assertFalse(client.wasSuccessfullySent(response))
188+
assertFalse(response.wasSuccessfullySent())
189189

190190
assertEquals(24, response.size)
191191
var offset = 0

0 commit comments

Comments
 (0)