Skip to content

Commit aa5ebb5

Browse files
Merge pull request #24 from appwrite/dev
update to support 1.0.0-RC1
2 parents 3f72f75 + 962b8da commit aa5ebb5

37 files changed

+351
-340
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ jobs:
5151
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
5252
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}
5353
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
54-
SDK_VERSION: ${{ github.event.release.tag_name }}
54+
SDK_VERSION: ${{ github.event.release.tag_name }}

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Redistribution and use in source and binary forms, with or without modification,
99

1010
3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
1111

12-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-0.15.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
99

10-
**This SDK is compatible with Appwrite server version 0.15.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).**
10+
**This SDK is compatible with Appwrite server version 1.0.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).**
1111

1212
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Android SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1313

@@ -38,7 +38,7 @@ repositories {
3838
Next, add the dependency to your project's `build.gradle(.kts)` file:
3939

4040
```groovy
41-
implementation("io.appwrite:sdk-for-android:0.7.0")
41+
implementation("io.appwrite:sdk-for-android:1.0.0-SNAPSHOT")
4242
```
4343

4444
### Maven
@@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
4949
<dependency>
5050
<groupId>io.appwrite</groupId>
5151
<artifactId>sdk-for-android</artifactId>
52-
<version>0.7.0</version>
52+
<version>1.0.0-SNAPSHOT</version>
5353
</dependency>
5454
</dependencies>
5555
```

docs/examples/java/databases/create-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
1616
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1717
.setProject("5df5acd0d48c2"); // Your project ID
1818

19-
Databases databases = new Databases(client, "[DATABASE_ID]");
19+
Databases databases = new Databases(client);
2020

2121
databases.createDocument(
22+
"[DATABASE_ID]",
2223
"[COLLECTION_ID]",
2324
"[DOCUMENT_ID]",
2425
mapOf( "a" to "b" ),

docs/examples/java/databases/delete-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
1616
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1717
.setProject("5df5acd0d48c2"); // Your project ID
1818

19-
Databases databases = new Databases(client, "[DATABASE_ID]");
19+
Databases databases = new Databases(client);
2020

2121
databases.deleteDocument(
22+
"[DATABASE_ID]",
2223
"[COLLECTION_ID]",
2324
"[DOCUMENT_ID]"
2425
new Continuation<Object>() {

docs/examples/java/databases/get-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
1616
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1717
.setProject("5df5acd0d48c2"); // Your project ID
1818

19-
Databases databases = new Databases(client, "[DATABASE_ID]");
19+
Databases databases = new Databases(client);
2020

2121
databases.getDocument(
22+
"[DATABASE_ID]",
2223
"[COLLECTION_ID]",
2324
"[DOCUMENT_ID]"
2425
new Continuation<Object>() {

docs/examples/java/databases/list-documents.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
1616
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1717
.setProject("5df5acd0d48c2"); // Your project ID
1818

19-
Databases databases = new Databases(client, "[DATABASE_ID]");
19+
Databases databases = new Databases(client);
2020

2121
databases.listDocuments(
22+
"[DATABASE_ID]",
2223
"[COLLECTION_ID]",
2324
new Continuation<Object>() {
2425
@NotNull

docs/examples/java/databases/update-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ public class MainActivity extends AppCompatActivity {
1616
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1717
.setProject("5df5acd0d48c2"); // Your project ID
1818

19-
Databases databases = new Databases(client, "[DATABASE_ID]");
19+
Databases databases = new Databases(client);
2020

2121
databases.updateDocument(
22+
"[DATABASE_ID]",
2223
"[COLLECTION_ID]",
2324
"[DOCUMENT_ID]",
2425
new Continuation<Object>() {

docs/examples/java/storage/create-file.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import android.os.Bundle
33
import kotlinx.coroutines.GlobalScope
44
import kotlinx.coroutines.launch
55
import io.appwrite.Client
6+
import io.appwrite.models.InputFile
67
import io.appwrite.services.Storage
78

89
public class MainActivity extends AppCompatActivity {

docs/examples/kotlin/account/create-phone-session.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MainActivity : AppCompatActivity() {
1919
GlobalScope.launch {
2020
val response = account.createPhoneSession(
2121
userId = "[USER_ID]",
22-
number = ""
22+
phone = ""
2323
)
2424
val json = response.body?.string()
2525
}

docs/examples/kotlin/account/update-phone.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() {
1818

1919
GlobalScope.launch {
2020
val response = account.updatePhone(
21-
number = "",
21+
phone = "",
2222
password = "password"
2323
)
2424
val json = response.body?.string()

docs/examples/kotlin/databases/create-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
1414
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1515
.setProject("5df5acd0d48c2") // Your project ID
1616

17-
val databases = Databases(client, "[DATABASE_ID]")
17+
val databases = Databases(client)
1818

1919
GlobalScope.launch {
2020
val response = databases.createDocument(
21+
databaseId = "[DATABASE_ID]",
2122
collectionId = "[COLLECTION_ID]",
2223
documentId = "[DOCUMENT_ID]",
2324
data = mapOf( "a" to "b" ),

docs/examples/kotlin/databases/delete-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
1414
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1515
.setProject("5df5acd0d48c2") // Your project ID
1616

17-
val databases = Databases(client, "[DATABASE_ID]")
17+
val databases = Databases(client)
1818

1919
GlobalScope.launch {
2020
val response = databases.deleteDocument(
21+
databaseId = "[DATABASE_ID]",
2122
collectionId = "[COLLECTION_ID]",
2223
documentId = "[DOCUMENT_ID]"
2324
)

docs/examples/kotlin/databases/get-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
1414
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1515
.setProject("5df5acd0d48c2") // Your project ID
1616

17-
val databases = Databases(client, "[DATABASE_ID]")
17+
val databases = Databases(client)
1818

1919
GlobalScope.launch {
2020
val response = databases.getDocument(
21+
databaseId = "[DATABASE_ID]",
2122
collectionId = "[COLLECTION_ID]",
2223
documentId = "[DOCUMENT_ID]"
2324
)

docs/examples/kotlin/databases/list-documents.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
1414
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1515
.setProject("5df5acd0d48c2") // Your project ID
1616

17-
val databases = Databases(client, "[DATABASE_ID]")
17+
val databases = Databases(client)
1818

1919
GlobalScope.launch {
2020
val response = databases.listDocuments(
21+
databaseId = "[DATABASE_ID]",
2122
collectionId = "[COLLECTION_ID]",
2223
)
2324
val json = response.body?.string()

docs/examples/kotlin/databases/update-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class MainActivity : AppCompatActivity() {
1414
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
1515
.setProject("5df5acd0d48c2") // Your project ID
1616

17-
val databases = Databases(client, "[DATABASE_ID]")
17+
val databases = Databases(client)
1818

1919
GlobalScope.launch {
2020
val response = databases.updateDocument(
21+
databaseId = "[DATABASE_ID]",
2122
collectionId = "[COLLECTION_ID]",
2223
documentId = "[DOCUMENT_ID]",
2324
)

docs/examples/kotlin/storage/create-file.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import android.os.Bundle
33
import kotlinx.coroutines.GlobalScope
44
import kotlinx.coroutines.launch
55
import io.appwrite.Client
6+
import io.appwrite.models.InputFile
67
import io.appwrite.services.Storage
78

89
class MainActivity : AppCompatActivity() {

library/src/main/java/io/appwrite/Client.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import kotlin.coroutines.resume
4040

4141
class Client @JvmOverloads constructor(
4242
context: Context,
43-
var endPoint: String = "https://appwrite.io/v1",
43+
var endPoint: String = "https://HOSTNAME/v1",
4444
var endPointRealtime: String? = null,
4545
private var selfSigned: Boolean = false
4646
) : CoroutineScope {
@@ -85,8 +85,11 @@ class Client @JvmOverloads constructor(
8585
"content-type" to "application/json",
8686
"origin" to "appwrite-android://${context.packageName}",
8787
"user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}",
88-
"x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}",
89-
"x-appwrite-response-format" to "0.15.0"
88+
"x-sdk-name" to "Android",
89+
"x-sdk-platform" to "client",
90+
"x-sdk-language" to "android",
91+
"x-sdk-version" to "1.0.0-SNAPSHOT",
92+
"x-appwrite-response-format" to "1.0.0-RC1"
9093
)
9194
config = mutableMapOf()
9295

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.appwrite
2+
3+
class ID {
4+
companion object {
5+
fun custom(id: String): String
6+
= id
7+
fun unique(): String
8+
= "unique()"
9+
}
10+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.appwrite
2+
3+
class Permission {
4+
companion object {
5+
fun read(role: String): String {
6+
return "read(\"${role}\")"
7+
}
8+
fun write(role: String): String {
9+
return "write(\"${role}\")"
10+
}
11+
fun create(role: String): String {
12+
return "create(\"${role}\")"
13+
}
14+
fun update(role: String): String {
15+
return "update(\"${role}\")"
16+
}
17+
fun delete(role: String): String {
18+
return "delete(\"${role}\")"
19+
}
20+
}
21+
}

library/src/main/java/io/appwrite/Query.kt

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,32 @@ class Query {
66

77
fun notEqual(attribute: String, value: Any) = Query.addQuery(attribute, "notEqual", value)
88

9-
fun lesser(attribute: String, value: Any) = Query.addQuery(attribute, "lesser", value)
9+
fun lessThan(attribute: String, value: Any) = Query.addQuery(attribute, "lessThan", value)
1010

11-
fun lesserEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lesserEqual", value)
11+
fun lessThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "lessThanEqual", value)
1212

13-
fun greater(attribute: String, value: Any) = Query.addQuery(attribute, "greater", value)
13+
fun greaterThan(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThan", value)
1414

15-
fun greaterEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterEqual", value)
15+
fun greaterThanEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterThanEqual", value)
1616

1717
fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value)
1818

19-
private fun addQuery(attribute: String, oper: String, value: Any): String {
19+
fun orderAsc(attribute: String) = "orderAsc(\"${attribute}\")"
20+
21+
fun orderDesc(attribute: String) = "orderDesc(\"${attribute}\")"
22+
23+
fun cursorBefore(documentId: String) = "cursorBefore(\"${documentId}\")"
24+
25+
fun cursorAfter(documentId: String) = "cursorAfter(\"${documentId}\")"
26+
27+
fun limit(limit: Int) = "limit(${limit})"
28+
29+
fun offset(offset: Int) = "offset(${offset})"
30+
31+
private fun addQuery(attribute: String, method: String, value: Any): String {
2032
return when (value) {
21-
is List<*> -> "${attribute}.${oper}(${value.map{it -> parseValues(it!!)}.joinToString(",")})"
22-
else -> "${attribute}.${oper}(${Query.parseValues(value)})"
33+
is List<*> -> "${method}(\"${attribute}\", [${value.map{it -> parseValues(it!!)}.joinToString(",")}])"
34+
else -> "${method}(\"${attribute}\", [${Query.parseValues(value)}])"
2335
}
2436
}
2537
private fun parseValues(value: Any): String {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.appwrite
2+
3+
class Role {
4+
companion object {
5+
fun any(): String
6+
= "any"
7+
fun user(id: String): String
8+
= "user:$id"
9+
fun users(): String
10+
= "users"
11+
fun guests(): String
12+
= "guests"
13+
fun team(id: String, role: String = ""): String
14+
= if(role.isEmpty()) {
15+
"team:$id"
16+
} else {
17+
"team:$id/$role"
18+
}
19+
fun status(status: String): String
20+
= "status:$status"
21+
}
22+
}

0 commit comments

Comments
 (0)