feat: introduce 0.15.x support

This commit is contained in:
Torsten Dittmann
2022-06-28 13:33:17 +02:00
parent ce50b9442e
commit 3f72f7540d
42 changed files with 913 additions and 156 deletions
+4 -4
View File
@@ -2,12 +2,12 @@
![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square)
![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.14.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-0.15.0-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![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)
**This SDK is compatible with Appwrite server version 0.14.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-android/releases).**
**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).**
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)
@@ -38,7 +38,7 @@ repositories {
Next, add the dependency to your project's `build.gradle(.kts)` file:
```groovy
implementation("io.appwrite:sdk-for-android:0.6.1")
implementation("io.appwrite:sdk-for-android:0.7.0")
```
### Maven
@@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
<dependency>
<groupId>io.appwrite</groupId>
<artifactId>sdk-for-android</artifactId>
<version>0.6.1</version>
<version>0.7.0</version>
</dependency>
</dependencies>
```
@@ -18,7 +18,7 @@ public class MainActivity extends AppCompatActivity {
Account account = new Account(client);
account.createSession(
account.createEmailSession(
"email@example.com",
"password"
new Continuation<Object>() {
@@ -0,0 +1,49 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Client client = new Client(getApplicationContext())
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Account account = new Account(client);
account.createPhoneSession(
"[USER_ID]",
""
new Continuation<Object>() {
@NotNull
@Override
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
@Override
public void resumeWith(@NotNull Object o) {
String json = "";
try {
if (o instanceof Result.Failure) {
Result.Failure failure = (Result.Failure) o;
throw failure.exception;
} else {
Response response = (Response) o;
json = response.body().string();
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
}
}
@@ -0,0 +1,46 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Client client = new Client(getApplicationContext())
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Account account = new Account(client);
account.createPhoneVerification(new Continuation<Object>() {
@NotNull
@Override
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
@Override
public void resumeWith(@NotNull Object o) {
String json = "";
try {
if (o instanceof Result.Failure) {
Result.Failure failure = (Result.Failure) o;
throw failure.exception;
} else {
Response response = (Response) o;
json = response.body().string();
}
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
});
}
}
@@ -0,0 +1,49 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Client client = new Client(getApplicationContext())
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Account account = new Account(client);
account.updatePhoneSession(
"[USER_ID]",
"[SECRET]"
new Continuation<Object>() {
@NotNull
@Override
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
@Override
public void resumeWith(@NotNull Object o) {
String json = "";
try {
if (o instanceof Result.Failure) {
Result.Failure failure = (Result.Failure) o;
throw failure.exception;
} else {
Response response = (Response) o;
json = response.body().string();
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
}
}
@@ -0,0 +1,49 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Client client = new Client(getApplicationContext())
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Account account = new Account(client);
account.updatePhoneVerification(
"[USER_ID]",
"[SECRET]"
new Continuation<Object>() {
@NotNull
@Override
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
@Override
public void resumeWith(@NotNull Object o) {
String json = "";
try {
if (o instanceof Result.Failure) {
Result.Failure failure = (Result.Failure) o;
throw failure.exception;
} else {
Response response = (Response) o;
json = response.body().string();
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
}
}
@@ -0,0 +1,49 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Client client = new Client(getApplicationContext())
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Account account = new Account(client);
account.updatePhone(
"",
"password"
new Continuation<Object>() {
@NotNull
@Override
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
@Override
public void resumeWith(@NotNull Object o) {
String json = "";
try {
if (o instanceof Result.Failure) {
Result.Failure failure = (Result.Failure) o;
throw failure.exception;
} else {
Response response = (Response) o;
json = response.body().string();
}
} catch (Throwable th) {
Log.e("ERROR", th.toString());
}
}
}
);
}
}
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
public class MainActivity extends AppCompatActivity {
@@ -16,9 +16,9 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Database database = new Database(client);
Databases databases = new Databases(client, "[DATABASE_ID]");
database.createDocument(
databases.createDocument(
"[COLLECTION_ID]",
"[DOCUMENT_ID]",
mapOf( "a" to "b" ),
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
public class MainActivity extends AppCompatActivity {
@@ -16,9 +16,9 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Database database = new Database(client);
Databases databases = new Databases(client, "[DATABASE_ID]");
database.deleteDocument(
databases.deleteDocument(
"[COLLECTION_ID]",
"[DOCUMENT_ID]"
new Continuation<Object>() {
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
public class MainActivity extends AppCompatActivity {
@@ -16,9 +16,9 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Database database = new Database(client);
Databases databases = new Databases(client, "[DATABASE_ID]");
database.getDocument(
databases.getDocument(
"[COLLECTION_ID]",
"[DOCUMENT_ID]"
new Continuation<Object>() {
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
public class MainActivity extends AppCompatActivity {
@@ -16,9 +16,9 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Database database = new Database(client);
Databases databases = new Databases(client, "[DATABASE_ID]");
database.listDocuments(
databases.listDocuments(
"[COLLECTION_ID]",
new Continuation<Object>() {
@NotNull
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
public class MainActivity extends AppCompatActivity {
@@ -16,12 +16,11 @@ public class MainActivity extends AppCompatActivity {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2"); // Your project ID
Database database = new Database(client);
Databases databases = new Databases(client, "[DATABASE_ID]");
database.updateDocument(
databases.updateDocument(
"[COLLECTION_ID]",
"[DOCUMENT_ID]",
mapOf( "a" to "b" ),
new Continuation<Object>() {
@NotNull
@Override
+1 -1
View File
@@ -21,7 +21,7 @@ public class MainActivity extends AppCompatActivity {
storage.createFile(
"[BUCKET_ID]",
"[FILE_ID]",
File("file.png"),
InputFile.fromPath("file.png"),
new Continuation<Object>() {
@NotNull
@Override
@@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() {
val account = Account(client)
GlobalScope.launch {
val response = account.createSession(
val response = account.createEmailSession(
email = "email@example.com",
password = "password"
)
@@ -0,0 +1,27 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val client = Client(applicationContext)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val account = Account(client)
GlobalScope.launch {
val response = account.createPhoneSession(
userId = "[USER_ID]",
number = ""
)
val json = response.body?.string()
}
}
}
@@ -0,0 +1,24 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val client = Client(applicationContext)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val account = Account(client)
GlobalScope.launch {
val response = account.createPhoneVerification()
val json = response.body?.string()
}
}
}
@@ -0,0 +1,27 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val client = Client(applicationContext)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val account = Account(client)
GlobalScope.launch {
val response = account.updatePhoneSession(
userId = "[USER_ID]",
secret = "[SECRET]"
)
val json = response.body?.string()
}
}
}
@@ -0,0 +1,27 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val client = Client(applicationContext)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val account = Account(client)
GlobalScope.launch {
val response = account.updatePhoneVerification(
userId = "[USER_ID]",
secret = "[SECRET]"
)
val json = response.body?.string()
}
}
}
@@ -0,0 +1,27 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Account
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val client = Client(applicationContext)
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val account = Account(client)
GlobalScope.launch {
val response = account.updatePhone(
number = "",
password = "password"
)
val json = response.body?.string()
}
}
}
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -14,10 +14,10 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val database = Database(client)
val databases = Databases(client, "[DATABASE_ID]")
GlobalScope.launch {
val response = database.createDocument(
val response = databases.createDocument(
collectionId = "[COLLECTION_ID]",
documentId = "[DOCUMENT_ID]",
data = mapOf( "a" to "b" ),
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -14,10 +14,10 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val database = Database(client)
val databases = Databases(client, "[DATABASE_ID]")
GlobalScope.launch {
val response = database.deleteDocument(
val response = databases.deleteDocument(
collectionId = "[COLLECTION_ID]",
documentId = "[DOCUMENT_ID]"
)
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -14,10 +14,10 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val database = Database(client)
val databases = Databases(client, "[DATABASE_ID]")
GlobalScope.launch {
val response = database.getDocument(
val response = databases.getDocument(
collectionId = "[COLLECTION_ID]",
documentId = "[DOCUMENT_ID]"
)
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -14,10 +14,10 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val database = Database(client)
val databases = Databases(client, "[DATABASE_ID]")
GlobalScope.launch {
val response = database.listDocuments(
val response = databases.listDocuments(
collectionId = "[COLLECTION_ID]",
)
val json = response.body?.string()
@@ -3,7 +3,7 @@ import android.os.Bundle
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import io.appwrite.Client
import io.appwrite.services.Database
import io.appwrite.services.Databases
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
@@ -14,13 +14,12 @@ class MainActivity : AppCompatActivity() {
.setEndpoint("https://[HOSTNAME_OR_IP]/v1") // Your API Endpoint
.setProject("5df5acd0d48c2") // Your project ID
val database = Database(client)
val databases = Databases(client, "[DATABASE_ID]")
GlobalScope.launch {
val response = database.updateDocument(
val response = databases.updateDocument(
collectionId = "[COLLECTION_ID]",
documentId = "[DOCUMENT_ID]",
data = mapOf( "a" to "b" ),
)
val json = response.body?.string()
}
+1 -1
View File
@@ -20,7 +20,7 @@ class MainActivity : AppCompatActivity() {
val response = storage.createFile(
bucketId = "[BUCKET_ID]",
fileId = "[FILE_ID]",
file = File("file.png"),
file = InputFile.fromPath("file.png"),
)
val json = response.body?.string()
}
+41 -9
View File
@@ -9,6 +9,7 @@ import io.appwrite.cookies.stores.SharedPreferencesCookieStore
import io.appwrite.exceptions.AppwriteException
import io.appwrite.extensions.fromJson
import io.appwrite.json.PreciseNumberAdapter
import io.appwrite.models.InputFile
import io.appwrite.models.UploadProgress
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -85,7 +86,7 @@ class Client @JvmOverloads constructor(
"origin" to "appwrite-android://${context.packageName}",
"user-agent" to "${context.packageName}/${appVersion}, ${System.getProperty("http.agent")}",
"x-sdk-version" to "appwrite:android:${BuildConfig.SDK_VERSION}",
"x-appwrite-response-format" to "0.14.0"
"x-appwrite-response-format" to "0.15.0"
)
config = mutableMapOf()
@@ -342,14 +343,29 @@ class Client @JvmOverloads constructor(
idParamName: String? = null,
onProgress: ((UploadProgress) -> Unit)? = null,
): T {
val file = params[paramName] as File
val size = file.length()
var file: RandomAccessFile? = null
val input = params[paramName] as InputFile
val size: Long = when(input.sourceType) {
"path", "file" -> {
file = RandomAccessFile(input.path, "r")
file.length()
}
"bytes" -> {
(input.data as ByteArray).size.toLong()
}
else -> throw UnsupportedOperationException()
}
if (size < CHUNK_SIZE) {
val data = when(input.sourceType) {
"file", "path" -> File(input.path).asRequestBody()
"bytes" -> (input.data as ByteArray).toRequestBody(input.mimeType.toMediaType())
else -> throw UnsupportedOperationException()
}
params[paramName] = MultipartBody.Part.createFormData(
paramName,
file.name,
file.asRequestBody()
input.filename,
data
)
return call(
method = "POST",
@@ -361,7 +377,6 @@ class Client @JvmOverloads constructor(
)
}
val input = RandomAccessFile(file, "r")
val buffer = ByteArray(CHUNK_SIZE)
var offset = 0L
var result: Map<*, *>? = null
@@ -380,12 +395,29 @@ class Client @JvmOverloads constructor(
}
while (offset < size) {
input.seek(offset)
input.read(buffer)
when(input.sourceType) {
"file", "path" -> {
file!!.seek(offset)
file!!.read(buffer)
}
"bytes" -> {
val end = if (offset + CHUNK_SIZE < size) {
offset + CHUNK_SIZE
} else {
size - 1
}
(input.data as ByteArray).copyInto(
buffer,
startIndex = offset.toInt(),
endIndex = end.toInt()
)
}
else -> throw UnsupportedOperationException()
}
params[paramName] = MultipartBody.Part.createFormData(
paramName,
file.name,
input.filename,
buffer.toRequestBody()
)
@@ -20,6 +20,20 @@ data class Document(
@SerializedName("\$collection")
val collection: String,
/**
* Document creation date in Unix timestamp.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
/**
* Document update date in Unix timestamp.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
/**
* Document read permissions.
*
@@ -41,6 +55,8 @@ data class Document(
fun from(map: Map<String, Any>) = Document(
id = map["\$id"] as String,
collection = map["\$collection"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
read = map["\$read"] as List<Any>,
write = map["\$write"] as List<Any>,
data = map
@@ -50,6 +66,8 @@ data class Document(
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"\$collection" to collection as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"\$read" to read as Any,
"\$write" to write as Any,
"data" to data
@@ -13,6 +13,20 @@ data class Execution(
@SerializedName("\$id")
val id: String,
/**
* Execution creation date in Unix timestamp.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
/**
* Execution update date in Unix timestamp.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
/**
* Execution read permissions.
*
@@ -27,13 +41,6 @@ data class Execution(
@SerializedName("functionId")
val functionId: String,
/**
* The execution creation date in Unix timestamp.
*
*/
@SerializedName("dateCreated")
val dateCreated: Long,
/**
* The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.
*
@@ -80,9 +87,10 @@ data class Execution(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Execution(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
read = map["\$read"] as List<Any>,
functionId = map["functionId"] as String,
dateCreated = (map["dateCreated"] as Number).toLong(),
trigger = map["trigger"] as String,
status = map["status"] as String,
statusCode = (map["statusCode"] as Number).toLong(),
@@ -94,9 +102,10 @@ data class Execution(
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"\$read" to read as Any,
"functionId" to functionId as Any,
"dateCreated" to dateCreated as Any,
"trigger" to trigger as Any,
"status" to status as Any,
"statusCode" to statusCode as Any,
@@ -20,6 +20,20 @@ data class File(
@SerializedName("bucketId")
val bucketId: String,
/**
* File creation date in Unix timestamp.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
/**
* File update date in Unix timestamp.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
/**
* File read permissions.
*
@@ -41,13 +55,6 @@ data class File(
@SerializedName("name")
val name: String,
/**
* File creation date in Unix timestamp.
*
*/
@SerializedName("dateCreated")
val dateCreated: Long,
/**
* File MD5 signature.
*
@@ -88,10 +95,11 @@ data class File(
fun from(map: Map<String, Any>) = File(
id = map["\$id"] as String,
bucketId = map["bucketId"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
read = map["\$read"] as List<Any>,
write = map["\$write"] as List<Any>,
name = map["name"] as String,
dateCreated = (map["dateCreated"] as Number).toLong(),
signature = map["signature"] as String,
mimeType = map["mimeType"] as String,
sizeOriginal = (map["sizeOriginal"] as Number).toLong(),
@@ -103,10 +111,11 @@ data class File(
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"bucketId" to bucketId as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"\$read" to read as Any,
"\$write" to write as Any,
"name" to name as Any,
"dateCreated" to dateCreated as Any,
"signature" to signature as Any,
"mimeType" to mimeType as Any,
"sizeOriginal" to sizeOriginal as Any,
@@ -0,0 +1,37 @@
package io.appwrite.models
import java.io.File
import java.net.URLConnection
import java.nio.file.Files
import java.nio.file.Paths
class InputFile private constructor() {
lateinit var path: String
lateinit var filename: String
lateinit var mimeType: String
lateinit var sourceType: String
lateinit var data: Any
companion object {
fun fromFile(file: File) = InputFile().apply {
path = file.canonicalPath
filename = file.name
mimeType = Files.probeContentType(Paths.get(file.canonicalPath))
?: URLConnection.guessContentTypeFromName(filename)
?: ""
sourceType = "file"
}
fun fromPath(path: String): InputFile = fromFile(File(path)).apply {
sourceType = "path"
}
fun fromBytes(bytes: ByteArray, filename: String = "", mimeType: String = "") = InputFile().apply {
this.filename = filename
this.mimeType = mimeType
data = bytes
sourceType = "bytes"
}
}
}
@@ -13,6 +13,20 @@ data class Membership(
@SerializedName("\$id")
val id: String,
/**
* Membership creation date in Unix timestamp.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
/**
* Membership update date in Unix timestamp.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
/**
* User ID.
*
@@ -80,6 +94,8 @@ data class Membership(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Membership(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
userId = map["userId"] as String,
userName = map["userName"] as String,
userEmail = map["userEmail"] as String,
@@ -94,6 +110,8 @@ data class Membership(
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,
"userName" to userName as Any,
"userEmail" to userEmail as Any,
@@ -13,6 +13,13 @@ data class Session(
@SerializedName("\$id")
val id: String,
/**
* Session creation date in Unix timestamp.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
/**
* User ID.
*
@@ -178,6 +185,7 @@ data class Session(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Session(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
userId = map["userId"] as String,
expire = (map["expire"] as Number).toLong(),
provider = map["provider"] as String,
@@ -206,6 +214,7 @@ data class Session(
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"\$createdAt" to createdAt as Any,
"userId" to userId as Any,
"expire" to expire as Any,
"provider" to provider as Any,
@@ -13,6 +13,20 @@ data class Team(
@SerializedName("\$id")
val id: String,
/**
* Team creation date in Unix timestamp.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
/**
* Team update date in Unix timestamp.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
/**
* Team name.
*
@@ -20,13 +34,6 @@ data class Team(
@SerializedName("name")
val name: String,
/**
* Team creation date in Unix timestamp.
*
*/
@SerializedName("dateCreated")
val dateCreated: Long,
/**
* Total number of team members.
*
@@ -38,16 +45,18 @@ data class Team(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Team(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
name = map["name"] as String,
dateCreated = (map["dateCreated"] as Number).toLong(),
total = (map["total"] as Number).toLong()
)
}
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"name" to name as Any,
"dateCreated" to dateCreated as Any,
"total" to total as Any
)
}
@@ -13,6 +13,13 @@ data class Token(
@SerializedName("\$id")
val id: String,
/**
* Token creation date in Unix timestamp.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
/**
* User ID.
*
@@ -38,6 +45,7 @@ data class Token(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = Token(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
userId = map["userId"] as String,
secret = map["secret"] as String,
expire = (map["expire"] as Number).toLong()
@@ -46,6 +54,7 @@ data class Token(
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"\$createdAt" to createdAt as Any,
"userId" to userId as Any,
"secret" to secret as Any,
"expire" to expire as Any
@@ -13,6 +13,20 @@ data class User(
@SerializedName("\$id")
val id: String,
/**
* User creation date in Unix timestamp.
*
*/
@SerializedName("\$createdAt")
val createdAt: Long,
/**
* User update date in Unix timestamp.
*
*/
@SerializedName("\$updatedAt")
val updatedAt: Long,
/**
* User name.
*
@@ -48,6 +62,13 @@ data class User(
@SerializedName("email")
val email: String,
/**
* User phone number in E.164 format.
*
*/
@SerializedName("phone")
val phone: String,
/**
* Email verification status.
*
@@ -55,6 +76,13 @@ data class User(
@SerializedName("emailVerification")
val emailVerification: Boolean,
/**
* Phone verification status.
*
*/
@SerializedName("phoneVerification")
val phoneVerification: Boolean,
/**
* User preferences as a key-value object
*
@@ -66,24 +94,32 @@ data class User(
@Suppress("UNCHECKED_CAST")
fun from(map: Map<String, Any>) = User(
id = map["\$id"] as String,
createdAt = (map["\$createdAt"] as Number).toLong(),
updatedAt = (map["\$updatedAt"] as Number).toLong(),
name = map["name"] as String,
registration = (map["registration"] as Number).toLong(),
status = map["status"] as Boolean,
passwordUpdate = (map["passwordUpdate"] as Number).toLong(),
email = map["email"] as String,
phone = map["phone"] as String,
emailVerification = map["emailVerification"] as Boolean,
phoneVerification = map["phoneVerification"] as Boolean,
prefs = Preferences.from(map = map["prefs"] as Map<String, Any>)
)
}
fun toMap(): Map<String, Any> = mapOf(
"\$id" to id as Any,
"\$createdAt" to createdAt as Any,
"\$updatedAt" to updatedAt as Any,
"name" to name as Any,
"registration" to registration as Any,
"status" to status as Any,
"passwordUpdate" to passwordUpdate as Any,
"email" to email as Any,
"phone" to phone as Any,
"emailVerification" to emailVerification as Any,
"phoneVerification" to phoneVerification as Any,
"prefs" to prefs.toMap() as Any
)
}
@@ -12,7 +12,9 @@ import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import java.io.File
class Account(client: Client) : Service(client) {
class Account : Service {
public constructor (client: Client) : super(client) { }
/**
* Get Account
@@ -274,6 +276,45 @@ class Account(client: Client) : Service(client) {
)
}
/**
* Update Account Phone
*
* Update currently logged in user account phone number. After changing phone
* number, the user confirmation status will get reset. A new confirmation SMS
* is not sent automatically however you can use the phone confirmation
* endpoint again to send the confirmation SMS.
*
* @param number Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
* @param password User password. Must be at least 8 chars.
* @return [io.appwrite.models.User]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updatePhone(
number: String,
password: String
): io.appwrite.models.User {
val path = "/account/phone"
val params = mutableMapOf<String, Any?>(
"number" to number,
"password" to password
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
io.appwrite.models.User.from(map = it)
}
return client.call(
"PATCH",
path,
headers,
params,
responseType = io.appwrite.models.User::class.java,
converter,
)
}
/**
* Get Account Preferences
*
@@ -461,43 +502,6 @@ class Account(client: Client) : Service(client) {
)
}
/**
* Create Account Session
*
* Allow the user to login into their account by providing a valid email and
* password combination. This route will create a new session for the user.
*
* @param email User email.
* @param password User password. Must be at least 8 chars.
* @return [io.appwrite.models.Session]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun createSession(
email: String,
password: String
): io.appwrite.models.Session {
val path = "/account/sessions"
val params = mutableMapOf<String, Any?>(
"email" to email,
"password" to password
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.Session = {
io.appwrite.models.Session.from(map = it)
}
return client.call(
"POST",
path,
headers,
params,
responseType = io.appwrite.models.Session::class.java,
converter,
)
}
/**
* Delete All Account Sessions
*
@@ -558,6 +562,43 @@ class Account(client: Client) : Service(client) {
)
}
/**
* Create Account Session with Email
*
* Allow the user to login into their account by providing a valid email and
* password combination. This route will create a new session for the user.
*
* @param email User email.
* @param password User password. Must be at least 8 chars.
* @return [io.appwrite.models.Session]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun createEmailSession(
email: String,
password: String
): io.appwrite.models.Session {
val path = "/account/sessions/email"
val params = mutableMapOf<String, Any?>(
"email" to email,
"password" to password
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.Session = {
io.appwrite.models.Session.from(map = it)
}
return client.call(
"POST",
path,
headers,
params,
responseType = io.appwrite.models.Session::class.java,
converter,
)
}
/**
* Create Magic URL session
*
@@ -668,10 +709,10 @@ class Account(client: Client) : Service(client) {
* user..
*
*
* @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, zoom, yahoo, yammer, yandex, wordpress, stripe.
* @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, dailymotion, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoom.
* @param success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
* @param scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 128 characters long.
* @param scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
*
*/
@JvmOverloads
@@ -734,6 +775,92 @@ class Account(client: Client) : Service(client) {
}
}
/**
* Create Phone session
*
* Sends the user a SMS with a secret key for creating a session. Use the
* returned user ID and the secret to submit a request to the [PUT
* /account/sessions/phone](/docs/client/account#accountUpdatePhoneSession)
* endpoint to complete the login process. The secret sent to the user's phone
* is valid for 15 minutes.
*
* @param userId Unique Id. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
* @param number Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
* @return [io.appwrite.models.Token]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun createPhoneSession(
userId: String,
number: String
): io.appwrite.models.Token {
val path = "/account/sessions/phone"
val params = mutableMapOf<String, Any?>(
"userId" to userId,
"number" to number
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.Token = {
io.appwrite.models.Token.from(map = it)
}
return client.call(
"POST",
path,
headers,
params,
responseType = io.appwrite.models.Token::class.java,
converter,
)
}
/**
* Create Phone session (confirmation)
*
* Use this endpoint to complete creating the session with the Magic URL. Both
* the **userId** and **secret** arguments will be passed as query parameters
* to the redirect URL you have provided when sending your request to the
* [POST
* /account/sessions/magic-url](/docs/client/account#accountCreateMagicURLSession)
* endpoint.
*
* Please note that in order to avoid a [Redirect
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
* the only valid redirect URLs are the ones from domains you have set when
* adding your platforms in the console interface.
*
* @param userId User ID.
* @param secret Valid verification token.
* @return [io.appwrite.models.Session]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updatePhoneSession(
userId: String,
secret: String
): io.appwrite.models.Session {
val path = "/account/sessions/phone"
val params = mutableMapOf<String, Any?>(
"userId" to userId,
"secret" to secret
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.Session = {
io.appwrite.models.Session.from(map = it)
}
return client.call(
"PUT",
path,
headers,
params,
responseType = io.appwrite.models.Session::class.java,
converter,
)
}
/**
* Get Session By ID
*
@@ -873,8 +1000,8 @@ class Account(client: Client) : Service(client) {
* should redirect the user back to your app and allow you to complete the
* verification process by verifying both the **userId** and **secret**
* parameters. Learn more about how to [complete the verification
* process](/docs/client/account#accountUpdateVerification). The verification
* link sent to the user's email address is valid for 7 days.
* process](/docs/client/account#accountUpdateEmailVerification). The
* verification link sent to the user's email address is valid for 7 days.
*
* Please note that in order to avoid a [Redirect
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
@@ -949,4 +1076,78 @@ class Account(client: Client) : Service(client) {
)
}
/**
* Create Phone Verification
*
* Use this endpoint to send a verification message to your user's phone
* number to confirm they are the valid owners of that address. The provided
* secret should allow you to complete the verification process by verifying
* both the **userId** and **secret** parameters. Learn more about how to
* [complete the verification
* process](/docs/client/account#accountUpdatePhoneVerification). The
* verification link sent to the user's phone number is valid for 15 minutes.
*
* @return [io.appwrite.models.Token]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun createPhoneVerification(): io.appwrite.models.Token {
val path = "/account/verification/phone"
val params = mutableMapOf<String, Any?>(
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.Token = {
io.appwrite.models.Token.from(map = it)
}
return client.call(
"POST",
path,
headers,
params,
responseType = io.appwrite.models.Token::class.java,
converter,
)
}
/**
* Create Phone Verification (confirmation)
*
* Use this endpoint to complete the user phone verification process. Use the
* **userId** and **secret** that were sent to your user's phone number to
* verify the user email ownership. If confirmed this route will return a 200
* status code.
*
* @param userId User ID.
* @param secret Valid verification token.
* @return [io.appwrite.models.Token]
*/
@JvmOverloads
@Throws(AppwriteException::class)
suspend fun updatePhoneVerification(
userId: String,
secret: String
): io.appwrite.models.Token {
val path = "/account/verification/phone"
val params = mutableMapOf<String, Any?>(
"userId" to userId,
"secret" to secret
)
val headers = mutableMapOf(
"content-type" to "application/json"
)
val converter: (Map<String, Any>) -> io.appwrite.models.Token = {
io.appwrite.models.Token.from(map = it)
}
return client.call(
"PUT",
path,
headers,
params,
responseType = io.appwrite.models.Token::class.java,
converter,
)
}
}
@@ -10,7 +10,9 @@ import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import java.io.File
class Avatars(client: Client) : Service(client) {
class Avatars : Service {
public constructor (client: Client) : super(client) { }
/**
* Get Browser Icon
@@ -8,23 +8,24 @@ import okhttp3.Cookie
import okhttp3.Response
import java.io.File
class Database(client: Client) : Service(client) {
class Databases : Service {
val databaseId: String
public constructor(client: Client, databaseId: String) : super(client) {
this.databaseId = databaseId
}
/**
* List Documents
*
* Get a list of all the user documents. You can use the query params to
* filter your results. On admin mode, this endpoint will return a list of all
* of the project's documents. [Learn more about different API
* modes](/docs/admin).
*
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 128 characters long.
* @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long.
* @param limit Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursor ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor.
* @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 128 characters long.
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 4096 characters long.
* @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed.
* @return [io.appwrite.models.DocumentList]
*/
@@ -40,7 +41,7 @@ class Database(client: Client) : Service(client) {
orderAttributes: List<Any>? = null,
orderTypes: List<Any>? = null
): io.appwrite.models.DocumentList {
val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId)
val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId)
val params = mutableMapOf<String, Any?>(
"queries" to queries,
"limit" to limit,
@@ -69,11 +70,6 @@ class Database(client: Client) : Service(client) {
/**
* Create Document
*
* Create a new Document. Before using this route, you should create a new
* collection resource using either a [server
* integration](/docs/server/database#databaseCreateCollection) API or
* directly from your database console.
*
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection). Make sure to define attributes before creating documents.
* @param documentId Document ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
* @param data Document data as JSON object.
@@ -90,7 +86,7 @@ class Database(client: Client) : Service(client) {
read: List<Any>? = null,
write: List<Any>? = null
): io.appwrite.models.Document {
val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId)
val path = "/databases/{databaseId}/collections/{collectionId}/documents".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId)
val params = mutableMapOf<String, Any?>(
"documentId" to documentId,
"data" to data,
@@ -116,9 +112,6 @@ class Database(client: Client) : Service(client) {
/**
* Get Document
*
* Get a document by its unique ID. This endpoint response returns a JSON
* object with the document data.
*
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
* @param documentId Document ID.
* @return [io.appwrite.models.Document]
@@ -129,7 +122,7 @@ class Database(client: Client) : Service(client) {
collectionId: String,
documentId: String
): io.appwrite.models.Document {
val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId)
val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId)
val params = mutableMapOf<String, Any?>(
)
val headers = mutableMapOf(
@@ -151,9 +144,6 @@ class Database(client: Client) : Service(client) {
/**
* Update Document
*
* Update a document by its unique ID. Using the patch method you can pass
* only specific fields that will get updated.
*
* @param collectionId Collection ID.
* @param documentId Document ID.
* @param data Document data as JSON object. Include only attribute and value pairs to be updated.
@@ -166,11 +156,11 @@ class Database(client: Client) : Service(client) {
suspend fun updateDocument(
collectionId: String,
documentId: String,
data: Any,
data: Any? = null,
read: List<Any>? = null,
write: List<Any>? = null
): io.appwrite.models.Document {
val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId)
val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId)
val params = mutableMapOf<String, Any?>(
"data" to data,
"read" to read,
@@ -195,8 +185,6 @@ class Database(client: Client) : Service(client) {
/**
* Delete Document
*
* Delete a document by its unique ID.
*
* @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).
* @param documentId Document ID.
* @return [Any]
@@ -207,7 +195,7 @@ class Database(client: Client) : Service(client) {
collectionId: String,
documentId: String
): Any {
val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId)
val path = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}".replace("{databaseId}", databaseId).replace("{collectionId}", collectionId).replace("{documentId}", documentId)
val params = mutableMapOf<String, Any?>(
)
val headers = mutableMapOf(
@@ -8,7 +8,9 @@ import okhttp3.Cookie
import okhttp3.Response
import java.io.File
class Functions(client: Client) : Service(client) {
class Functions : Service {
public constructor (client: Client) : super(client) { }
/**
* Retry Build
@@ -53,7 +55,7 @@ class Functions(client: Client) : Service(client) {
* @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param search Search term to filter your list results. Max length: 256 chars.
* @param cursor ID of the execution used as the starting point for the query, excluding the execution itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor.
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @return [io.appwrite.models.ExecutionList]
*/
@JvmOverloads
@@ -8,7 +8,9 @@ import okhttp3.Cookie
import okhttp3.Response
import java.io.File
class Locale(client: Client) : Service(client) {
class Locale : Service {
public constructor (client: Client) : super(client) { }
/**
* Get User Locale
@@ -10,7 +10,9 @@ import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrl
import java.io.File
class Storage(client: Client) : Service(client) {
class Storage : Service {
public constructor (client: Client) : super(client) { }
/**
* List Files
@@ -24,7 +26,7 @@ class Storage(client: Client) : Service(client) {
* @param limit Maximum number of files to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursor ID of the file used as the starting point for the query, excluding the file itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor.
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @param orderType Order result by ASC or DESC order.
* @return [io.appwrite.models.FileList]
*/
@@ -98,7 +100,7 @@ class Storage(client: Client) : Service(client) {
suspend fun createFile(
bucketId: String,
fileId: String,
file: File,
file: InputFile,
read: List<Any>? = null,
write: List<Any>? = null, onProgress: ((UploadProgress) -> Unit)? = null
): io.appwrite.models.File {
@@ -8,7 +8,9 @@ import okhttp3.Cookie
import okhttp3.Response
import java.io.File
class Teams(client: Client) : Service(client) {
class Teams : Service {
public constructor (client: Client) : super(client) { }
/**
* List Teams
@@ -23,7 +25,7 @@ class Teams(client: Client) : Service(client) {
* @param limit Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor.
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @param orderType Order result by ASC or DESC order.
* @return [io.appwrite.models.TeamList]
*/
@@ -211,7 +213,7 @@ class Teams(client: Client) : Service(client) {
* @param limit Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
* @param offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
* @param cursorDirection Direction of the cursor.
* @param cursorDirection Direction of the cursor, can be either &#039;before&#039; or &#039;after&#039;.
* @param orderType Order result by ASC or DESC order.
* @return [io.appwrite.models.MembershipList]
*/