diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4d35e..8406e63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,8 @@ -# Change Log \ No newline at end of file +# Change Log + +## 8.0.0 + +* Add `token` param to `getFilePreview` and `getFileView` for File tokens usage +* Update default `quality` for `getFilePreview` from 0 to -1 +* Remove `Gif` from ImageFormat enum +* Remove `search` param from `listExecutions` method \ No newline at end of file diff --git a/README.md b/README.md index f00352f..1eee246 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:8.0.0") +implementation("io.appwrite:sdk-for-android:8.0.1") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 8.0.0 + 8.0.1 ``` diff --git a/docs/examples/java/databases/create-documents.md b/docs/examples/java/databases/create-documents.md new file mode 100644 index 0000000..dbdc64f --- /dev/null +++ b/docs/examples/java/databases/create-documents.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey(""); // + +Databases databases = new Databases(client); + +databases.createDocuments( + "", // databaseId + "", // collectionId + listOf(), // documents + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/kotlin/databases/create-documents.md b/docs/examples/kotlin/databases/create-documents.md new file mode 100644 index 0000000..33635b4 --- /dev/null +++ b/docs/examples/kotlin/databases/create-documents.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setKey("") // + +val databases = Databases(client) + +val result = databases.createDocuments( + databaseId = "", + collectionId = "", + documents = listOf(), +) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index 7905e40..6ea42ae 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "8.0.0", + "x-sdk-version" to "8.0.1", "x-appwrite-response-format" to "1.7.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index b6559a9..73384a1 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -146,6 +146,64 @@ class Databases(client: Client) : Service(client) { nestedType = classOf(), ) + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + nestedType: Class, + ): io.appwrite.models.DocumentList { + val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" + .replace("{databaseId}", databaseId) + .replace("{collectionId}", collectionId) + + val apiParams = mutableMapOf( + "documents" to documents, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.DocumentList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.DocumentList.from(map = it as Map, nestedType) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = classOf(), + converter, + ) + } + + /** + * Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + * + * @param databaseId Database ID. + * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). Make sure to define attributes before creating documents. + * @param documents Array of documents data as JSON objects. + * @return [io.appwrite.models.DocumentList] + */ + @Throws(AppwriteException::class) + suspend fun createDocuments( + databaseId: String, + collectionId: String, + documents: List, + ): io.appwrite.models.DocumentList> = createDocuments( + databaseId, + collectionId, + documents, + nestedType = classOf(), + ) + /** * Get a document by its unique ID. This endpoint response returns a JSON object with the document data. *