Skip to content

Add inc/dec #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
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.7.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.7.4-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:9.0.0")
implementation("io.appwrite:sdk-for-kotlin:9.1.0")
```

### 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>9.0.0</version>
<version>9.1.0</version>
</dependency>
</dependencies>
```
Expand Down
1 change: 1 addition & 0 deletions docs/examples/java/databases/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.appwrite.services.Databases;

Client client = new Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setAdmin("") //
.setSession("") // The user session to authenticate with
.setKey("<YOUR_API_KEY>") // Your secret API key
.setJWT("<YOUR_JWT>"); // Your secret JSON Web Token
Expand Down
28 changes: 28 additions & 0 deletions docs/examples/java/databases/decrement-document-attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Databases;

Client client = new Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>"); // Your secret API key

Databases databases = new Databases(client);

databases.decrementDocumentAttribute(
"<DATABASE_ID>", // databaseId
"<COLLECTION_ID>", // collectionId
"<DOCUMENT_ID>", // documentId
"", // attribute
0, // value (optional)
0, // min (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}

System.out.println(result);
})
);

28 changes: 28 additions & 0 deletions docs/examples/java/databases/increment-document-attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Databases;

Client client = new Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>"); // Your secret API key

Databases databases = new Databases(client);

databases.incrementDocumentAttribute(
"<DATABASE_ID>", // databaseId
"<COLLECTION_ID>", // collectionId
"<DOCUMENT_ID>", // documentId
"", // attribute
0, // value (optional)
0, // max (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}

System.out.println(result);
})
);

27 changes: 27 additions & 0 deletions docs/examples/java/databases/upsert-document.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import io.appwrite.Client;
import io.appwrite.coroutines.CoroutineCallback;
import io.appwrite.services.Databases;

Client client = new Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setSession(""); // The user session to authenticate with

Databases databases = new Databases(client);

databases.upsertDocument(
"<DATABASE_ID>", // databaseId
"<COLLECTION_ID>", // collectionId
"<DOCUMENT_ID>", // documentId
mapOf( "a" to "b" ), // data
listOf("read("any")"), // permissions (optional)
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
return;
}

System.out.println(result);
})
);

2 changes: 1 addition & 1 deletion docs/examples/java/databases/upsert-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Databases databases = new Databases(client);
databases.upsertDocuments(
"<DATABASE_ID>", // databaseId
"<COLLECTION_ID>", // collectionId
listOf(), // documents (optional)
listOf(), // documents
new CoroutineCallback<>((result, error) -> {
if (error != null) {
error.printStackTrace();
Expand Down
1 change: 1 addition & 0 deletions docs/examples/kotlin/databases/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.appwrite.services.Databases

val client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setAdmin("") //
.setSession("") // The user session to authenticate with
.setKey("<YOUR_API_KEY>") // Your secret API key
.setJWT("<YOUR_JWT>") // Your secret JSON Web Token
Expand Down
19 changes: 19 additions & 0 deletions docs/examples/kotlin/databases/decrement-document-attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Databases

val client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key

val databases = Databases(client)

val response = databases.decrementDocumentAttribute(
databaseId = "<DATABASE_ID>",
collectionId = "<COLLECTION_ID>",
documentId = "<DOCUMENT_ID>",
attribute = "",
value = 0, // optional
min = 0 // optional
)
19 changes: 19 additions & 0 deletions docs/examples/kotlin/databases/increment-document-attribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Databases

val client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setKey("<YOUR_API_KEY>") // Your secret API key

val databases = Databases(client)

val response = databases.incrementDocumentAttribute(
databaseId = "<DATABASE_ID>",
collectionId = "<COLLECTION_ID>",
documentId = "<DOCUMENT_ID>",
attribute = "",
value = 0, // optional
max = 0 // optional
)
18 changes: 18 additions & 0 deletions docs/examples/kotlin/databases/upsert-document.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import io.appwrite.Client
import io.appwrite.coroutines.CoroutineCallback
import io.appwrite.services.Databases

val client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
.setProject("<YOUR_PROJECT_ID>") // Your project ID
.setSession("") // The user session to authenticate with

val databases = Databases(client)

val response = databases.upsertDocument(
databaseId = "<DATABASE_ID>",
collectionId = "<COLLECTION_ID>",
documentId = "<DOCUMENT_ID>",
data = mapOf( "a" to "b" ),
permissions = listOf("read("any")") // optional
)
2 changes: 1 addition & 1 deletion docs/examples/kotlin/databases/upsert-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ val databases = Databases(client)
val response = databases.upsertDocuments(
databaseId = "<DATABASE_ID>",
collectionId = "<COLLECTION_ID>",
documents = listOf() // optional
documents = listOf()
)
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 @@ -58,11 +58,11 @@ class Client @JvmOverloads constructor(
init {
headers = mutableMapOf(
"content-type" to "application/json",
"user-agent" to "AppwriteKotlinSDK/9.0.0 ${System.getProperty("http.agent")}",
"user-agent" to "AppwriteKotlinSDK/9.1.0 ${System.getProperty("http.agent")}",
"x-sdk-name" to "Kotlin",
"x-sdk-platform" to "server",
"x-sdk-language" to "kotlin",
"x-sdk-version" to "9.0.0",
"x-sdk-version" to "9.1.0",
"x-appwrite-response-format" to "1.7.0",
)

Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/io/appwrite/enums/BuildRuntime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ enum class BuildRuntime(val value: String) {
DART_3_3("dart-3.3"),
@SerializedName("dart-3.5")
DART_3_5("dart-3.5"),
@SerializedName("dart-3.8")
DART_3_8("dart-3.8"),
@SerializedName("dotnet-6.0")
DOTNET_6_0("dotnet-6.0"),
@SerializedName("dotnet-7.0")
Expand Down Expand Up @@ -128,7 +130,9 @@ enum class BuildRuntime(val value: String) {
@SerializedName("flutter-3.27")
FLUTTER_3_27("flutter-3.27"),
@SerializedName("flutter-3.29")
FLUTTER_3_29("flutter-3.29");
FLUTTER_3_29("flutter-3.29"),
@SerializedName("flutter-3.32")
FLUTTER_3_32("flutter-3.32");

override fun toString() = value
}
4 changes: 3 additions & 1 deletion src/main/kotlin/io/appwrite/enums/ImageFormat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ enum class ImageFormat(val value: String) {
@SerializedName("heic")
HEIC("heic"),
@SerializedName("avif")
AVIF("avif");
AVIF("avif"),
@SerializedName("gif")
GIF("gif");

override fun toString() = value
}
6 changes: 5 additions & 1 deletion src/main/kotlin/io/appwrite/enums/Runtime.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ enum class Runtime(val value: String) {
DART_3_3("dart-3.3"),
@SerializedName("dart-3.5")
DART_3_5("dart-3.5"),
@SerializedName("dart-3.8")
DART_3_8("dart-3.8"),
@SerializedName("dotnet-6.0")
DOTNET_6_0("dotnet-6.0"),
@SerializedName("dotnet-7.0")
Expand Down Expand Up @@ -128,7 +130,9 @@ enum class Runtime(val value: String) {
@SerializedName("flutter-3.27")
FLUTTER_3_27("flutter-3.27"),
@SerializedName("flutter-3.29")
FLUTTER_3_29("flutter-3.29");
FLUTTER_3_29("flutter-3.29"),
@SerializedName("flutter-3.32")
FLUTTER_3_32("flutter-3.32");

override fun toString() = value
}
8 changes: 8 additions & 0 deletions src/main/kotlin/io/appwrite/models/AttributeString.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ data class AttributeString(
@SerializedName("default")
var default: String?,

/**
* Defines whether this attribute is encrypted or not.
*/
@SerializedName("encrypt")
var encrypt: Boolean?,

) {
fun toMap(): Map<String, Any> = mapOf(
"key" to key as Any,
Expand All @@ -79,6 +85,7 @@ data class AttributeString(
"\$updatedAt" to updatedAt as Any,
"size" to size as Any,
"default" to default as Any,
"encrypt" to encrypt as Any,
)

companion object {
Expand All @@ -97,6 +104,7 @@ data class AttributeString(
updatedAt = map["\$updatedAt"] as String,
size = (map["size"] as Number).toLong(),
default = map["default"] as? String?,
encrypt = map["encrypt"] as? Boolean?,
)
}
}
10 changes: 10 additions & 0 deletions src/main/kotlin/io/appwrite/models/Document.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ data class Document<T>(
@SerializedName("\$id")
val id: String,

/**
* Document automatically incrementing ID.
*/
@SerializedName("\$sequence")
val sequence: Long,

/**
* Collection ID.
*/
Expand Down Expand Up @@ -51,6 +57,7 @@ data class Document<T>(
) {
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"\$sequence" to sequence as Any,
"\$collectionId" to collectionId as Any,
"\$databaseId" to databaseId as Any,
"\$createdAt" to createdAt as Any,
Expand All @@ -62,6 +69,7 @@ data class Document<T>(
companion object {
operator fun invoke(
id: String,
sequence: Long,
collectionId: String,
databaseId: String,
createdAt: String,
Expand All @@ -70,6 +78,7 @@ data class Document<T>(
data: Map<String, Any>
) = Document<Map<String, Any>>(
id,
sequence,
collectionId,
databaseId,
createdAt,
Expand All @@ -84,6 +93,7 @@ data class Document<T>(
nestedType: Class<T>
) = Document<T>(
id = map["\$id"] as String,
sequence = (map["\$sequence"] as Number).toLong(),
collectionId = map["\$collectionId"] as String,
databaseId = map["\$databaseId"] as String,
createdAt = map["\$createdAt"] as String,
Expand Down
Loading