diff --git a/README.md b/README.md
index 6e62098..5b5aac5 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@


-
+
[](https://twitter.com/appwrite)
[](https://appwrite.io/discord)
@@ -39,7 +39,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:
```groovy
-implementation("io.appwrite:sdk-for-kotlin:5.0.0")
+implementation("io.appwrite:sdk-for-kotlin:5.0.1")
```
### Maven
@@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file:
io.appwrite
sdk-for-kotlin
- 5.0.0
+ 5.0.1
```
diff --git a/docs/examples/java/messaging/create-msg91provider.md b/docs/examples/java/messaging/create-msg91provider.md
index 2f4ef83..9d7ffcb 100644
--- a/docs/examples/java/messaging/create-msg91provider.md
+++ b/docs/examples/java/messaging/create-msg91provider.md
@@ -12,7 +12,7 @@ Messaging messaging = new Messaging(client);
messaging.createMsg91Provider(
"", // providerId
"", // name
- "+12065550100", // from (optional)
+ "", // templateId (optional)
"", // senderId (optional)
"", // authKey (optional)
false, // enabled (optional)
diff --git a/docs/examples/java/messaging/update-msg91provider.md b/docs/examples/java/messaging/update-msg91provider.md
index b9ba21d..700995e 100644
--- a/docs/examples/java/messaging/update-msg91provider.md
+++ b/docs/examples/java/messaging/update-msg91provider.md
@@ -13,9 +13,9 @@ messaging.updateMsg91Provider(
"", // providerId
"", // name (optional)
false, // enabled (optional)
+ "", // templateId (optional)
"", // senderId (optional)
"", // authKey (optional)
- "", // from (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
diff --git a/docs/examples/kotlin/messaging/create-msg91provider.md b/docs/examples/kotlin/messaging/create-msg91provider.md
index 1299fa7..e3bf36c 100644
--- a/docs/examples/kotlin/messaging/create-msg91provider.md
+++ b/docs/examples/kotlin/messaging/create-msg91provider.md
@@ -12,7 +12,7 @@ val messaging = Messaging(client)
val response = messaging.createMsg91Provider(
providerId = "",
name = "",
- from = "+12065550100", // optional
+ templateId = "", // optional
senderId = "", // optional
authKey = "", // optional
enabled = false // optional
diff --git a/docs/examples/kotlin/messaging/update-msg91provider.md b/docs/examples/kotlin/messaging/update-msg91provider.md
index 4e30528..c5c690b 100644
--- a/docs/examples/kotlin/messaging/update-msg91provider.md
+++ b/docs/examples/kotlin/messaging/update-msg91provider.md
@@ -13,7 +13,7 @@ val response = messaging.updateMsg91Provider(
providerId = "",
name = "", // optional
enabled = false, // optional
+ templateId = "", // optional
senderId = "", // optional
- authKey = "", // optional
- from = "" // optional
+ authKey = "" // optional
)
diff --git a/src/main/kotlin/io/appwrite/Client.kt b/src/main/kotlin/io/appwrite/Client.kt
index b65eacc..6da64e3 100644
--- a/src/main/kotlin/io/appwrite/Client.kt
+++ b/src/main/kotlin/io/appwrite/Client.kt
@@ -57,11 +57,11 @@ class Client @JvmOverloads constructor(
init {
headers = mutableMapOf(
"content-type" to "application/json",
- "user-agent" to "AppwriteKotlinSDK/5.0.0 ${System.getProperty("http.agent")}",
+ "user-agent" to "AppwriteKotlinSDK/5.0.1 ${System.getProperty("http.agent")}",
"x-sdk-name" to "Kotlin",
"x-sdk-platform" to "server",
"x-sdk-language" to "kotlin",
- "x-sdk-version" to "5.0.0",
+ "x-sdk-version" to "5.0.1",
"x-appwrite-response-format" to "1.5.0",
)
diff --git a/src/main/kotlin/io/appwrite/ID.kt b/src/main/kotlin/io/appwrite/ID.kt
index fe8e656..b1a9cf7 100644
--- a/src/main/kotlin/io/appwrite/ID.kt
+++ b/src/main/kotlin/io/appwrite/ID.kt
@@ -1,10 +1,33 @@
package io.appwrite
+import java.time.Instant
+import kotlin.math.floor
+import kotlin.random.Random
+
class ID {
companion object {
+ // Generate an hex ID based on timestamp
+ // Recreated from https://www.php.net/manual/en/function.uniqid.php
+ private fun hexTimestamp(): String {
+ val now = Instant.now()
+ val sec = now.epochSecond
+ val usec = (System.nanoTime() / 1000) % 1000
+
+ val hexTimestamp = "%08x%05x".format(sec, usec)
+
+ return hexTimestamp
+ }
+
fun custom(id: String): String
= id
- fun unique(): String
- = "unique()"
+ // Generate a unique ID with padding to have a longer ID
+ fun unique(padding: Int = 7): String {
+ val baseId = ID.hexTimestamp()
+ val randomPadding = (1..padding)
+ .map { Random.nextInt(0, 16).toString(16) }
+ .joinToString("")
+
+ return baseId + randomPadding
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/main/kotlin/io/appwrite/services/Messaging.kt b/src/main/kotlin/io/appwrite/services/Messaging.kt
index 6828c2c..4fef5cd 100644
--- a/src/main/kotlin/io/appwrite/services/Messaging.kt
+++ b/src/main/kotlin/io/appwrite/services/Messaging.kt
@@ -941,9 +941,9 @@ class Messaging(client: Client) : Service(client) {
*
* @param providerId Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
* @param name Provider name.
- * @param from Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
- * @param senderId Msg91 Sender ID.
- * @param authKey Msg91 Auth Key.
+ * @param templateId Msg91 template ID
+ * @param senderId Msg91 sender ID.
+ * @param authKey Msg91 auth key.
* @param enabled Set as enabled.
* @return [io.appwrite.models.Provider]
*/
@@ -952,7 +952,7 @@ class Messaging(client: Client) : Service(client) {
suspend fun createMsg91Provider(
providerId: String,
name: String,
- from: String? = null,
+ templateId: String? = null,
senderId: String? = null,
authKey: String? = null,
enabled: Boolean? = null,
@@ -962,7 +962,7 @@ class Messaging(client: Client) : Service(client) {
val apiParams = mutableMapOf(
"providerId" to providerId,
"name" to name,
- "from" to from,
+ "templateId" to templateId,
"senderId" to senderId,
"authKey" to authKey,
"enabled" to enabled,
@@ -991,9 +991,9 @@ class Messaging(client: Client) : Service(client) {
* @param providerId Provider ID.
* @param name Provider name.
* @param enabled Set as enabled.
- * @param senderId Msg91 Sender ID.
- * @param authKey Msg91 Auth Key.
- * @param from Sender number.
+ * @param templateId Msg91 template ID.
+ * @param senderId Msg91 sender ID.
+ * @param authKey Msg91 auth key.
* @return [io.appwrite.models.Provider]
*/
@JvmOverloads
@@ -1002,9 +1002,9 @@ class Messaging(client: Client) : Service(client) {
providerId: String,
name: String? = null,
enabled: Boolean? = null,
+ templateId: String? = null,
senderId: String? = null,
authKey: String? = null,
- from: String? = null,
): io.appwrite.models.Provider {
val apiPath = "/messaging/providers/msg91/{providerId}"
.replace("{providerId}", providerId)
@@ -1012,9 +1012,9 @@ class Messaging(client: Client) : Service(client) {
val apiParams = mutableMapOf(
"name" to name,
"enabled" to enabled,
+ "templateId" to templateId,
"senderId" to senderId,
"authKey" to authKey,
- "from" to from,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",