Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Add this dependency to your `pom.xml`:
<dependency>
<groupId>com.cloudcontactai</groupId>
<artifactId>ccai-java-sdk</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
</dependency>
```

Expand All @@ -41,7 +41,7 @@ Add this dependency to your `pom.xml`:
Add this dependency to your `build.gradle`:

```gradle
implementation 'com.cloudcontactai:ccai-java-sdk:1.1.0'
implementation 'com.cloudcontactai:ccai-java-sdk:1.2.0'
```

## Configuration
Expand Down
2 changes: 1 addition & 1 deletion integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Override with -Dccai.sdk.version=X.Y.Z for release testing -->
<ccai.sdk.version>1.1.0</ccai.sdk.version>
<ccai.sdk.version>1.2.0</ccai.sdk.version>
</properties>

<dependencies>
Expand Down
30 changes: 24 additions & 6 deletions integration/src/main/kotlin/com/ccai/integration/TestMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import java.util.Base64
import kotlin.system.exitProcess

// ---------------------------------------------------------------------------
// CCAI Java (Kotlin) SDK Integration Tests — 52 tests
// CCAI Java (Kotlin) SDK Integration Tests — 54 tests
// Covers: SMS (1-6), MMS (7-17), Email (18-22), Webhook (23-29), Contact (30-31),
// Brands (32-36), Campaigns (37-42), ContactValidator (43-46), Negative cases (47-52)
// Brands (32-36), Campaigns (37-42), ContactValidator (43-46), Negative cases (47-52),
// SMS Templates (53-54)
//
// Test results use three states:
// PASS — the test ran and all assertions held
Expand All @@ -40,7 +41,7 @@ val requiredEnv = listOf(
"CCAI_TEST_FIRST_NAME", "CCAI_TEST_LAST_NAME",
"CCAI_TEST_FIRST_NAME_2", "CCAI_TEST_LAST_NAME_2",
"CCAI_TEST_FIRST_NAME_3", "CCAI_TEST_LAST_NAME_3",
"WEBHOOK_URL"
"WEBHOOK_URL", "CCAI_TEST_TEMPLATE_ID"
)

val clientId = System.getenv("CCAI_CLIENT_ID") ?: ""
Expand All @@ -57,6 +58,7 @@ val first2 = System.getenv("CCAI_TEST_FIRST_NAME_2") ?: ""
val last2 = System.getenv("CCAI_TEST_LAST_NAME_2") ?: ""
val first3 = System.getenv("CCAI_TEST_FIRST_NAME_3") ?: ""
val last3 = System.getenv("CCAI_TEST_LAST_NAME_3") ?: ""
val templateId = System.getenv("CCAI_TEST_TEMPLATE_ID")?.toLongOrNull() ?: 0L

// Unique per-run suffix so parallel SDK runs don't collide on the same webhook URL
val runId = "java-${System.currentTimeMillis() / 1000}"
Expand Down Expand Up @@ -197,9 +199,12 @@ fun main() {

runTest("06 SMS sendSingle with customData") {
val res = client.sms.sendSingle(
first1, last1, phone1,
"Custom data test", "Java Test 06",
"""{"source":"java-integration"}"""
firstName = first1,
lastName = last1,
phone = phone1,
message = "Custom data test",
title = "Java Test 06",
customData = """{"source":"java-integration"}"""
)
check(res.id.isNotBlank()) { "Empty id in response" }
}
Expand Down Expand Up @@ -693,6 +698,19 @@ fun main() {
)
assertMmsResponse(res)
}

println("\n--- SMS Templates ---")

runTest("53 SMS sendWithTemplate") {
val accounts = listOf(SmsAccount(first1, last1, phone1), SmsAccount(first2, last2, phone2))
val res = client.sms.sendWithTemplate(accounts, templateId, "Java Template Test")
check(res.id.isNotBlank()) { "Empty id in response" }
}

runTest("54 SMS sendSingleWithTemplate") {
val res = client.sms.sendSingleWithTemplate(first1, last1, phone1, templateId, "Java Single Template Test")
check(res.id.isNotBlank()) { "Empty id in response" }
}
} finally {
// -------------------------------------------------------------------
// Cleanup — always runs, even if the test body threw: delete leftover
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.cloudcontactai</groupId>
<artifactId>ccai-java-sdk</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<name>CCAI Java SDK</name>
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/com/cloudcontactai/sdk/sms/SMSService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.cloudcontactai.sdk.common.ApiClient
import com.cloudcontactai.sdk.common.CCAIConfig

class SMSService(private val config: CCAIConfig, private val apiClient: ApiClient) {

fun sendSingle(
firstName: String,
lastName: String,
Expand All @@ -17,7 +17,7 @@ class SMSService(private val config: CCAIConfig, private val apiClient: ApiClien
lastName = lastName,
phone = phone
)

return send(listOf(account), message, title)
}

Expand Down Expand Up @@ -56,7 +56,7 @@ class SMSService(private val config: CCAIConfig, private val apiClient: ApiClien

return send(listOf(account), message, title, senderPhone)
}

fun send(
accounts: List<Account>,
message: String,
Expand All @@ -71,9 +71,9 @@ class SMSService(private val config: CCAIConfig, private val apiClient: ApiClien
senderPhone = senderPhone,
templateId = templateId
)

val headers = mapOf("ForceNewCampaign" to "false")

return apiClient.request(
method = "POST",
endpoint = "/clients/${config.clientId}/campaigns/direct",
Expand Down Expand Up @@ -103,7 +103,7 @@ class SMSService(private val config: CCAIConfig, private val apiClient: ApiClien
val account = Account(firstName = firstName, lastName = lastName, phone = phone)
return sendWithTemplate(listOf(account), templateId, title, senderPhone)
}

fun getCampaignStatus(campaignId: String): SMSCampaignStatus {
return apiClient.request(
method = "GET",
Expand Down