Skip to content
Merged
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-kotlin.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-kotlin.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.6-blue.svg?style=flat-square)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

Expand Down Expand Up @@ -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.1")
implementation("io.appwrite:sdk-for-kotlin:5.0.2")
```

### Maven
Expand All @@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-kotlin</artifactId>
<version>5.0.1</version>
<version>5.0.2</version>
</dependency>
</dependencies>
```
Expand Down
1 change: 1 addition & 0 deletions docs/examples/java/messaging/update-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ messaging.updateEmail(
listOf(), // cc (optional)
listOf(), // bcc (optional)
"", // scheduledAt (optional)
listOf(), // attachments (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/kotlin/messaging/update-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ val response = messaging.updateEmail(
html = false, // optional
cc = listOf(), // optional
bcc = listOf(), // optional
scheduledAt = "" // optional
scheduledAt = "", // optional
attachments = listOf() // optional
)
4 changes: 2 additions & 2 deletions src/main/kotlin/io/appwrite/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class Client @JvmOverloads constructor(
init {
headers = mutableMapOf(
"content-type" to "application/json",
"user-agent" to "AppwriteKotlinSDK/5.0.1 ${System.getProperty("http.agent")}",
"user-agent" to "AppwriteKotlinSDK/5.0.2 ${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.1",
"x-sdk-version" to "5.0.2",
"x-appwrite-response-format" to "1.5.0",
)

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/io/appwrite/enums/CreditCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ enum class CreditCard(val value: String) {
ARGENCARD("argencard"),
@SerializedName("cabal")
CABAL("cabal"),
@SerializedName("censosud")
CONSOSUD("censosud"),
@SerializedName("cencosud")
CENCOSUD("cencosud"),
@SerializedName("diners")
DINERS_CLUB("diners"),
@SerializedName("discover")
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/io/appwrite/enums/Flag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ enum class Flag(val value: String) {
PAPUA_NEW_GUINEA("pg"),
@SerializedName("pl")
POLAND("pl"),
@SerializedName("pf")
FRENCH_POLYNESIA("pf"),
@SerializedName("kp")
NORTH_KOREA("kp"),
@SerializedName("pt")
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/io/appwrite/enums/Runtime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ enum class Runtime(val value: String) {
PYTHON_3_11("python-3.11"),
@SerializedName("python-3.12")
PYTHON_3_12("python-3.12"),
@SerializedName("python-ml-3.11")
PYTHON_ML_3_11("python-ml-3.11"),
@SerializedName("deno-1.40")
DENO_1_40("deno-1.40"),
@SerializedName("dart-2.15")
Expand Down
14 changes: 11 additions & 3 deletions src/main/kotlin/io/appwrite/models/MfaFactors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,35 @@ import io.appwrite.extensions.jsonCast
*/
data class MfaFactors(
/**
* TOTP
* Can TOTP be used for MFA challenge for this account.
*/
@SerializedName("totp")
val totp: Boolean,

/**
* Phone
* Can phone (SMS) be used for MFA challenge for this account.
*/
@SerializedName("phone")
val phone: Boolean,

/**
* Email
* Can email be used for MFA challenge for this account.
*/
@SerializedName("email")
val email: Boolean,

/**
* Can recovery code be used for MFA challenge for this account.
*/
@SerializedName("recoveryCode")
val recoveryCode: Boolean,

) {
fun toMap(): Map<String, Any> = mapOf(
"totp" to totp as Any,
"phone" to phone as Any,
"email" to email as Any,
"recoveryCode" to recoveryCode as Any,
)

companion object {
Expand All @@ -41,6 +48,7 @@ data class MfaFactors(
totp = map["totp"] as Boolean,
phone = map["phone"] as Boolean,
email = map["email"] as Boolean,
recoveryCode = map["recoveryCode"] as Boolean,
)
}
}
8 changes: 8 additions & 0 deletions src/main/kotlin/io/appwrite/models/Session.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ data class Session(
@SerializedName("\$createdAt")
val createdAt: String,

/**
* Session update date in ISO 8601 format.
*/
@SerializedName("\$updatedAt")
val updatedAt: String,

/**
* User ID.
*/
Expand Down Expand Up @@ -179,6 +185,7 @@ data class Session(
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"userId" to userId as Any,
"expire" to expire as Any,
"provider" to provider as Any,
Expand Down Expand Up @@ -215,6 +222,7 @@ data class Session(
) = Session(
id = map["\$id"] as String,
createdAt = map["\$createdAt"] as String,
updatedAt = map["\$updatedAt"] as String,
userId = map["userId"] as String,
expire = map["expire"] as String,
provider = map["provider"] as String,
Expand Down
38 changes: 7 additions & 31 deletions src/main/kotlin/io/appwrite/services/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class Account(client: Client) : Service(client) {
/**
* Add Authenticator
*
* Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) method.
* Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method.
*
* @param type Type of authenticator. Must be `totp`
* @return [io.appwrite.models.MfaType]
Expand Down Expand Up @@ -396,7 +396,7 @@ class Account(client: Client) : Service(client) {
/**
* Verify Authenticator
*
* Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method.
* Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add
*
* @param type Type of authenticator.
* @param otp Valid verification token.
Expand Down Expand Up @@ -433,7 +433,7 @@ class Account(client: Client) : Service(client) {
/**
* Verify Authenticator
*
* Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method.
* Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add
*
* @param type Type of authenticator.
* @param otp Valid verification token.
Expand All @@ -456,14 +456,13 @@ class Account(client: Client) : Service(client) {
*
* @param type Type of authenticator.
* @param otp Valid verification token.
* @return [io.appwrite.models.User<T>]
* @return [Any]
*/
@Throws(AppwriteException::class)
suspend fun <T> deleteMfaAuthenticator(
suspend fun deleteMfaAuthenticator(
type: io.appwrite.enums.AuthenticatorType,
otp: String,
nestedType: Class<T>,
): io.appwrite.models.User<T> {
): Any {
val apiPath = "/account/mfa/authenticators/{type}"
.replace("{type}", type.value)

Expand All @@ -473,38 +472,15 @@ class Account(client: Client) : Service(client) {
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
)
val converter: (Any) -> io.appwrite.models.User<T> = {
io.appwrite.models.User.from(map = it as Map<String, Any>, nestedType)
}
return client.call(
"DELETE",
apiPath,
apiHeaders,
apiParams,
responseType = classOf(),
converter,
responseType = Any::class.java,
)
}

/**
* Delete Authenticator
*
* Delete an authenticator for a user by ID.
*
* @param type Type of authenticator.
* @param otp Valid verification token.
* @return [io.appwrite.models.User<T>]
*/
@Throws(AppwriteException::class)
suspend fun deleteMfaAuthenticator(
type: io.appwrite.enums.AuthenticatorType,
otp: String,
): io.appwrite.models.User<Map<String, Any>> = deleteMfaAuthenticator(
type,
otp,
nestedType = classOf(),
)

/**
* Create 2FA Challenge
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/appwrite/services/Avatars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Avatars(client: Client) : Service(client) {
*
* The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings.When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.
*
* @param code Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.
* @param code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.
* @param width Image width. Pass an integer between 0 to 2000. Defaults to 100.
* @param height Image height. Pass an integer between 0 to 2000. Defaults to 100.
* @param quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
Expand Down
9 changes: 6 additions & 3 deletions src/main/kotlin/io/appwrite/services/Messaging.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Messaging(client: Client) : Service(client) {
* @param targets List of Targets IDs.
* @param cc Array of target IDs to be added as CC.
* @param bcc Array of target IDs to be added as BCC.
* @param attachments Array of compound bucket IDs to file IDs to be attached to the email.
* @param attachments Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.
* @param draft Is message a draft
* @param html Is content of type HTML
* @param scheduledAt Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.
Expand Down Expand Up @@ -133,6 +133,7 @@ class Messaging(client: Client) : Service(client) {
* @param cc Array of target IDs to be added as CC.
* @param bcc Array of target IDs to be added as BCC.
* @param scheduledAt Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.
* @param attachments Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.
* @return [io.appwrite.models.Message]
*/
@JvmOverloads
Expand All @@ -149,6 +150,7 @@ class Messaging(client: Client) : Service(client) {
cc: List<String>? = null,
bcc: List<String>? = null,
scheduledAt: String? = null,
attachments: List<String>? = null,
): io.appwrite.models.Message {
val apiPath = "/messaging/messages/email/{messageId}"
.replace("{messageId}", messageId)
Expand All @@ -164,6 +166,7 @@ class Messaging(client: Client) : Service(client) {
"cc" to cc,
"bcc" to bcc,
"scheduledAt" to scheduledAt,
"attachments" to attachments,
)
val apiHeaders = mutableMapOf(
"content-type" to "application/json",
Expand Down Expand Up @@ -194,7 +197,7 @@ class Messaging(client: Client) : Service(client) {
* @param targets List of Targets IDs.
* @param data Additional Data for push notification.
* @param action Action for push notification.
* @param image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage.
* @param image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.
* @param icon Icon for push notification. Available only for Android and Web Platform.
* @param sound Sound for push notification. Available only for Android and IOS Platform.
* @param color Color for push notification. Available only for Android Platform.
Expand Down Expand Up @@ -273,7 +276,7 @@ class Messaging(client: Client) : Service(client) {
* @param body Body for push notification.
* @param data Additional Data for push notification.
* @param action Action for push notification.
* @param image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage.
* @param image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.
* @param icon Icon for push notification. Available only for Android and Web platforms.
* @param sound Sound for push notification. Available only for Android and iOS platforms.
* @param color Color for push notification. Available only for Android platforms.
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/appwrite/services/Users.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ class Users(client: Client) : Service(client) {
/**
* Create token
*
* Returns a token with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession) endpoint to complete the login process.
* Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process.
*
* @param userId User ID.
* @param length Token length in characters. The default length is 6 characters
Expand Down