mirror of
https://github.com/appwrite/sdk-for-android.git
synced 2026-04-07 19:17:49 +00:00
feat: update for appwrite 0.14.x
This commit is contained in:
@@ -28,7 +28,7 @@ jobs:
|
||||
|
||||
# Builds the release artifacts of the library
|
||||
- name: Build Release Artifacts
|
||||
run: ./gradlew --info library:assembleRelease
|
||||
run: ./gradlew library:assembleRelease
|
||||
|
||||
# Generates other artifacts (javadocJar is optional)
|
||||
- name: Generate Source jar
|
||||
@@ -39,10 +39,10 @@ jobs:
|
||||
run: |
|
||||
if ${{ endswith(github.event.release.tag_name, '-SNAPSHOT') }}; then
|
||||
echo "Publising Snapshot Version ${{ github.event.release.tag_name}} to Snapshot repository"
|
||||
./gradlew publishReleasePublicationToSonatypeRepository
|
||||
./gradlew publishToSonatype
|
||||
else
|
||||
echo "Publising Release Version ${{ github.event.release.tag_name}} to Staging repository"
|
||||
./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
|
||||
./gradlew publishToSonatype --max-workers 1 closeAndReleaseSonatypeStagingRepository
|
||||
fi
|
||||
env:
|
||||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2021 Appwrite (https://appwrite.io) and individual contributors.
|
||||
Copyright (c) 2022 Appwrite (https://appwrite.io) and individual contributors.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
[](https://travis-ci.com/appwrite/sdk-generator)
|
||||
[](https://twitter.com/appwrite_io)
|
||||
[](https://twitter.com/appwrite)
|
||||
[](https://appwrite.io/discord)
|
||||
|
||||
**This SDK is compatible with Appwrite server version 0.11.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.14.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,11 +38,7 @@ repositories {
|
||||
Next, add the dependency to your project's `build.gradle(.kts)` file:
|
||||
|
||||
```groovy
|
||||
<<<<<<< HEAD
|
||||
implementation("io.appwrite:sdk-for-android:0.3.0-SNAPSHOT")
|
||||
=======
|
||||
implementation("io.appwrite:sdk-for-android:0.2.1")
|
||||
>>>>>>> de10694090d63c4d6b8d39a3f651f5b6cc21d0c0
|
||||
implementation("io.appwrite:sdk-for-android:0.6.0")
|
||||
```
|
||||
|
||||
### Maven
|
||||
@@ -53,11 +49,7 @@ Add this to your project's `pom.xml` file:
|
||||
<dependency>
|
||||
<groupId>io.appwrite</groupId>
|
||||
<artifactId>sdk-for-android</artifactId>
|
||||
<<<<<<< HEAD
|
||||
<version>0.3.0-SNAPSHOT</version>
|
||||
=======
|
||||
<version>0.2.1</version>
|
||||
>>>>>>> de10694090d63c4d6b8d39a3f651f5b6cc21d0c0
|
||||
<version>0.6.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
@@ -116,6 +108,7 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos
|
||||
// Register User
|
||||
val account = Account(client)
|
||||
val response = account.create(
|
||||
"[USER_ID]",
|
||||
"email@example.com",
|
||||
"password"
|
||||
)
|
||||
@@ -134,6 +127,7 @@ val client = Client(context)
|
||||
|
||||
val account = Account(client)
|
||||
val response = account.create(
|
||||
"[USER_ID]",
|
||||
"email@example.com",
|
||||
"password"
|
||||
)
|
||||
@@ -144,7 +138,7 @@ The Appwrite Android SDK raises an `AppwriteException` object with `message`, `c
|
||||
|
||||
```kotlin
|
||||
try {
|
||||
var response = account.create("email@example.com", "password")
|
||||
var response = account.create("[USER_ID]", "email@example.com", "password")
|
||||
Log.d("Appwrite response", response.body?.string())
|
||||
} catch(e : AppwriteException) {
|
||||
Log.e("AppwriteException",e.message.toString())
|
||||
|
||||
+3
-3
@@ -2,15 +2,15 @@ apply plugin: 'io.github.gradle-nexus.publish-plugin'
|
||||
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.4.31"
|
||||
version '0.2.1'
|
||||
ext.kotlin_version = "1.5.31"
|
||||
version System.getenv("SDK_VERSION")
|
||||
repositories {
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:7.0.3"
|
||||
classpath "com.android.tools.build:gradle:4.2.0"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Account account = new Account(client);
|
||||
|
||||
account.createMagicURLSession(
|
||||
"",
|
||||
"[USER_ID]",
|
||||
"email@example.com",
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
|
||||
@@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Account account = new Account(client);
|
||||
|
||||
account.create(
|
||||
"",
|
||||
"[USER_ID]",
|
||||
"email@example.com",
|
||||
"password",
|
||||
new Continuation<Object>() {
|
||||
|
||||
@@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Account account = new Account(client);
|
||||
|
||||
account.updateMagicURLSession(
|
||||
"",
|
||||
"[USER_ID]",
|
||||
"[SECRET]"
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
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.updateSession(
|
||||
"[SESSION_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());
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
Account account = new Account(client);
|
||||
|
||||
account.delete(new Continuation<Object>() {
|
||||
account.updateStatus(new Continuation<Object>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public CoroutineContext getContext() {
|
||||
@@ -20,7 +20,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
database.createDocument(
|
||||
"[COLLECTION_ID]",
|
||||
"",
|
||||
"[DOCUMENT_ID]",
|
||||
mapOf( "a" to "b" ),
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
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.Functions
|
||||
|
||||
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
|
||||
|
||||
Functions functions = new Functions(client);
|
||||
|
||||
functions.retryBuild(
|
||||
"[FUNCTION_ID]",
|
||||
"[DEPLOYMENT_ID]",
|
||||
"[BUILD_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());
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
Storage storage = new Storage(client);
|
||||
|
||||
storage.createFile(
|
||||
"",
|
||||
File("./path-to-files/image.jpg"),
|
||||
"[BUCKET_ID]",
|
||||
"[FILE_ID]",
|
||||
File("file.png"),
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Storage storage = new Storage(client);
|
||||
|
||||
storage.deleteFile(
|
||||
"[BUCKET_ID]",
|
||||
"[FILE_ID]"
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
|
||||
@@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Storage storage = new Storage(client);
|
||||
|
||||
storage.getFileDownload(
|
||||
"[BUCKET_ID]",
|
||||
"[FILE_ID]"
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
|
||||
@@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Storage storage = new Storage(client);
|
||||
|
||||
storage.getFilePreview(
|
||||
"[BUCKET_ID]",
|
||||
"[FILE_ID]",
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
|
||||
@@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Storage storage = new Storage(client);
|
||||
|
||||
storage.getFileView(
|
||||
"[BUCKET_ID]",
|
||||
"[FILE_ID]"
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
|
||||
@@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Storage storage = new Storage(client);
|
||||
|
||||
storage.getFile(
|
||||
"[BUCKET_ID]",
|
||||
"[FILE_ID]"
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
|
||||
@@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Storage storage = new Storage(client);
|
||||
|
||||
storage.listFiles(
|
||||
"[BUCKET_ID]",
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -19,9 +19,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
Storage storage = new Storage(client);
|
||||
|
||||
storage.updateFile(
|
||||
"[BUCKET_ID]",
|
||||
"[FILE_ID]",
|
||||
listOf(),
|
||||
listOf()
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Teams teams = new Teams(client);
|
||||
|
||||
teams.create(
|
||||
"",
|
||||
"[TEAM_ID]",
|
||||
"[NAME]",
|
||||
new Continuation<Object>() {
|
||||
@NotNull
|
||||
|
||||
@@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = account.createMagicURLSession(
|
||||
userId = "",
|
||||
userId = "[USER_ID]",
|
||||
email = "email@example.com",
|
||||
)
|
||||
val json = response.body?.string()
|
||||
|
||||
@@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = account.create(
|
||||
userId = "",
|
||||
userId = "[USER_ID]",
|
||||
email = "email@example.com",
|
||||
password = "password",
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = account.updateMagicURLSession(
|
||||
userId = "",
|
||||
userId = "[USER_ID]",
|
||||
secret = "[SECRET]"
|
||||
)
|
||||
val json = response.body?.string()
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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.updateSession(
|
||||
sessionId = "[SESSION_ID]"
|
||||
)
|
||||
val json = response.body?.string()
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val account = Account(client)
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = account.delete()
|
||||
val response = account.updateStatus()
|
||||
val json = response.body?.string()
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class MainActivity : AppCompatActivity() {
|
||||
GlobalScope.launch {
|
||||
val response = database.createDocument(
|
||||
collectionId = "[COLLECTION_ID]",
|
||||
documentId = "",
|
||||
documentId = "[DOCUMENT_ID]",
|
||||
data = mapOf( "a" to "b" ),
|
||||
)
|
||||
val json = response.body?.string()
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
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.Functions
|
||||
|
||||
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 functions = Functions(client)
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = functions.retryBuild(
|
||||
functionId = "[FUNCTION_ID]",
|
||||
deploymentId = "[DEPLOYMENT_ID]",
|
||||
buildId = "[BUILD_ID]"
|
||||
)
|
||||
val json = response.body?.string()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,9 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = storage.createFile(
|
||||
fileId = "",
|
||||
file = File("./path-to-files/image.jpg"),
|
||||
bucketId = "[BUCKET_ID]",
|
||||
fileId = "[FILE_ID]",
|
||||
file = File("file.png"),
|
||||
)
|
||||
val json = response.body?.string()
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = storage.deleteFile(
|
||||
bucketId = "[BUCKET_ID]",
|
||||
fileId = "[FILE_ID]"
|
||||
)
|
||||
val json = response.body?.string()
|
||||
|
||||
@@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val result = storage.getFileDownload(
|
||||
bucketId = "[BUCKET_ID]",
|
||||
fileId = "[FILE_ID]"
|
||||
)
|
||||
println(result); // Resource URL
|
||||
|
||||
@@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val result = storage.getFilePreview(
|
||||
bucketId = "[BUCKET_ID]",
|
||||
fileId = "[FILE_ID]",
|
||||
)
|
||||
println(result); // Resource URL
|
||||
|
||||
@@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val result = storage.getFileView(
|
||||
bucketId = "[BUCKET_ID]",
|
||||
fileId = "[FILE_ID]"
|
||||
)
|
||||
println(result); // Resource URL
|
||||
|
||||
@@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = storage.getFile(
|
||||
bucketId = "[BUCKET_ID]",
|
||||
fileId = "[FILE_ID]"
|
||||
)
|
||||
val json = response.body?.string()
|
||||
|
||||
@@ -18,6 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = storage.listFiles(
|
||||
bucketId = "[BUCKET_ID]",
|
||||
)
|
||||
val json = response.body?.string()
|
||||
}
|
||||
|
||||
@@ -18,9 +18,8 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = storage.updateFile(
|
||||
bucketId = "[BUCKET_ID]",
|
||||
fileId = "[FILE_ID]",
|
||||
read = listOf(),
|
||||
write = listOf()
|
||||
)
|
||||
val json = response.body?.string()
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
GlobalScope.launch {
|
||||
val response = teams.create(
|
||||
teamId = "",
|
||||
teamId = "[TEAM_ID]",
|
||||
name = "[NAME]",
|
||||
)
|
||||
val json = response.body?.string()
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#Tue Jun 01 15:55:54 IST 2021
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -19,6 +19,8 @@ ext {
|
||||
GITHUB_SCM_CONNECTION = 'scm:git:git://github.com/appwrite/sdk-for-android.git'
|
||||
}
|
||||
|
||||
version PUBLISH_VERSION
|
||||
|
||||
android {
|
||||
compileSdkVersion(31)
|
||||
|
||||
@@ -61,7 +63,6 @@ dependencies {
|
||||
implementation("com.squareup.okhttp3:logging-interceptor")
|
||||
implementation("com.google.code.gson:gson:2.8.7")
|
||||
|
||||
implementation("net.gotev:cookie-store:1.3.5")
|
||||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
|
||||
implementation("androidx.lifecycle:lifecycle-common-java8:2.3.1")
|
||||
implementation("androidx.appcompat:appcompat:1.3.1")
|
||||
|
||||
@@ -5,14 +5,15 @@ import android.content.pm.PackageManager
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import io.appwrite.appwrite.BuildConfig
|
||||
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.UploadProgress
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import net.gotev.cookiestore.SharedPreferencesCookieStore
|
||||
import okhttp3.*
|
||||
import okhttp3.Headers.Companion.toHeaders
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
@@ -22,6 +23,7 @@ import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.RandomAccessFile
|
||||
import java.io.IOException
|
||||
import java.net.CookieManager
|
||||
import java.net.CookiePolicy
|
||||
@@ -42,6 +44,10 @@ class Client @JvmOverloads constructor(
|
||||
private var selfSigned: Boolean = false
|
||||
) : CoroutineScope {
|
||||
|
||||
companion object {
|
||||
const val CHUNK_SIZE = 5*1024*1024; // 5MB
|
||||
}
|
||||
|
||||
override val coroutineContext: CoroutineContext
|
||||
get() = Dispatchers.Main + job
|
||||
|
||||
@@ -79,7 +85,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.11.0"
|
||||
"x-appwrite-response-format" to "0.14.0"
|
||||
)
|
||||
config = mutableMapOf()
|
||||
|
||||
@@ -231,7 +237,7 @@ class Client @JvmOverloads constructor(
|
||||
* @param headers
|
||||
* @param params
|
||||
*
|
||||
* @return [Response]
|
||||
* @return [T]
|
||||
*/
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun <T> call(
|
||||
@@ -240,7 +246,7 @@ class Client @JvmOverloads constructor(
|
||||
headers: Map<String, String> = mapOf(),
|
||||
params: Map<String, Any?> = mapOf(),
|
||||
responseType: Class<T>,
|
||||
convert: ((Map<String, Any,>) -> T)? = null
|
||||
converter: ((Map<String, Any,>) -> T)? = null
|
||||
): T {
|
||||
val filteredParams = params.filterValues { it != null }
|
||||
|
||||
@@ -276,7 +282,7 @@ class Client @JvmOverloads constructor(
|
||||
.get()
|
||||
.build()
|
||||
|
||||
return awaitResponse(request, responseType, convert)
|
||||
return awaitResponse(request, responseType, converter)
|
||||
}
|
||||
|
||||
val body = if (MultipartBody.FORM.toString() == headers["content-type"]) {
|
||||
@@ -285,8 +291,7 @@ class Client @JvmOverloads constructor(
|
||||
filteredParams.forEach {
|
||||
when {
|
||||
it.key == "file" -> {
|
||||
val file = it.value as File
|
||||
builder.addFormDataPart(it.key, file.name, file.asRequestBody())
|
||||
builder.addPart(it.value as MultipartBody.Part)
|
||||
}
|
||||
it.value is List<*> -> {
|
||||
val list = it.value as List<*>
|
||||
@@ -314,7 +319,101 @@ class Client @JvmOverloads constructor(
|
||||
.method(method, body)
|
||||
.build()
|
||||
|
||||
return awaitResponse(request, responseType, convert)
|
||||
return awaitResponse(request, responseType, converter)
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a file in chunks
|
||||
*
|
||||
* @param path
|
||||
* @param headers
|
||||
* @param params
|
||||
*
|
||||
* @return [T]
|
||||
*/
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun <T> chunkedUpload(
|
||||
path: String,
|
||||
headers: MutableMap<String, String>,
|
||||
params: MutableMap<String, Any?>,
|
||||
responseType: Class<T>,
|
||||
converter: ((Map<String, Any,>) -> T),
|
||||
paramName: String,
|
||||
idParamName: String? = null,
|
||||
onProgress: ((UploadProgress) -> Unit)? = null,
|
||||
): T {
|
||||
val file = params[paramName] as File
|
||||
val size = file.length()
|
||||
|
||||
if (size < CHUNK_SIZE) {
|
||||
params[paramName] = MultipartBody.Part.createFormData(
|
||||
paramName,
|
||||
file.name,
|
||||
file.asRequestBody()
|
||||
)
|
||||
return call(
|
||||
method = "POST",
|
||||
path,
|
||||
headers,
|
||||
params,
|
||||
responseType,
|
||||
converter
|
||||
)
|
||||
}
|
||||
|
||||
val input = RandomAccessFile(file, "r")
|
||||
val buffer = ByteArray(CHUNK_SIZE)
|
||||
var offset = 0L
|
||||
var result: Map<*, *>? = null
|
||||
|
||||
if (idParamName?.isNotEmpty() == true && params[idParamName] != "unique()") {
|
||||
// Make a request to check if a file already exists
|
||||
val current = call(
|
||||
method = "GET",
|
||||
path = "$path/${params[idParamName]}",
|
||||
headers = headers,
|
||||
params = emptyMap(),
|
||||
responseType = Map::class.java,
|
||||
)
|
||||
val chunksUploaded = current["chunksUploaded"] as Long
|
||||
offset = (chunksUploaded * CHUNK_SIZE).coerceAtMost(size)
|
||||
}
|
||||
|
||||
while (offset < size) {
|
||||
input.seek(offset)
|
||||
input.read(buffer)
|
||||
|
||||
params[paramName] = MultipartBody.Part.createFormData(
|
||||
paramName,
|
||||
file.name,
|
||||
buffer.toRequestBody()
|
||||
)
|
||||
|
||||
headers["Content-Range"] =
|
||||
"bytes $offset-${((offset + CHUNK_SIZE) - 1).coerceAtMost(size)}/$size"
|
||||
|
||||
result = call(
|
||||
method = "POST",
|
||||
path,
|
||||
headers,
|
||||
params,
|
||||
responseType = Map::class.java
|
||||
)
|
||||
|
||||
offset += CHUNK_SIZE
|
||||
headers["x-appwrite-id"] = result!!["\$id"].toString()
|
||||
onProgress?.invoke(
|
||||
UploadProgress(
|
||||
id = result!!["\$id"].toString(),
|
||||
progress = offset.coerceAtMost(size).toDouble() / size * 100,
|
||||
sizeUploaded = offset.coerceAtMost(size),
|
||||
chunksTotal = result!!["chunksTotal"].toString().toInt(),
|
||||
chunksUploaded = result!!["chunksUploaded"].toString().toInt(),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return converter(result as Map<String, Any>)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +421,7 @@ class Client @JvmOverloads constructor(
|
||||
*
|
||||
* @param request
|
||||
* @param responseType
|
||||
* @param convert
|
||||
* @param converter
|
||||
*
|
||||
* @return [T]
|
||||
*/
|
||||
@@ -330,7 +429,7 @@ class Client @JvmOverloads constructor(
|
||||
private suspend fun <T> awaitResponse(
|
||||
request: Request,
|
||||
responseType: Class<T>,
|
||||
convert: ((Map<String, Any,>) -> T)? = null
|
||||
converter: ((Map<String, Any,>) -> T)? = null
|
||||
) = suspendCancellableCoroutine<T> {
|
||||
http.newCall(request).enqueue(object : Callback {
|
||||
override fun onFailure(call: Call, e: IOException) {
|
||||
@@ -347,8 +446,18 @@ class Client @JvmOverloads constructor(
|
||||
.charStream()
|
||||
.buffered()
|
||||
.use(BufferedReader::readText)
|
||||
|
||||
val error = if (response.headers["content-type"]?.contains("application/json") == true) {
|
||||
body.fromJson()
|
||||
val map = gson.fromJson<Map<String, Any>>(
|
||||
body,
|
||||
object : TypeToken<Map<String, Any>>(){}.type
|
||||
)
|
||||
AppwriteException(
|
||||
map["message"] as? String ?: "",
|
||||
(map["code"] as Number).toInt(),
|
||||
map["type"] as? String ?: "",
|
||||
body
|
||||
)
|
||||
} else {
|
||||
AppwriteException(body, response.code)
|
||||
}
|
||||
@@ -386,7 +495,7 @@ class Client @JvmOverloads constructor(
|
||||
object : TypeToken<Map<String, Any>>(){}.type
|
||||
)
|
||||
it.resume(
|
||||
convert?.invoke(map) ?: map as T
|
||||
converter?.invoke(map) ?: map as T
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -13,8 +13,8 @@ class Query {
|
||||
fun greater(attribute: String, value: Any) = Query.addQuery(attribute, "greater", value)
|
||||
|
||||
fun greaterEqual(attribute: String, value: Any) = Query.addQuery(attribute, "greaterEqual", value)
|
||||
|
||||
fun contains(attribute: String, value: List<Any>) = Query.addQuery(attribute, "contains", value)
|
||||
|
||||
fun search(attribute: String, value: String) = Query.addQuery(attribute, "search", value)
|
||||
|
||||
private fun addQuery(attribute: String, oper: String, value: Any): String {
|
||||
return when (value) {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package io.appwrite.cookies
|
||||
|
||||
import android.os.Build
|
||||
import java.net.CookieStore
|
||||
import java.net.HttpCookie
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
fun HttpCookie.toSetCookieString(): String {
|
||||
val expires = if (maxAge != -1L) {
|
||||
val dateFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.UK).apply {
|
||||
timeZone = TimeZone.getTimeZone("GMT")
|
||||
}
|
||||
|
||||
val calendar = Calendar.getInstance(Locale.UK).apply { set(Calendar.SECOND, maxAge.toInt()) }
|
||||
|
||||
"; expires=${dateFormat.format(calendar.time)}"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
val path = if (path != null) "; path=$path" else ""
|
||||
val domain = if (domain != null) "; domain=$domain" else ""
|
||||
val secure = if (secure) "; secure" else ""
|
||||
val httpOnly = if (Build.VERSION.SDK_INT >= 24) {
|
||||
if (isHttpOnly) "; httponly" else ""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
return "$name=$value$expires$path$domain$secure$httpOnly"
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun CookieStore.syncToWebKitCookieManager() {
|
||||
val webKitCookieManager = android.webkit.CookieManager.getInstance()
|
||||
|
||||
cookies.forEach {
|
||||
val hostUrl = "${if (it.secure) "https" else "http"}://${it.domain}"
|
||||
webKitCookieManager.setCookie(hostUrl, it.toSetCookieString())
|
||||
}
|
||||
|
||||
webKitCookieManager.flush()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
@Suppress("DEPRECATION")
|
||||
fun android.webkit.CookieManager.removeAll() {
|
||||
removeAllCookies(null)
|
||||
flush()
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package io.appwrite.cookies
|
||||
|
||||
import android.os.Build
|
||||
import java.net.HttpCookie
|
||||
|
||||
data class InternalCookie(
|
||||
val comment: String?,
|
||||
val commentURL: String?,
|
||||
val discard: Boolean?,
|
||||
val domain: String,
|
||||
val maxAge: Long?,
|
||||
val name: String,
|
||||
val path: String?,
|
||||
val portlist: String?,
|
||||
val secure: Boolean?,
|
||||
val value: String,
|
||||
val version: Int?,
|
||||
var httpOnly: Boolean? = null
|
||||
) {
|
||||
constructor(cookie: HttpCookie) : this(
|
||||
cookie.comment,
|
||||
cookie.commentURL,
|
||||
cookie.discard,
|
||||
cookie.domain,
|
||||
cookie.maxAge,
|
||||
cookie.name,
|
||||
cookie.path,
|
||||
cookie.portlist,
|
||||
cookie.secure,
|
||||
cookie.value,
|
||||
cookie.version
|
||||
)
|
||||
|
||||
fun toHttpCookie() = HttpCookie(name, value).apply {
|
||||
comment = this@InternalCookie.comment
|
||||
commentURL = this@InternalCookie.commentURL
|
||||
discard = this@InternalCookie.discard == true
|
||||
domain = this@InternalCookie.domain
|
||||
maxAge = this@InternalCookie.maxAge ?: 0
|
||||
path = this@InternalCookie.path
|
||||
portlist = this@InternalCookie.portlist
|
||||
secure = this@InternalCookie.secure == true
|
||||
version = this@InternalCookie.version ?: 0
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
isHttpOnly = (this@InternalCookie.httpOnly == true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
package io.appwrite.cookies.stores
|
||||
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import java.net.CookieStore
|
||||
import java.net.HttpCookie
|
||||
import java.net.URI
|
||||
import java.net.URISyntaxException
|
||||
import java.util.Collections
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
|
||||
open class InMemoryCookieStore(private val name: String) : CookieStore {
|
||||
|
||||
internal val uriIndex = mutableMapOf<URI, MutableList<HttpCookie>>()
|
||||
private val lock = ReentrantLock(false)
|
||||
|
||||
override fun removeAll(): Boolean {
|
||||
lock.lock()
|
||||
|
||||
return try {
|
||||
uriIndex.clear()
|
||||
uriIndex.isEmpty()
|
||||
} finally {
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
|
||||
override fun add(uri: URI?, cookie: HttpCookie?) {
|
||||
if (cookie == null) {
|
||||
Log.i(
|
||||
javaClass.simpleName,
|
||||
"tried to add null cookie in cookie store named $name. Doing nothing."
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (uri == null) {
|
||||
Log.i(
|
||||
javaClass.simpleName,
|
||||
"tried to add null URI in cookie store named $name. Doing nothing."
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
lock.lock()
|
||||
try {
|
||||
addIndex(getEffectiveURI(uri), cookie)
|
||||
} finally {
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCookies(): List<HttpCookie> {
|
||||
val cookies = mutableListOf<HttpCookie>()
|
||||
|
||||
lock.lock()
|
||||
try {
|
||||
for (list in uriIndex.values) {
|
||||
val it = list.iterator()
|
||||
while (it.hasNext()) {
|
||||
val cookie = it.next()
|
||||
if (cookie.hasExpired()) {
|
||||
it.remove()
|
||||
} else if (!cookies.contains(cookie)) {
|
||||
cookies.add(cookie)
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
return cookies
|
||||
}
|
||||
|
||||
override fun getURIs(): List<URI> {
|
||||
val uris = mutableListOf<URI>()
|
||||
|
||||
lock.lock()
|
||||
return try {
|
||||
uriIndex.keys.toList()
|
||||
} finally {
|
||||
uris.addAll(uriIndex.keys)
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
|
||||
override fun remove(uri: URI?, cookie: HttpCookie?): Boolean {
|
||||
if (cookie == null) {
|
||||
Log.i(
|
||||
javaClass.simpleName,
|
||||
"tried to remove null cookie from cookie store named $name. Doing nothing."
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
if (uri == null) {
|
||||
Log.i(
|
||||
javaClass.simpleName,
|
||||
"tried to remove null URI from cookie store named $name. Doing nothing."
|
||||
)
|
||||
return true
|
||||
}
|
||||
|
||||
lock.lock()
|
||||
|
||||
return try {
|
||||
val lintedURI = getEffectiveURI(uri)
|
||||
|
||||
if (uriIndex[lintedURI] == null) {
|
||||
false
|
||||
} else {
|
||||
val cookies = uriIndex[lintedURI]
|
||||
cookies?.remove(cookie) ?: false
|
||||
}
|
||||
} finally {
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
|
||||
override fun get(uri: URI?): List<HttpCookie> {
|
||||
if (uri == null) {
|
||||
Log.i(
|
||||
javaClass.simpleName,
|
||||
"getting cookies from cookie store named $name for null URI results in empty list"
|
||||
)
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val cookies = arrayListOf<HttpCookie>()
|
||||
|
||||
lock.lock()
|
||||
try {
|
||||
uri.host?.let { cookies.addAll(getInternal1(it)) }
|
||||
val internal2 = getInternal2(getEffectiveURI(uri)).filter { !cookies.contains(it) }
|
||||
cookies.addAll(internal2)
|
||||
} finally {
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
return cookies
|
||||
}
|
||||
|
||||
internal fun getEffectiveURI(uri: URI): URI {
|
||||
return try {
|
||||
URI(uri.scheme ?: "http", uri.host, null, null, null)
|
||||
} catch (ignored: URISyntaxException) {
|
||||
uri
|
||||
}
|
||||
}
|
||||
|
||||
private fun addIndex(index: URI, cookie: HttpCookie) {
|
||||
val cookies = uriIndex[index]
|
||||
|
||||
if (cookies != null) {
|
||||
cookies.remove(cookie)
|
||||
cookies.add(cookie)
|
||||
} else {
|
||||
val newCookies = mutableListOf<HttpCookie>()
|
||||
newCookies.add(cookie)
|
||||
uriIndex[index] = newCookies
|
||||
}
|
||||
}
|
||||
|
||||
private fun netscapeDomainMatches(domain: String?, host: String?): Boolean {
|
||||
if (domain == null || host == null) {
|
||||
return false
|
||||
}
|
||||
|
||||
// If there's no embedded dot in domain and domain is not .local
|
||||
val isLocalDomain = ".local".equals(domain, ignoreCase = true)
|
||||
var embeddedDotInDomain = domain.indexOf('.')
|
||||
if (embeddedDotInDomain == 0) {
|
||||
embeddedDotInDomain = domain.indexOf('.', 1)
|
||||
}
|
||||
if (!isLocalDomain && (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length - 1)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// If the host name contains no dot and the domain name is .local
|
||||
val firstDotInHost = host.indexOf('.')
|
||||
if (firstDotInHost == -1 && isLocalDomain) {
|
||||
return true
|
||||
}
|
||||
|
||||
val domainLength = domain.length
|
||||
val lengthDiff = host.length - domainLength
|
||||
if (lengthDiff == 0) {
|
||||
// If the host name and the domain name are just string-compare euqal
|
||||
return host.equals(domain, ignoreCase = true)
|
||||
} else if (lengthDiff > 0) {
|
||||
// need to check H & D component
|
||||
val D = host.substring(lengthDiff)
|
||||
|
||||
// Android-changed: b/26456024 targetSdkVersion based compatibility for domain matching
|
||||
// Android M and earlier: Cookies with domain "foo.com" would not match "bar.foo.com".
|
||||
// The RFC dictates that the user agent must treat those domains as if they had a
|
||||
// leading period and must therefore match "bar.foo.com".
|
||||
return if (Build.VERSION.SDK_INT <= 23 && !domain.startsWith(".")) {
|
||||
false
|
||||
} else D.equals(domain, ignoreCase = true)
|
||||
} else if (lengthDiff == -1) {
|
||||
// if domain is actually .host
|
||||
return domain[0] == '.' && host.equals(domain.substring(1), ignoreCase = true)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
private fun getInternal1(host: String): List<HttpCookie> {
|
||||
// BEGIN Android-changed: b/25897688 InMemoryCookieStore ignores scheme (http/https)
|
||||
// Use a separate list to handle cookies that need to be removed so
|
||||
// that there is no conflict with iterators.
|
||||
val toRemove = mutableListOf<HttpCookie>()
|
||||
val cookies = mutableListOf<HttpCookie>()
|
||||
|
||||
for ((_, lst) in uriIndex) {
|
||||
for (c in lst) {
|
||||
val domain = c.domain
|
||||
if (c.version == 0 && netscapeDomainMatches(
|
||||
domain,
|
||||
host
|
||||
) || c.version == 1 && HttpCookie.domainMatches(domain, host)
|
||||
) {
|
||||
if (!c.hasExpired()) {
|
||||
if (!cookies.contains(c)) {
|
||||
cookies.add(c)
|
||||
}
|
||||
} else {
|
||||
toRemove.add(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Clean up the cookies that need to be removed
|
||||
for (c in toRemove) {
|
||||
lst.remove(c)
|
||||
}
|
||||
toRemove.clear()
|
||||
}
|
||||
return cookies
|
||||
}
|
||||
|
||||
private fun getInternal2(comparator: URI): List<HttpCookie> {
|
||||
// BEGIN Android-changed: b/25897688 InMemoryCookieStore ignores scheme (http/https)
|
||||
// Removed cookieJar
|
||||
val cookies = mutableListOf<HttpCookie>()
|
||||
|
||||
for (index in uriIndex.keys) {
|
||||
if (index === comparator || comparator.compareTo(index) == 0) {
|
||||
val indexedCookies = uriIndex[index]
|
||||
// Check the list of cookies associated with this domain
|
||||
if (indexedCookies != null) {
|
||||
val it = indexedCookies.iterator()
|
||||
while (it.hasNext()) {
|
||||
val ck = it.next()
|
||||
if (!ck.hasExpired()) {
|
||||
if (!cookies.contains(ck))
|
||||
cookies.add(ck)
|
||||
} else {
|
||||
it.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cookies
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package io.appwrite.cookies.stores
|
||||
|
||||
import io.appwrite.cookies.InternalCookie
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import java.net.HttpCookie
|
||||
import java.net.URI
|
||||
|
||||
open class SharedPreferencesCookieStore(
|
||||
context: Context,
|
||||
private val name: String
|
||||
) : InMemoryCookieStore(name) {
|
||||
|
||||
private val preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE)
|
||||
private val gson = Gson()
|
||||
|
||||
init {
|
||||
synchronized(SharedPreferencesCookieStore::class.java) {
|
||||
preferences.all.forEach { (key, value) ->
|
||||
try {
|
||||
val index = URI.create(key)
|
||||
val listType = object : TypeToken<MutableList<InternalCookie>>() {}.type
|
||||
val internalCookies =
|
||||
gson.fromJson<MutableList<InternalCookie>>(value.toString(), listType)
|
||||
val cookies = internalCookies.map { it.toHttpCookie() }.toMutableList()
|
||||
uriIndex[index] = cookies
|
||||
} catch (exception: Throwable) {
|
||||
Log.e(
|
||||
javaClass.simpleName,
|
||||
"Error while loading key = $key, value = $value from cookie store named $name",
|
||||
exception
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun removeAll(): Boolean =
|
||||
synchronized(SharedPreferencesCookieStore::class.java) {
|
||||
super.removeAll()
|
||||
preferences.edit().clear().apply()
|
||||
true
|
||||
}
|
||||
|
||||
override fun add(uri: URI?, cookie: HttpCookie?) =
|
||||
synchronized(SharedPreferencesCookieStore::class.java) {
|
||||
uri ?: return@synchronized
|
||||
|
||||
super.add(uri, cookie)
|
||||
val index = getEffectiveURI(uri)
|
||||
val cookies = uriIndex[index] ?: return@synchronized
|
||||
|
||||
val internalCookies = cookies.map {
|
||||
InternalCookie(it).apply {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
httpOnly = it.isHttpOnly
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val listType = object : TypeToken<MutableList<InternalCookie>>() {}.type
|
||||
val json = gson.toJson(internalCookies, listType)
|
||||
|
||||
preferences
|
||||
.edit()
|
||||
.putString(index.toString(), json)
|
||||
.apply()
|
||||
}
|
||||
|
||||
override fun remove(uri: URI?, cookie: HttpCookie?): Boolean =
|
||||
synchronized(SharedPreferencesCookieStore::class.java) {
|
||||
uri ?: return false
|
||||
|
||||
val result = super.remove(uri, cookie)
|
||||
val index = getEffectiveURI(uri)
|
||||
val cookies = uriIndex[index]
|
||||
val internalCookies = cookies?.map {
|
||||
InternalCookie(it).apply {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
httpOnly = it.isHttpOnly
|
||||
}
|
||||
}
|
||||
}
|
||||
val listType = object : TypeToken<MutableList<InternalCookie>>() {}.type
|
||||
val json = gson.toJson(internalCookies, listType)
|
||||
|
||||
preferences.edit().apply {
|
||||
when (cookies) {
|
||||
null -> remove(index.toString())
|
||||
else -> putString(index.toString(), json)
|
||||
}
|
||||
}.apply()
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,6 @@ import java.lang.Exception
|
||||
class AppwriteException(
|
||||
override val message: String? = null,
|
||||
val code: Int? = null,
|
||||
val type: String? = null,
|
||||
val response: String? = null
|
||||
) : Exception(message)
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Continent
|
||||
*/
|
||||
@@ -8,12 +10,14 @@ data class Continent(
|
||||
* Continent name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
|
||||
/**
|
||||
* Continent two letter code.
|
||||
*
|
||||
*/
|
||||
@SerializedName("code")
|
||||
val code: String
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Continents List
|
||||
*/
|
||||
data class ContinentList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of continents documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of continents.
|
||||
*
|
||||
*/
|
||||
@SerializedName("continents")
|
||||
val continents: List<Continent>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = ContinentList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
continents = (map["continents"] as List<Map<String, Any>>).map { Continent.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"continents" to continents.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Country
|
||||
*/
|
||||
@@ -8,12 +10,14 @@ data class Country(
|
||||
* Country name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
|
||||
/**
|
||||
* Country two-character ISO 3166-1 alpha code.
|
||||
*
|
||||
*/
|
||||
@SerializedName("code")
|
||||
val code: String
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Countries List
|
||||
*/
|
||||
data class CountryList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of countries documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of countries.
|
||||
*
|
||||
*/
|
||||
@SerializedName("countries")
|
||||
val countries: List<Country>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = CountryList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
countries = (map["countries"] as List<Map<String, Any>>).map { Country.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"countries" to countries.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Currency
|
||||
*/
|
||||
@@ -8,42 +10,49 @@ data class Currency(
|
||||
* Currency symbol.
|
||||
*
|
||||
*/
|
||||
@SerializedName("symbol")
|
||||
val symbol: String,
|
||||
|
||||
/**
|
||||
* Currency name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
|
||||
/**
|
||||
* Currency native symbol.
|
||||
*
|
||||
*/
|
||||
@SerializedName("symbolNative")
|
||||
val symbolNative: String,
|
||||
|
||||
/**
|
||||
* Number of decimal digits.
|
||||
*
|
||||
*/
|
||||
@SerializedName("decimalDigits")
|
||||
val decimalDigits: Long,
|
||||
|
||||
/**
|
||||
* Currency digit rounding.
|
||||
*
|
||||
*/
|
||||
@SerializedName("rounding")
|
||||
val rounding: Double,
|
||||
|
||||
/**
|
||||
* Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format.
|
||||
*
|
||||
*/
|
||||
@SerializedName("code")
|
||||
val code: String,
|
||||
|
||||
/**
|
||||
* Currency plural name
|
||||
*
|
||||
*/
|
||||
@SerializedName("namePlural")
|
||||
val namePlural: String
|
||||
) {
|
||||
companion object {
|
||||
@@ -52,8 +61,8 @@ data class Currency(
|
||||
symbol = map["symbol"] as String,
|
||||
name = map["name"] as String,
|
||||
symbolNative = map["symbolNative"] as String,
|
||||
decimalDigits = map["decimalDigits"] as Long,
|
||||
rounding = map["rounding"] as Double,
|
||||
decimalDigits = (map["decimalDigits"] as Number).toLong(),
|
||||
rounding = (map["rounding"] as Number).toDouble(),
|
||||
code = map["code"] as String,
|
||||
namePlural = map["namePlural"] as String
|
||||
)
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Currencies List
|
||||
*/
|
||||
data class CurrencyList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of currencies documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of currencies.
|
||||
*
|
||||
*/
|
||||
@SerializedName("currencies")
|
||||
val currencies: List<Currency>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = CurrencyList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
currencies = (map["currencies"] as List<Map<String, Any>>).map { Currency.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"currencies" to currencies.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Document
|
||||
*/
|
||||
@@ -8,24 +10,28 @@ data class Document(
|
||||
* Document ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$id")
|
||||
val id: String,
|
||||
|
||||
/**
|
||||
* Collection ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$collection")
|
||||
val collection: String,
|
||||
|
||||
/**
|
||||
* Document read permissions.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$read")
|
||||
val read: List<Any>,
|
||||
|
||||
/**
|
||||
* Document write permissions.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$write")
|
||||
val write: List<Any>,
|
||||
|
||||
val data: Map<String, Any>
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Documents List
|
||||
*/
|
||||
data class DocumentList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of documents documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of documents.
|
||||
*
|
||||
*/
|
||||
@SerializedName("documents")
|
||||
val documents: List<Document>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = DocumentList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
documents = (map["documents"] as List<Map<String, Any>>).map { Document.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"documents" to documents.map { it.toMap() } as Any
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Execution
|
||||
*/
|
||||
@@ -8,60 +10,70 @@ data class Execution(
|
||||
* Execution ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$id")
|
||||
val id: String,
|
||||
|
||||
/**
|
||||
* Execution read permissions.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$read")
|
||||
val read: List<Any>,
|
||||
|
||||
/**
|
||||
* Function ID.
|
||||
*
|
||||
*/
|
||||
@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`.
|
||||
*
|
||||
*/
|
||||
@SerializedName("trigger")
|
||||
val trigger: String,
|
||||
|
||||
/**
|
||||
* The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.
|
||||
*
|
||||
*/
|
||||
@SerializedName("status")
|
||||
val status: String,
|
||||
|
||||
/**
|
||||
* The script exit code.
|
||||
* The script status code.
|
||||
*
|
||||
*/
|
||||
val exitCode: Long,
|
||||
@SerializedName("statusCode")
|
||||
val statusCode: Long,
|
||||
|
||||
/**
|
||||
* The script stdout output string. Logs the last 4,000 characters of the execution stdout output.
|
||||
* The script response output string. Logs the last 4,000 characters of the execution response output.
|
||||
*
|
||||
*/
|
||||
val stdout: String,
|
||||
@SerializedName("response")
|
||||
val response: String,
|
||||
|
||||
/**
|
||||
* The script stderr output string. Logs the last 4,000 characters of the execution stderr output
|
||||
*
|
||||
*/
|
||||
@SerializedName("stderr")
|
||||
val stderr: String,
|
||||
|
||||
/**
|
||||
* The script execution time in seconds.
|
||||
*
|
||||
*/
|
||||
@SerializedName("time")
|
||||
val time: Double
|
||||
) {
|
||||
companion object {
|
||||
@@ -70,13 +82,13 @@ data class Execution(
|
||||
id = map["\$id"] as String,
|
||||
read = map["\$read"] as List<Any>,
|
||||
functionId = map["functionId"] as String,
|
||||
dateCreated = map["dateCreated"] as Long,
|
||||
dateCreated = (map["dateCreated"] as Number).toLong(),
|
||||
trigger = map["trigger"] as String,
|
||||
status = map["status"] as String,
|
||||
exitCode = map["exitCode"] as Long,
|
||||
stdout = map["stdout"] as String,
|
||||
statusCode = (map["statusCode"] as Number).toLong(),
|
||||
response = map["response"] as String,
|
||||
stderr = map["stderr"] as String,
|
||||
time = map["time"] as Double
|
||||
time = (map["time"] as Number).toDouble()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -87,8 +99,8 @@ data class Execution(
|
||||
"dateCreated" to dateCreated as Any,
|
||||
"trigger" to trigger as Any,
|
||||
"status" to status as Any,
|
||||
"exitCode" to exitCode as Any,
|
||||
"stdout" to stdout as Any,
|
||||
"statusCode" to statusCode as Any,
|
||||
"response" to response as Any,
|
||||
"stderr" to stderr as Any,
|
||||
"time" to time as Any
|
||||
)
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Executions List
|
||||
*/
|
||||
data class ExecutionList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of executions documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of executions.
|
||||
*
|
||||
*/
|
||||
@SerializedName("executions")
|
||||
val executions: List<Execution>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = ExecutionList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
executions = (map["executions"] as List<Map<String, Any>>).map { Execution.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"executions" to executions.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* File
|
||||
*/
|
||||
@@ -8,72 +10,107 @@ data class File(
|
||||
* File ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$id")
|
||||
val id: String,
|
||||
|
||||
/**
|
||||
* Bucket ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("bucketId")
|
||||
val bucketId: String,
|
||||
|
||||
/**
|
||||
* File read permissions.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$read")
|
||||
val read: List<Any>,
|
||||
|
||||
/**
|
||||
* File write permissions.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$write")
|
||||
val write: List<Any>,
|
||||
|
||||
/**
|
||||
* File name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
|
||||
/**
|
||||
* File creation date in Unix timestamp.
|
||||
*
|
||||
*/
|
||||
@SerializedName("dateCreated")
|
||||
val dateCreated: Long,
|
||||
|
||||
/**
|
||||
* File MD5 signature.
|
||||
*
|
||||
*/
|
||||
@SerializedName("signature")
|
||||
val signature: String,
|
||||
|
||||
/**
|
||||
* File mime type.
|
||||
*
|
||||
*/
|
||||
@SerializedName("mimeType")
|
||||
val mimeType: String,
|
||||
|
||||
/**
|
||||
* File original size in bytes.
|
||||
*
|
||||
*/
|
||||
val sizeOriginal: Long
|
||||
@SerializedName("sizeOriginal")
|
||||
val sizeOriginal: Long,
|
||||
|
||||
/**
|
||||
* Total number of chunks available
|
||||
*
|
||||
*/
|
||||
@SerializedName("chunksTotal")
|
||||
val chunksTotal: Long,
|
||||
|
||||
/**
|
||||
* Total number of chunks uploaded
|
||||
*
|
||||
*/
|
||||
@SerializedName("chunksUploaded")
|
||||
val chunksUploaded: Long
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = File(
|
||||
id = map["\$id"] as String,
|
||||
bucketId = map["bucketId"] as String,
|
||||
read = map["\$read"] as List<Any>,
|
||||
write = map["\$write"] as List<Any>,
|
||||
name = map["name"] as String,
|
||||
dateCreated = map["dateCreated"] as Long,
|
||||
dateCreated = (map["dateCreated"] as Number).toLong(),
|
||||
signature = map["signature"] as String,
|
||||
mimeType = map["mimeType"] as String,
|
||||
sizeOriginal = map["sizeOriginal"] as Long
|
||||
sizeOriginal = (map["sizeOriginal"] as Number).toLong(),
|
||||
chunksTotal = (map["chunksTotal"] as Number).toLong(),
|
||||
chunksUploaded = (map["chunksUploaded"] as Number).toLong()
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"\$id" to id as Any,
|
||||
"bucketId" to bucketId 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
|
||||
"sizeOriginal" to sizeOriginal as Any,
|
||||
"chunksTotal" to chunksTotal as Any,
|
||||
"chunksUploaded" to chunksUploaded as Any
|
||||
)
|
||||
}
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Files List
|
||||
*/
|
||||
data class FileList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of files documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of files.
|
||||
*
|
||||
*/
|
||||
@SerializedName("files")
|
||||
val files: List<File>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = FileList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
files = (map["files"] as List<Map<String, Any>>).map { File.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"files" to files.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* JWT
|
||||
*/
|
||||
@@ -8,6 +10,7 @@ data class Jwt(
|
||||
* JWT encoded string.
|
||||
*
|
||||
*/
|
||||
@SerializedName("jwt")
|
||||
val jwt: String
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Language
|
||||
*/
|
||||
@@ -8,18 +10,21 @@ data class Language(
|
||||
* Language name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
|
||||
/**
|
||||
* Language two-character ISO 639-1 codes.
|
||||
*
|
||||
*/
|
||||
@SerializedName("code")
|
||||
val code: String,
|
||||
|
||||
/**
|
||||
* Language native name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("nativeName")
|
||||
val nativeName: String
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Languages List
|
||||
*/
|
||||
data class LanguageList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of languages documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of languages.
|
||||
*
|
||||
*/
|
||||
@SerializedName("languages")
|
||||
val languages: List<Language>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = LanguageList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
languages = (map["languages"] as List<Map<String, Any>>).map { Language.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"languages" to languages.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Locale
|
||||
*/
|
||||
@@ -8,42 +10,49 @@ data class Locale(
|
||||
* User IP address.
|
||||
*
|
||||
*/
|
||||
@SerializedName("ip")
|
||||
val ip: String,
|
||||
|
||||
/**
|
||||
* Country code in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) two-character format
|
||||
*
|
||||
*/
|
||||
@SerializedName("countryCode")
|
||||
val countryCode: String,
|
||||
|
||||
/**
|
||||
* Country name. This field support localization.
|
||||
*
|
||||
*/
|
||||
@SerializedName("country")
|
||||
val country: String,
|
||||
|
||||
/**
|
||||
* Continent code. A two character continent code "AF" for Africa, "AN" for Antarctica, "AS" for Asia, "EU" for Europe, "NA" for North America, "OC" for Oceania, and "SA" for South America.
|
||||
*
|
||||
*/
|
||||
@SerializedName("continentCode")
|
||||
val continentCode: String,
|
||||
|
||||
/**
|
||||
* Continent name. This field support localization.
|
||||
*
|
||||
*/
|
||||
@SerializedName("continent")
|
||||
val continent: String,
|
||||
|
||||
/**
|
||||
* True if country is part of the Europian Union.
|
||||
*
|
||||
*/
|
||||
@SerializedName("eu")
|
||||
val eu: Boolean,
|
||||
|
||||
/**
|
||||
* Currency code in [ISO 4217-1](http://en.wikipedia.org/wiki/ISO_4217) three-character format
|
||||
*
|
||||
*/
|
||||
@SerializedName("currency")
|
||||
val currency: String
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Log
|
||||
*/
|
||||
@@ -8,126 +10,147 @@ data class Log(
|
||||
* Event name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("event")
|
||||
val event: String,
|
||||
|
||||
/**
|
||||
* User ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("userId")
|
||||
val userId: String,
|
||||
|
||||
/**
|
||||
* User Email.
|
||||
*
|
||||
*/
|
||||
@SerializedName("userEmail")
|
||||
val userEmail: String,
|
||||
|
||||
/**
|
||||
* User Name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("userName")
|
||||
val userName: String,
|
||||
|
||||
/**
|
||||
* API mode when event triggered.
|
||||
*
|
||||
*/
|
||||
@SerializedName("mode")
|
||||
val mode: String,
|
||||
|
||||
/**
|
||||
* IP session in use when the session was created.
|
||||
*
|
||||
*/
|
||||
@SerializedName("ip")
|
||||
val ip: String,
|
||||
|
||||
/**
|
||||
* Log creation time in Unix timestamp.
|
||||
*
|
||||
*/
|
||||
@SerializedName("time")
|
||||
val time: Long,
|
||||
|
||||
/**
|
||||
* Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).
|
||||
*
|
||||
*/
|
||||
@SerializedName("osCode")
|
||||
val osCode: String,
|
||||
|
||||
/**
|
||||
* Operating system name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("osName")
|
||||
val osName: String,
|
||||
|
||||
/**
|
||||
* Operating system version.
|
||||
*
|
||||
*/
|
||||
@SerializedName("osVersion")
|
||||
val osVersion: String,
|
||||
|
||||
/**
|
||||
* Client type.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientType")
|
||||
val clientType: String,
|
||||
|
||||
/**
|
||||
* Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json).
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientCode")
|
||||
val clientCode: String,
|
||||
|
||||
/**
|
||||
* Client name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientName")
|
||||
val clientName: String,
|
||||
|
||||
/**
|
||||
* Client version.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientVersion")
|
||||
val clientVersion: String,
|
||||
|
||||
/**
|
||||
* Client engine name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientEngine")
|
||||
val clientEngine: String,
|
||||
|
||||
/**
|
||||
* Client engine name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientEngineVersion")
|
||||
val clientEngineVersion: String,
|
||||
|
||||
/**
|
||||
* Device name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("deviceName")
|
||||
val deviceName: String,
|
||||
|
||||
/**
|
||||
* Device brand name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("deviceBrand")
|
||||
val deviceBrand: String,
|
||||
|
||||
/**
|
||||
* Device model name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("deviceModel")
|
||||
val deviceModel: String,
|
||||
|
||||
/**
|
||||
* Country two-character ISO 3166-1 alpha code.
|
||||
*
|
||||
*/
|
||||
@SerializedName("countryCode")
|
||||
val countryCode: String,
|
||||
|
||||
/**
|
||||
* Country name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("countryName")
|
||||
val countryName: String
|
||||
) {
|
||||
companion object {
|
||||
@@ -139,7 +162,7 @@ data class Log(
|
||||
userName = map["userName"] as String,
|
||||
mode = map["mode"] as String,
|
||||
ip = map["ip"] as String,
|
||||
time = map["time"] as Long,
|
||||
time = (map["time"] as Number).toLong(),
|
||||
osCode = map["osCode"] as String,
|
||||
osName = map["osName"] as String,
|
||||
osVersion = map["osVersion"] as String,
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Logs List
|
||||
*/
|
||||
data class LogList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of logs documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of logs.
|
||||
*
|
||||
*/
|
||||
@SerializedName("logs")
|
||||
val logs: List<Log>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = LogList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
logs = (map["logs"] as List<Map<String, Any>>).map { Log.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"logs" to logs.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Membership
|
||||
*/
|
||||
@@ -8,54 +10,70 @@ data class Membership(
|
||||
* Membership ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$id")
|
||||
val id: String,
|
||||
|
||||
/**
|
||||
* User ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("userId")
|
||||
val userId: String,
|
||||
|
||||
/**
|
||||
* Team ID.
|
||||
*
|
||||
*/
|
||||
val teamId: String,
|
||||
|
||||
/**
|
||||
* User name.
|
||||
*
|
||||
*/
|
||||
val name: String,
|
||||
@SerializedName("userName")
|
||||
val userName: String,
|
||||
|
||||
/**
|
||||
* User email address.
|
||||
*
|
||||
*/
|
||||
val email: String,
|
||||
@SerializedName("userEmail")
|
||||
val userEmail: String,
|
||||
|
||||
/**
|
||||
* Team ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("teamId")
|
||||
val teamId: String,
|
||||
|
||||
/**
|
||||
* Team name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("teamName")
|
||||
val teamName: String,
|
||||
|
||||
/**
|
||||
* Date, the user has been invited to join the team in Unix timestamp.
|
||||
*
|
||||
*/
|
||||
@SerializedName("invited")
|
||||
val invited: Long,
|
||||
|
||||
/**
|
||||
* Date, the user has accepted the invitation to join the team in Unix timestamp.
|
||||
*
|
||||
*/
|
||||
@SerializedName("joined")
|
||||
val joined: Long,
|
||||
|
||||
/**
|
||||
* User confirmation status, true if the user has joined the team or false otherwise.
|
||||
*
|
||||
*/
|
||||
@SerializedName("confirm")
|
||||
val confirm: Boolean,
|
||||
|
||||
/**
|
||||
* User list of roles
|
||||
*
|
||||
*/
|
||||
@SerializedName("roles")
|
||||
val roles: List<Any>
|
||||
) {
|
||||
companion object {
|
||||
@@ -63,11 +81,12 @@ data class Membership(
|
||||
fun from(map: Map<String, Any>) = Membership(
|
||||
id = map["\$id"] as String,
|
||||
userId = map["userId"] as String,
|
||||
userName = map["userName"] as String,
|
||||
userEmail = map["userEmail"] as String,
|
||||
teamId = map["teamId"] as String,
|
||||
name = map["name"] as String,
|
||||
email = map["email"] as String,
|
||||
invited = map["invited"] as Long,
|
||||
joined = map["joined"] as Long,
|
||||
teamName = map["teamName"] as String,
|
||||
invited = (map["invited"] as Number).toLong(),
|
||||
joined = (map["joined"] as Number).toLong(),
|
||||
confirm = map["confirm"] as Boolean,
|
||||
roles = map["roles"] as List<Any>
|
||||
)
|
||||
@@ -76,9 +95,10 @@ data class Membership(
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"\$id" to id as Any,
|
||||
"userId" to userId as Any,
|
||||
"userName" to userName as Any,
|
||||
"userEmail" to userEmail as Any,
|
||||
"teamId" to teamId as Any,
|
||||
"name" to name as Any,
|
||||
"email" to email as Any,
|
||||
"teamName" to teamName as Any,
|
||||
"invited" to invited as Any,
|
||||
"joined" to joined as Any,
|
||||
"confirm" to confirm as Any,
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Memberships List
|
||||
*/
|
||||
data class MembershipList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of memberships documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of memberships.
|
||||
*
|
||||
*/
|
||||
@SerializedName("memberships")
|
||||
val memberships: List<Membership>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = MembershipList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
memberships = (map["memberships"] as List<Map<String, Any>>).map { Membership.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"memberships" to memberships.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Phone
|
||||
*/
|
||||
@@ -8,18 +10,21 @@ data class Phone(
|
||||
* Phone code.
|
||||
*
|
||||
*/
|
||||
@SerializedName("code")
|
||||
val code: String,
|
||||
|
||||
/**
|
||||
* Country two-character ISO 3166-1 alpha code.
|
||||
*
|
||||
*/
|
||||
@SerializedName("countryCode")
|
||||
val countryCode: String,
|
||||
|
||||
/**
|
||||
* Country name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("countryName")
|
||||
val countryName: String
|
||||
) {
|
||||
companion object {
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Phones List
|
||||
*/
|
||||
data class PhoneList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of phones documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of phones.
|
||||
*
|
||||
*/
|
||||
@SerializedName("phones")
|
||||
val phones: List<Phone>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = PhoneList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
phones = (map["phones"] as List<Map<String, Any>>).map { Phone.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"phones" to phones.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Preferences
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import kotlin.collections.Collection
|
||||
import java.io.Closeable
|
||||
|
||||
data class RealtimeSubscription(
|
||||
@@ -20,7 +21,7 @@ open class RealtimeResponse(
|
||||
)
|
||||
|
||||
data class RealtimeResponseEvent<T>(
|
||||
val event: String,
|
||||
val events: Collection<String>,
|
||||
val channels: Collection<String>,
|
||||
val timestamp: Long,
|
||||
var payload: T
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Session
|
||||
*/
|
||||
@@ -8,132 +10,168 @@ data class Session(
|
||||
* Session ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$id")
|
||||
val id: String,
|
||||
|
||||
/**
|
||||
* User ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("userId")
|
||||
val userId: String,
|
||||
|
||||
/**
|
||||
* Session expiration date in Unix timestamp.
|
||||
*
|
||||
*/
|
||||
@SerializedName("expire")
|
||||
val expire: Long,
|
||||
|
||||
/**
|
||||
* Session Provider.
|
||||
*
|
||||
*/
|
||||
@SerializedName("provider")
|
||||
val provider: String,
|
||||
|
||||
/**
|
||||
* Session Provider User ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("providerUid")
|
||||
val providerUid: String,
|
||||
|
||||
/**
|
||||
* Session Provider Token.
|
||||
* Session Provider Access Token.
|
||||
*
|
||||
*/
|
||||
val providerToken: String,
|
||||
@SerializedName("providerAccessToken")
|
||||
val providerAccessToken: String,
|
||||
|
||||
/**
|
||||
* Date, the Unix timestamp of when the access token expires.
|
||||
*
|
||||
*/
|
||||
@SerializedName("providerAccessTokenExpiry")
|
||||
val providerAccessTokenExpiry: Long,
|
||||
|
||||
/**
|
||||
* Session Provider Refresh Token.
|
||||
*
|
||||
*/
|
||||
@SerializedName("providerRefreshToken")
|
||||
val providerRefreshToken: String,
|
||||
|
||||
/**
|
||||
* IP in use when the session was created.
|
||||
*
|
||||
*/
|
||||
@SerializedName("ip")
|
||||
val ip: String,
|
||||
|
||||
/**
|
||||
* Operating system code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/os.json).
|
||||
*
|
||||
*/
|
||||
@SerializedName("osCode")
|
||||
val osCode: String,
|
||||
|
||||
/**
|
||||
* Operating system name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("osName")
|
||||
val osName: String,
|
||||
|
||||
/**
|
||||
* Operating system version.
|
||||
*
|
||||
*/
|
||||
@SerializedName("osVersion")
|
||||
val osVersion: String,
|
||||
|
||||
/**
|
||||
* Client type.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientType")
|
||||
val clientType: String,
|
||||
|
||||
/**
|
||||
* Client code name. View list of [available options](https://github.com/appwrite/appwrite/blob/master/docs/lists/clients.json).
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientCode")
|
||||
val clientCode: String,
|
||||
|
||||
/**
|
||||
* Client name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientName")
|
||||
val clientName: String,
|
||||
|
||||
/**
|
||||
* Client version.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientVersion")
|
||||
val clientVersion: String,
|
||||
|
||||
/**
|
||||
* Client engine name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientEngine")
|
||||
val clientEngine: String,
|
||||
|
||||
/**
|
||||
* Client engine name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("clientEngineVersion")
|
||||
val clientEngineVersion: String,
|
||||
|
||||
/**
|
||||
* Device name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("deviceName")
|
||||
val deviceName: String,
|
||||
|
||||
/**
|
||||
* Device brand name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("deviceBrand")
|
||||
val deviceBrand: String,
|
||||
|
||||
/**
|
||||
* Device model name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("deviceModel")
|
||||
val deviceModel: String,
|
||||
|
||||
/**
|
||||
* Country two-character ISO 3166-1 alpha code.
|
||||
*
|
||||
*/
|
||||
@SerializedName("countryCode")
|
||||
val countryCode: String,
|
||||
|
||||
/**
|
||||
* Country name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("countryName")
|
||||
val countryName: String,
|
||||
|
||||
/**
|
||||
* Returns true if this the current user session.
|
||||
*
|
||||
*/
|
||||
@SerializedName("current")
|
||||
val current: Boolean
|
||||
) {
|
||||
companion object {
|
||||
@@ -141,10 +179,12 @@ data class Session(
|
||||
fun from(map: Map<String, Any>) = Session(
|
||||
id = map["\$id"] as String,
|
||||
userId = map["userId"] as String,
|
||||
expire = map["expire"] as Long,
|
||||
expire = (map["expire"] as Number).toLong(),
|
||||
provider = map["provider"] as String,
|
||||
providerUid = map["providerUid"] as String,
|
||||
providerToken = map["providerToken"] as String,
|
||||
providerAccessToken = map["providerAccessToken"] as String,
|
||||
providerAccessTokenExpiry = (map["providerAccessTokenExpiry"] as Number).toLong(),
|
||||
providerRefreshToken = map["providerRefreshToken"] as String,
|
||||
ip = map["ip"] as String,
|
||||
osCode = map["osCode"] as String,
|
||||
osName = map["osName"] as String,
|
||||
@@ -170,7 +210,9 @@ data class Session(
|
||||
"expire" to expire as Any,
|
||||
"provider" to provider as Any,
|
||||
"providerUid" to providerUid as Any,
|
||||
"providerToken" to providerToken as Any,
|
||||
"providerAccessToken" to providerAccessToken as Any,
|
||||
"providerAccessTokenExpiry" to providerAccessTokenExpiry as Any,
|
||||
"providerRefreshToken" to providerRefreshToken as Any,
|
||||
"ip" to ip as Any,
|
||||
"osCode" to osCode as Any,
|
||||
"osName" to osName as Any,
|
||||
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Sessions List
|
||||
*/
|
||||
data class SessionList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of sessions documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of sessions.
|
||||
*
|
||||
*/
|
||||
@SerializedName("sessions")
|
||||
val sessions: List<Session>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = SessionList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
sessions = (map["sessions"] as List<Map<String, Any>>).map { Session.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"sessions" to sessions.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Team
|
||||
*/
|
||||
@@ -8,33 +10,37 @@ data class Team(
|
||||
* Team ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$id")
|
||||
val id: String,
|
||||
|
||||
/**
|
||||
* Team name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
|
||||
/**
|
||||
* Team creation date in Unix timestamp.
|
||||
*
|
||||
*/
|
||||
@SerializedName("dateCreated")
|
||||
val dateCreated: Long,
|
||||
|
||||
/**
|
||||
* Total sum of team members.
|
||||
* Total number of team members.
|
||||
*
|
||||
*/
|
||||
val sum: Long
|
||||
@SerializedName("total")
|
||||
val total: Long
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = Team(
|
||||
id = map["\$id"] as String,
|
||||
name = map["name"] as String,
|
||||
dateCreated = map["dateCreated"] as Long,
|
||||
sum = map["sum"] as Long
|
||||
dateCreated = (map["dateCreated"] as Number).toLong(),
|
||||
total = (map["total"] as Number).toLong()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -42,6 +48,6 @@ data class Team(
|
||||
"\$id" to id as Any,
|
||||
"name" to name as Any,
|
||||
"dateCreated" to dateCreated as Any,
|
||||
"sum" to sum as Any
|
||||
"total" to total as Any
|
||||
)
|
||||
}
|
||||
@@ -1,31 +1,35 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Teams List
|
||||
*/
|
||||
data class TeamList(
|
||||
/**
|
||||
* Total number of items available on the server.
|
||||
* Total number of teams documents that matched your query.
|
||||
*
|
||||
*/
|
||||
val sum: Long,
|
||||
@SerializedName("total")
|
||||
val total: Long,
|
||||
|
||||
/**
|
||||
* List of teams.
|
||||
*
|
||||
*/
|
||||
@SerializedName("teams")
|
||||
val teams: List<Team>
|
||||
) {
|
||||
companion object {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(map: Map<String, Any>) = TeamList(
|
||||
sum = map["sum"] as Long,
|
||||
total = (map["total"] as Number).toLong(),
|
||||
teams = (map["teams"] as List<Map<String, Any>>).map { Team.from(map = it) }
|
||||
)
|
||||
}
|
||||
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"sum" to sum as Any,
|
||||
"total" to total as Any,
|
||||
"teams" to teams.map { it.toMap() } as Any
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* Token
|
||||
*/
|
||||
@@ -8,24 +10,28 @@ data class Token(
|
||||
* Token ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$id")
|
||||
val id: String,
|
||||
|
||||
/**
|
||||
* User ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("userId")
|
||||
val userId: String,
|
||||
|
||||
/**
|
||||
* Token secret key. This will return an empty string unless the response is returned using an API key or as part of a webhook payload.
|
||||
*
|
||||
*/
|
||||
@SerializedName("secret")
|
||||
val secret: String,
|
||||
|
||||
/**
|
||||
* Token expiration date in Unix timestamp.
|
||||
*
|
||||
*/
|
||||
@SerializedName("expire")
|
||||
val expire: Long
|
||||
) {
|
||||
companion object {
|
||||
@@ -34,7 +40,7 @@ data class Token(
|
||||
id = map["\$id"] as String,
|
||||
userId = map["userId"] as String,
|
||||
secret = map["secret"] as String,
|
||||
expire = map["expire"] as Long
|
||||
expire = (map["expire"] as Number).toLong()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.appwrite.models
|
||||
|
||||
data class UploadProgress(
|
||||
val id: String,
|
||||
val progress: Double,
|
||||
val sizeUploaded: Long,
|
||||
val chunksTotal: Int,
|
||||
val chunksUploaded: Int
|
||||
)
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.appwrite.models
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
/**
|
||||
* User
|
||||
*/
|
||||
@@ -8,48 +10,56 @@ data class User(
|
||||
* User ID.
|
||||
*
|
||||
*/
|
||||
@SerializedName("\$id")
|
||||
val id: String,
|
||||
|
||||
/**
|
||||
* User name.
|
||||
*
|
||||
*/
|
||||
@SerializedName("name")
|
||||
val name: String,
|
||||
|
||||
/**
|
||||
* User registration date in Unix timestamp.
|
||||
*
|
||||
*/
|
||||
@SerializedName("registration")
|
||||
val registration: Long,
|
||||
|
||||
/**
|
||||
* User status. Pass `true` for enabled and `false` for disabled.
|
||||
*
|
||||
*/
|
||||
@SerializedName("status")
|
||||
val status: Boolean,
|
||||
|
||||
/**
|
||||
* Unix timestamp of the most recent password update
|
||||
*
|
||||
*/
|
||||
@SerializedName("passwordUpdate")
|
||||
val passwordUpdate: Long,
|
||||
|
||||
/**
|
||||
* User email address.
|
||||
*
|
||||
*/
|
||||
@SerializedName("email")
|
||||
val email: String,
|
||||
|
||||
/**
|
||||
* Email verification status.
|
||||
*
|
||||
*/
|
||||
@SerializedName("emailVerification")
|
||||
val emailVerification: Boolean,
|
||||
|
||||
/**
|
||||
* User preferences as a key-value object
|
||||
*
|
||||
*/
|
||||
@SerializedName("prefs")
|
||||
val prefs: Preferences
|
||||
) {
|
||||
companion object {
|
||||
@@ -57,9 +67,9 @@ data class User(
|
||||
fun from(map: Map<String, Any>) = User(
|
||||
id = map["\$id"] as String,
|
||||
name = map["name"] as String,
|
||||
registration = map["registration"] as Long,
|
||||
registration = (map["registration"] as Number).toLong(),
|
||||
status = map["status"] as Boolean,
|
||||
passwordUpdate = map["passwordUpdate"] as Long,
|
||||
passwordUpdate = (map["passwordUpdate"] as Number).toLong(),
|
||||
email = map["email"] as String,
|
||||
emailVerification = map["emailVerification"] as Boolean,
|
||||
prefs = Preferences.from(map = map["prefs"] as Map<String, Any>)
|
||||
|
||||
@@ -25,12 +25,12 @@ class Account(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun get(): io.appwrite.models.User {
|
||||
val path = "/account"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
io.appwrite.models.User.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -39,7 +39,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.User::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ class Account(client: Client) : Service(client) {
|
||||
* login to their new account, you need to create a new [account
|
||||
* session](/docs/client/account#accountCreateSession).
|
||||
*
|
||||
* @param userId Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @param userId Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @param email User email.
|
||||
* @param password User password. Must be between 6 to 32 chars.
|
||||
* @param password User password. Must be at least 8 chars.
|
||||
* @param name User name. Max length: 128 chars.
|
||||
* @return [io.appwrite.models.User]
|
||||
*/
|
||||
@@ -68,16 +68,16 @@ class Account(client: Client) : Service(client) {
|
||||
name: String? = null
|
||||
): io.appwrite.models.User {
|
||||
val path = "/account"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"userId" to userId,
|
||||
"email" to email,
|
||||
"password" to password,
|
||||
"name" to name
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
io.appwrite.models.User.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -86,36 +86,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.User::class.java,
|
||||
convert = convert
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Account
|
||||
*
|
||||
* Delete a currently logged in user account. Behind the scene, the user
|
||||
* record is not deleted but permanently blocked from any access. This is done
|
||||
* to avoid deleted accounts being overtaken by new users with the same email
|
||||
* address. Any user-related resources like documents or storage files should
|
||||
* be deleted separately.
|
||||
*
|
||||
* @return [Any]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun delete(): Any {
|
||||
val path = "/account"
|
||||
val params = mapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
return client.call(
|
||||
"DELETE",
|
||||
path,
|
||||
headers,
|
||||
params,
|
||||
responseType = Any::class.java,
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -123,14 +94,16 @@ class Account(client: Client) : Service(client) {
|
||||
* Update Account Email
|
||||
*
|
||||
* Update currently logged in user account email address. After changing user
|
||||
* address, user confirmation status is being reset and a new confirmation
|
||||
* mail is sent. For security measures, user password is required to complete
|
||||
* this request.
|
||||
* address, the user confirmation status will get reset. A new confirmation
|
||||
* email is not sent automatically however you can use the send confirmation
|
||||
* email endpoint again to send the confirmation email. For security measures,
|
||||
* user password is required to complete this request.
|
||||
* This endpoint can also be used to convert an anonymous account to a normal
|
||||
* one, by passing an email address and a new password.
|
||||
*
|
||||
*
|
||||
* @param email User email.
|
||||
* @param password User password. Must be between 6 to 32 chars.
|
||||
* @param password User password. Must be at least 8 chars.
|
||||
* @return [io.appwrite.models.User]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -140,14 +113,14 @@ class Account(client: Client) : Service(client) {
|
||||
password: String
|
||||
): io.appwrite.models.User {
|
||||
val path = "/account/email"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"email" to email,
|
||||
"password" to password
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
io.appwrite.models.User.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -156,7 +129,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.User::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -175,12 +148,12 @@ class Account(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun createJWT(): io.appwrite.models.Jwt {
|
||||
val path = "/account/jwt"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Jwt = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Jwt = {
|
||||
io.appwrite.models.Jwt.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -189,7 +162,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Jwt::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -199,8 +172,8 @@ class Account(client: Client) : Service(client) {
|
||||
* Get currently logged in user list of latest security activity logs. Each
|
||||
* log returns user IP address, location and date and time of log.
|
||||
*
|
||||
* @param limit Maximum number of logs to return in response. Use this value to manage pagination. 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.
|
||||
* @param limit Maximum number of logs 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)
|
||||
* @return [io.appwrite.models.LogList]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -210,14 +183,14 @@ class Account(client: Client) : Service(client) {
|
||||
offset: Long? = null
|
||||
): io.appwrite.models.LogList {
|
||||
val path = "/account/logs"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"limit" to limit,
|
||||
"offset" to offset
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.LogList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.LogList = {
|
||||
io.appwrite.models.LogList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -226,7 +199,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.LogList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -244,13 +217,13 @@ class Account(client: Client) : Service(client) {
|
||||
name: String
|
||||
): io.appwrite.models.User {
|
||||
val path = "/account/name"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"name" to name
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
io.appwrite.models.User.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -259,7 +232,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.User::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -268,10 +241,10 @@ class Account(client: Client) : Service(client) {
|
||||
*
|
||||
* Update currently logged in user password. For validation, user is required
|
||||
* to pass in the new password, and the old password. For users created with
|
||||
* OAuth and Team Invites, oldPassword is optional.
|
||||
* OAuth, Team Invites and Magic URL, oldPassword is optional.
|
||||
*
|
||||
* @param password New user password. Must be between 6 to 32 chars.
|
||||
* @param oldPassword Old user password. Must be between 6 to 32 chars.
|
||||
* @param password New user password. Must be at least 8 chars.
|
||||
* @param oldPassword Current user password. Must be at least 8 chars.
|
||||
* @return [io.appwrite.models.User]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -281,14 +254,14 @@ class Account(client: Client) : Service(client) {
|
||||
oldPassword: String? = null
|
||||
): io.appwrite.models.User {
|
||||
val path = "/account/password"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"password" to password,
|
||||
"oldPassword" to oldPassword
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
io.appwrite.models.User.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -297,7 +270,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.User::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -312,12 +285,12 @@ class Account(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getPrefs(): io.appwrite.models.Preferences {
|
||||
val path = "/account/prefs"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Preferences = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Preferences = {
|
||||
io.appwrite.models.Preferences.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -326,15 +299,16 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Preferences::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Account Preferences
|
||||
*
|
||||
* Update currently logged in user account preferences. You can pass only the
|
||||
* specific settings you wish to update.
|
||||
* Update currently logged in user account preferences. The object you pass is
|
||||
* stored as is, and replaces any previous value. The maximum allowed prefs
|
||||
* size is 64kB and throws error if exceeded.
|
||||
*
|
||||
* @param prefs Prefs key-value JSON object.
|
||||
* @return [io.appwrite.models.User]
|
||||
@@ -345,13 +319,13 @@ class Account(client: Client) : Service(client) {
|
||||
prefs: Any
|
||||
): io.appwrite.models.User {
|
||||
val path = "/account/prefs"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"prefs" to prefs
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.User = {
|
||||
io.appwrite.models.User.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -360,7 +334,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.User::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -387,14 +361,14 @@ class Account(client: Client) : Service(client) {
|
||||
url: String
|
||||
): io.appwrite.models.Token {
|
||||
val path = "/account/recovery"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"email" to email,
|
||||
"url" to url
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
io.appwrite.models.Token.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -403,7 +377,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Token::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -420,10 +394,10 @@ class Account(client: Client) : Service(client) {
|
||||
* the only valid redirect URLs are the ones from domains you have set when
|
||||
* adding your platforms in the console interface.
|
||||
*
|
||||
* @param userId User account UID address.
|
||||
* @param userId User ID.
|
||||
* @param secret Valid reset token.
|
||||
* @param password New password. Must be between 6 to 32 chars.
|
||||
* @param passwordAgain New password again. Must be between 6 to 32 chars.
|
||||
* @param password New user password. Must be at least 8 chars.
|
||||
* @param passwordAgain Repeat new user password. Must be at least 8 chars.
|
||||
* @return [io.appwrite.models.Token]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -435,16 +409,16 @@ class Account(client: Client) : Service(client) {
|
||||
passwordAgain: String
|
||||
): io.appwrite.models.Token {
|
||||
val path = "/account/recovery"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"userId" to userId,
|
||||
"secret" to secret,
|
||||
"password" to password,
|
||||
"passwordAgain" to passwordAgain
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
io.appwrite.models.Token.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -453,7 +427,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Token::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -469,12 +443,12 @@ class Account(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getSessions(): io.appwrite.models.SessionList {
|
||||
val path = "/account/sessions"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.SessionList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.SessionList = {
|
||||
io.appwrite.models.SessionList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -483,7 +457,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.SessionList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -494,7 +468,7 @@ class Account(client: Client) : Service(client) {
|
||||
* password combination. This route will create a new session for the user.
|
||||
*
|
||||
* @param email User email.
|
||||
* @param password User password. Must be between 6 to 32 chars.
|
||||
* @param password User password. Must be at least 8 chars.
|
||||
* @return [io.appwrite.models.Session]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -504,14 +478,14 @@ class Account(client: Client) : Service(client) {
|
||||
password: String
|
||||
): io.appwrite.models.Session {
|
||||
val path = "/account/sessions"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"email" to email,
|
||||
"password" to password
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Session = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Session = {
|
||||
io.appwrite.models.Session.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -520,7 +494,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Session::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -536,9 +510,9 @@ class Account(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun deleteSessions(): Any {
|
||||
val path = "/account/sessions"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
return client.call(
|
||||
@@ -566,12 +540,12 @@ class Account(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun createAnonymousSession(): io.appwrite.models.Session {
|
||||
val path = "/account/sessions/anonymous"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Session = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Session = {
|
||||
io.appwrite.models.Session.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -580,7 +554,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Session::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -598,7 +572,7 @@ class Account(client: Client) : Service(client) {
|
||||
* the URL parameter empty, so that the login completion will be handled by
|
||||
* your Appwrite instance by default.
|
||||
*
|
||||
* @param userId Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @param userId Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @param email User email.
|
||||
* @param url URL to redirect the user back to your app from the magic URL login. 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.
|
||||
* @return [io.appwrite.models.Token]
|
||||
@@ -611,15 +585,15 @@ class Account(client: Client) : Service(client) {
|
||||
url: String? = null
|
||||
): io.appwrite.models.Token {
|
||||
val path = "/account/sessions/magic-url"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"userId" to userId,
|
||||
"email" to email,
|
||||
"url" to url
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
io.appwrite.models.Token.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -628,7 +602,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Token::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -647,7 +621,7 @@ class Account(client: Client) : Service(client) {
|
||||
* the only valid redirect URLs are the ones from domains you have set when
|
||||
* adding your platforms in the console interface.
|
||||
*
|
||||
* @param userId User unique ID.
|
||||
* @param userId User ID.
|
||||
* @param secret Valid verification token.
|
||||
* @return [io.appwrite.models.Session]
|
||||
*/
|
||||
@@ -658,14 +632,14 @@ class Account(client: Client) : Service(client) {
|
||||
secret: String
|
||||
): io.appwrite.models.Session {
|
||||
val path = "/account/sessions/magic-url"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"userId" to userId,
|
||||
"secret" to secret
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Session = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Session = {
|
||||
io.appwrite.models.Session.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -674,7 +648,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Session::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -694,10 +668,10 @@ class Account(client: Client) : Service(client) {
|
||||
* user..
|
||||
*
|
||||
*
|
||||
* @param provider OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yandex, wordpress.
|
||||
* @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 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.
|
||||
* @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.
|
||||
*
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -710,7 +684,7 @@ class Account(client: Client) : Service(client) {
|
||||
scopes: List<Any>? = null
|
||||
) {
|
||||
val path = "/account/sessions/oauth2/{provider}".replace("{provider}", provider)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"success" to success,
|
||||
"failure" to failure,
|
||||
"scopes" to scopes,
|
||||
@@ -766,7 +740,7 @@ class Account(client: Client) : Service(client) {
|
||||
* Use this endpoint to get a logged in user's session using a Session ID.
|
||||
* Inputting 'current' will return the current session being used.
|
||||
*
|
||||
* @param sessionId Session unique ID. Use the string 'current' to get the current device session.
|
||||
* @param sessionId Session ID. Use the string 'current' to get the current device session.
|
||||
* @return [io.appwrite.models.Session]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -775,12 +749,12 @@ class Account(client: Client) : Service(client) {
|
||||
sessionId: String
|
||||
): io.appwrite.models.Session {
|
||||
val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Session = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Session = {
|
||||
io.appwrite.models.Session.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -789,7 +763,41 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Session::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Session (Refresh Tokens)
|
||||
*
|
||||
* Access tokens have limited lifespan and expire to mitigate security risks.
|
||||
* If session was created using an OAuth provider, this route can be used to
|
||||
* "refresh" the access token.
|
||||
*
|
||||
* @param sessionId Session ID. Use the string 'current' to update the current device session.
|
||||
* @return [io.appwrite.models.Session]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun updateSession(
|
||||
sessionId: String
|
||||
): io.appwrite.models.Session {
|
||||
val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
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(
|
||||
"PATCH",
|
||||
path,
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Session::class.java,
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -798,9 +806,10 @@ class Account(client: Client) : Service(client) {
|
||||
*
|
||||
* Use this endpoint to log out the currently logged in user from all their
|
||||
* account sessions across all of their different devices. When using the
|
||||
* option id argument, only the session unique ID provider will be deleted.
|
||||
* Session ID argument, only the unique session ID provided is deleted.
|
||||
*
|
||||
*
|
||||
* @param sessionId Session unique ID. Use the string 'current' to delete the current device session.
|
||||
* @param sessionId Session ID. Use the string 'current' to delete the current device session.
|
||||
* @return [Any]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -809,9 +818,9 @@ class Account(client: Client) : Service(client) {
|
||||
sessionId: String
|
||||
): Any {
|
||||
val path = "/account/sessions/{sessionId}".replace("{sessionId}", sessionId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
return client.call(
|
||||
@@ -823,6 +832,37 @@ class Account(client: Client) : Service(client) {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Account Status
|
||||
*
|
||||
* Block the currently logged in user account. Behind the scene, the user
|
||||
* record is not deleted but permanently blocked from any access. To
|
||||
* completely delete a user, use the Users API instead.
|
||||
*
|
||||
* @return [io.appwrite.models.User]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun updateStatus(): io.appwrite.models.User {
|
||||
val path = "/account/status"
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
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,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Email Verification
|
||||
*
|
||||
@@ -851,13 +891,13 @@ class Account(client: Client) : Service(client) {
|
||||
url: String
|
||||
): io.appwrite.models.Token {
|
||||
val path = "/account/verification"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"url" to url
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
io.appwrite.models.Token.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -866,7 +906,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Token::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -878,7 +918,7 @@ class Account(client: Client) : Service(client) {
|
||||
* to verify the user email ownership. If confirmed this route will return a
|
||||
* 200 status code.
|
||||
*
|
||||
* @param userId User unique ID.
|
||||
* @param userId User ID.
|
||||
* @param secret Valid verification token.
|
||||
* @return [io.appwrite.models.Token]
|
||||
*/
|
||||
@@ -889,14 +929,14 @@ class Account(client: Client) : Service(client) {
|
||||
secret: String
|
||||
): io.appwrite.models.Token {
|
||||
val path = "/account/verification"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"userId" to userId,
|
||||
"secret" to secret
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Token = {
|
||||
io.appwrite.models.Token.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -905,7 +945,7 @@ class Account(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Token::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,14 @@ class Avatars(client: Client) : Service(client) {
|
||||
* Get Browser Icon
|
||||
*
|
||||
* You can use this endpoint to show different browser icons to your users.
|
||||
* The code argument receives the browser code as it appears in your user
|
||||
* /account/sessions endpoint. Use width, height and quality arguments to
|
||||
* change the output settings.
|
||||
* The code argument receives the browser code as it appears in your user [GET
|
||||
* /account/sessions](/docs/client/account#accountGetSessions) endpoint. 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 Browser Code.
|
||||
* @param width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
||||
@@ -35,7 +40,7 @@ class Avatars(client: Client) : Service(client) {
|
||||
quality: Long? = null
|
||||
): ByteArray {
|
||||
val path = "/avatars/browsers/{code}".replace("{code}", code)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"width" to width,
|
||||
"height" to height,
|
||||
"quality" to quality,
|
||||
@@ -55,6 +60,12 @@ 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 width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
||||
@@ -71,7 +82,7 @@ class Avatars(client: Client) : Service(client) {
|
||||
quality: Long? = null
|
||||
): ByteArray {
|
||||
val path = "/avatars/credit-cards/{code}".replace("{code}", code)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"width" to width,
|
||||
"height" to height,
|
||||
"quality" to quality,
|
||||
@@ -101,7 +112,7 @@ class Avatars(client: Client) : Service(client) {
|
||||
url: String
|
||||
): ByteArray {
|
||||
val path = "/avatars/favicon"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"url" to url,
|
||||
"project" to client.config["project"]
|
||||
)
|
||||
@@ -119,6 +130,12 @@ class Avatars(client: Client) : Service(client) {
|
||||
* You can use this endpoint to show different country flags icons to your
|
||||
* users. The code argument receives the 2 letter country code. 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 Country Code. ISO Alpha-2 country code format.
|
||||
* @param width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
||||
@@ -135,7 +152,7 @@ class Avatars(client: Client) : Service(client) {
|
||||
quality: Long? = null
|
||||
): ByteArray {
|
||||
val path = "/avatars/flags/{code}".replace("{code}", code)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"width" to width,
|
||||
"height" to height,
|
||||
"quality" to quality,
|
||||
@@ -156,10 +173,16 @@ class Avatars(client: Client) : Service(client) {
|
||||
* you want. This endpoint is very useful if you need to crop and display
|
||||
* remote images in your app or in case you want to make sure a 3rd party
|
||||
* image is properly served using a TLS protocol.
|
||||
*
|
||||
* 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 400x400px.
|
||||
*
|
||||
*
|
||||
* @param url Image URL which you want to crop.
|
||||
* @param width Resize preview image width, Pass an integer between 0 to 2000.
|
||||
* @param height Resize preview image height, Pass an integer between 0 to 2000.
|
||||
* @param width Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400.
|
||||
* @param height Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400.
|
||||
* @return [ByteArray]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -170,7 +193,7 @@ class Avatars(client: Client) : Service(client) {
|
||||
height: Long? = null
|
||||
): ByteArray {
|
||||
val path = "/avatars/image"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"url" to url,
|
||||
"width" to width,
|
||||
"height" to height,
|
||||
@@ -197,6 +220,12 @@ class Avatars(client: Client) : Service(client) {
|
||||
* default, a random theme will be selected. The random theme will persist for
|
||||
* the user's initials when reloading the same theme will always return for
|
||||
* the same initials.
|
||||
*
|
||||
* 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 name Full Name. When empty, current user name or email will be used. Max length: 128 chars.
|
||||
* @param width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
||||
@@ -215,7 +244,7 @@ class Avatars(client: Client) : Service(client) {
|
||||
background: String? = null
|
||||
): ByteArray {
|
||||
val path = "/avatars/initials"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"name" to name,
|
||||
"width" to width,
|
||||
"height" to height,
|
||||
@@ -236,9 +265,10 @@ class Avatars(client: Client) : Service(client) {
|
||||
*
|
||||
* Converts a given plain text to a QR code image. You can use the query
|
||||
* parameters to change the size and style of the resulting image.
|
||||
*
|
||||
*
|
||||
* @param text Plain text to be converted to QR code image.
|
||||
* @param size QR code size. Pass an integer between 0 to 1000. Defaults to 400.
|
||||
* @param size QR code size. Pass an integer between 1 to 1000. Defaults to 400.
|
||||
* @param margin Margin from edge. Pass an integer between 0 to 10. Defaults to 1.
|
||||
* @param download Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.
|
||||
* @return [ByteArray]
|
||||
@@ -252,7 +282,7 @@ class Avatars(client: Client) : Service(client) {
|
||||
download: Boolean? = null
|
||||
): ByteArray {
|
||||
val path = "/avatars/qr"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"text" to text,
|
||||
"size" to size,
|
||||
"margin" to margin,
|
||||
|
||||
@@ -18,14 +18,14 @@ class Database(client: Client) : Service(client) {
|
||||
* of the project's documents. [Learn more about different API
|
||||
* modes](/docs/admin).
|
||||
*
|
||||
* @param collectionId Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection).
|
||||
* @param queries Array of query strings.
|
||||
* @param limit Maximum number of documents to return in response. Use this value to manage pagination. 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.
|
||||
* @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.
|
||||
* @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 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.
|
||||
* @param orderTypes Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order.
|
||||
* @param orderAttributes Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 128 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]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -41,7 +41,7 @@ class Database(client: Client) : Service(client) {
|
||||
orderTypes: List<Any>? = null
|
||||
): io.appwrite.models.DocumentList {
|
||||
val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"queries" to queries,
|
||||
"limit" to limit,
|
||||
"offset" to offset,
|
||||
@@ -50,10 +50,10 @@ class Database(client: Client) : Service(client) {
|
||||
"orderAttributes" to orderAttributes,
|
||||
"orderTypes" to orderTypes
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.DocumentList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.DocumentList = {
|
||||
io.appwrite.models.DocumentList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -62,7 +62,7 @@ class Database(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.DocumentList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ class Database(client: Client) : Service(client) {
|
||||
* integration](/docs/server/database#databaseCreateCollection) API or
|
||||
* directly from your database console.
|
||||
*
|
||||
* @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).
|
||||
* @param documentId Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @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 "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @param data Document data as JSON object.
|
||||
* @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
||||
* @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
||||
* @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
||||
* @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
||||
* @return [io.appwrite.models.Document]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -91,16 +91,16 @@ class Database(client: Client) : Service(client) {
|
||||
write: List<Any>? = null
|
||||
): io.appwrite.models.Document {
|
||||
val path = "/database/collections/{collectionId}/documents".replace("{collectionId}", collectionId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"documentId" to documentId,
|
||||
"data" to data,
|
||||
"read" to read,
|
||||
"write" to write
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Document = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Document = {
|
||||
io.appwrite.models.Document.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -109,7 +109,7 @@ class Database(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Document::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ class Database(client: Client) : Service(client) {
|
||||
* Get a document by its unique ID. This endpoint response returns a JSON
|
||||
* object with the document data.
|
||||
*
|
||||
* @param collectionId Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection).
|
||||
* @param documentId Document 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 [io.appwrite.models.Document]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -130,12 +130,12 @@ class Database(client: Client) : Service(client) {
|
||||
documentId: String
|
||||
): io.appwrite.models.Document {
|
||||
val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Document = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Document = {
|
||||
io.appwrite.models.Document.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -144,7 +144,7 @@ class Database(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Document::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -154,11 +154,11 @@ class Database(client: Client) : Service(client) {
|
||||
* Update a document by its unique ID. Using the patch method you can pass
|
||||
* only specific fields that will get updated.
|
||||
*
|
||||
* @param collectionId Collection unique ID. You can create a new collection with validation rules using the Database service [server integration](/docs/server/database#createCollection).
|
||||
* @param documentId Document unique ID.
|
||||
* @param data Document data as JSON object.
|
||||
* @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
||||
* @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
||||
* @param collectionId Collection ID.
|
||||
* @param documentId Document ID.
|
||||
* @param data Document data as JSON object. Include only attribute and value pairs to be updated.
|
||||
* @param read An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
||||
* @param write An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
||||
* @return [io.appwrite.models.Document]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -171,15 +171,15 @@ class Database(client: Client) : Service(client) {
|
||||
write: List<Any>? = null
|
||||
): io.appwrite.models.Document {
|
||||
val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"data" to data,
|
||||
"read" to read,
|
||||
"write" to write
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Document = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Document = {
|
||||
io.appwrite.models.Document.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -188,19 +188,17 @@ class Database(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Document::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Document
|
||||
*
|
||||
* Delete a document by its unique ID. This endpoint deletes only the parent
|
||||
* documents, its attributes and relations to other documents. Child documents
|
||||
* **will not** be deleted.
|
||||
* Delete a document by its unique ID.
|
||||
*
|
||||
* @param collectionId Collection unique ID. You can create a new collection using the Database service [server integration](/docs/server/database#createCollection).
|
||||
* @param documentId Document 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]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -210,9 +208,9 @@ class Database(client: Client) : Service(client) {
|
||||
documentId: String
|
||||
): Any {
|
||||
val path = "/database/collections/{collectionId}/documents/{documentId}".replace("{collectionId}", collectionId).replace("{documentId}", documentId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
return client.call(
|
||||
|
||||
@@ -10,6 +10,36 @@ import java.io.File
|
||||
|
||||
class Functions(client: Client) : Service(client) {
|
||||
|
||||
/**
|
||||
* Retry Build
|
||||
*
|
||||
* @param functionId Function ID.
|
||||
* @param deploymentId Deployment ID.
|
||||
* @param buildId Build unique ID.
|
||||
* @return [Any]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun retryBuild(
|
||||
functionId: String,
|
||||
deploymentId: String,
|
||||
buildId: String
|
||||
): Any {
|
||||
val path = "/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}".replace("{functionId}", functionId).replace("{deploymentId}", deploymentId).replace("{buildId}", buildId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
return client.call(
|
||||
"POST",
|
||||
path,
|
||||
headers,
|
||||
params,
|
||||
responseType = Any::class.java,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* List Executions
|
||||
*
|
||||
@@ -18,11 +48,11 @@ class Functions(client: Client) : Service(client) {
|
||||
* return a list of all of the project's executions. [Learn more about
|
||||
* different API modes](/docs/admin).
|
||||
*
|
||||
* @param functionId Function unique ID.
|
||||
* @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.
|
||||
* @param offset Results offset. The default value is 0. Use this param to manage pagination.
|
||||
* @param functionId Function ID.
|
||||
* @param limit Maximum number of executions 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 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.
|
||||
* @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.
|
||||
* @return [io.appwrite.models.ExecutionList]
|
||||
*/
|
||||
@@ -37,17 +67,17 @@ class Functions(client: Client) : Service(client) {
|
||||
cursorDirection: String? = null
|
||||
): io.appwrite.models.ExecutionList {
|
||||
val path = "/functions/{functionId}/executions".replace("{functionId}", functionId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"limit" to limit,
|
||||
"offset" to offset,
|
||||
"search" to search,
|
||||
"cursor" to cursor,
|
||||
"cursorDirection" to cursorDirection
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.ExecutionList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.ExecutionList = {
|
||||
io.appwrite.models.ExecutionList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -56,7 +86,7 @@ class Functions(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.ExecutionList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -68,24 +98,27 @@ class Functions(client: Client) : Service(client) {
|
||||
* updates on the current execution status. Once this endpoint is called, your
|
||||
* function execution process will start asynchronously.
|
||||
*
|
||||
* @param functionId Function unique ID.
|
||||
* @param functionId Function ID.
|
||||
* @param data String of custom data to send to function.
|
||||
* @param async Execute code asynchronously. Default value is true.
|
||||
* @return [io.appwrite.models.Execution]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun createExecution(
|
||||
functionId: String,
|
||||
data: String? = null
|
||||
data: String? = null,
|
||||
async: Boolean? = null
|
||||
): io.appwrite.models.Execution {
|
||||
val path = "/functions/{functionId}/executions".replace("{functionId}", functionId)
|
||||
val params = mapOf<String, Any?>(
|
||||
"data" to data
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"data" to data,
|
||||
"async" to async
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Execution = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Execution = {
|
||||
io.appwrite.models.Execution.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -94,7 +127,7 @@ class Functions(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Execution::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -103,8 +136,8 @@ class Functions(client: Client) : Service(client) {
|
||||
*
|
||||
* Get a function execution log by its unique ID.
|
||||
*
|
||||
* @param functionId Function unique ID.
|
||||
* @param executionId Execution unique ID.
|
||||
* @param functionId Function ID.
|
||||
* @param executionId Execution ID.
|
||||
* @return [io.appwrite.models.Execution]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -114,12 +147,12 @@ class Functions(client: Client) : Service(client) {
|
||||
executionId: String
|
||||
): io.appwrite.models.Execution {
|
||||
val path = "/functions/{functionId}/executions/{executionId}".replace("{functionId}", functionId).replace("{executionId}", executionId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Execution = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Execution = {
|
||||
io.appwrite.models.Execution.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -128,7 +161,7 @@ class Functions(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Execution::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ class Locale(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun get(): io.appwrite.models.Locale {
|
||||
val path = "/locale"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Locale = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Locale = {
|
||||
io.appwrite.models.Locale.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -40,7 +40,7 @@ class Locale(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Locale::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -56,12 +56,12 @@ class Locale(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getContinents(): io.appwrite.models.ContinentList {
|
||||
val path = "/locale/continents"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.ContinentList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.ContinentList = {
|
||||
io.appwrite.models.ContinentList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -70,7 +70,7 @@ class Locale(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.ContinentList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ class Locale(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getCountries(): io.appwrite.models.CountryList {
|
||||
val path = "/locale/countries"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.CountryList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.CountryList = {
|
||||
io.appwrite.models.CountryList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -100,7 +100,7 @@ class Locale(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.CountryList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -116,12 +116,12 @@ class Locale(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getCountriesEU(): io.appwrite.models.CountryList {
|
||||
val path = "/locale/countries/eu"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.CountryList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.CountryList = {
|
||||
io.appwrite.models.CountryList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -130,7 +130,7 @@ class Locale(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.CountryList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -146,12 +146,12 @@ class Locale(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getCountriesPhones(): io.appwrite.models.PhoneList {
|
||||
val path = "/locale/countries/phones"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.PhoneList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.PhoneList = {
|
||||
io.appwrite.models.PhoneList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -160,7 +160,7 @@ class Locale(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.PhoneList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -177,12 +177,12 @@ class Locale(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getCurrencies(): io.appwrite.models.CurrencyList {
|
||||
val path = "/locale/currencies"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.CurrencyList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.CurrencyList = {
|
||||
io.appwrite.models.CurrencyList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -191,7 +191,7 @@ class Locale(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.CurrencyList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -207,12 +207,12 @@ class Locale(client: Client) : Service(client) {
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getLanguages(): io.appwrite.models.LanguageList {
|
||||
val path = "/locale/languages"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.LanguageList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.LanguageList = {
|
||||
io.appwrite.models.LanguageList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -221,7 +221,7 @@ class Locale(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.LanguageList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,11 @@ class Storage(client: Client) : Service(client) {
|
||||
* your results. On admin mode, this endpoint will return a list of all of the
|
||||
* project's files. [Learn more about different API modes](/docs/admin).
|
||||
*
|
||||
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
||||
* @param search Search term to filter your list results. Max length: 256 chars.
|
||||
* @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.
|
||||
* @param offset Results offset. The default value is 0. Use this param to manage 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.
|
||||
* @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 orderType Order result by ASC or DESC order.
|
||||
* @return [io.appwrite.models.FileList]
|
||||
@@ -30,6 +31,7 @@ class Storage(client: Client) : Service(client) {
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun listFiles(
|
||||
bucketId: String,
|
||||
search: String? = null,
|
||||
limit: Long? = null,
|
||||
offset: Long? = null,
|
||||
@@ -37,8 +39,8 @@ class Storage(client: Client) : Service(client) {
|
||||
cursorDirection: String? = null,
|
||||
orderType: String? = null
|
||||
): io.appwrite.models.FileList {
|
||||
val path = "/storage/files"
|
||||
val params = mapOf<String, Any?>(
|
||||
val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"search" to search,
|
||||
"limit" to limit,
|
||||
"offset" to offset,
|
||||
@@ -46,10 +48,10 @@ class Storage(client: Client) : Service(client) {
|
||||
"cursorDirection" to cursorDirection,
|
||||
"orderType" to orderType
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.FileList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.FileList = {
|
||||
io.appwrite.models.FileList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -58,51 +60,72 @@ class Storage(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.FileList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create File
|
||||
*
|
||||
* Create a new file. The user who creates the file will automatically be
|
||||
* assigned to read and write access unless he has passed custom values for
|
||||
* read and write arguments.
|
||||
* Create a new file. Before using this route, you should create a new bucket
|
||||
* resource using either a [server
|
||||
* integration](/docs/server/database#storageCreateBucket) API or directly
|
||||
* from your Appwrite console.
|
||||
*
|
||||
* Larger files should be uploaded using multiple requests with the
|
||||
* [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range)
|
||||
* header to send a partial request with a maximum supported chunk of `5MB`.
|
||||
* The `content-range` header values should always be in bytes.
|
||||
*
|
||||
* When the first request is sent, the server will return the **File** object,
|
||||
* and the subsequent part request must include the file's **id** in
|
||||
* `x-appwrite-id` header to allow the server to know that the partial upload
|
||||
* is for the existing file and not for a new one.
|
||||
*
|
||||
* If you're creating a new file using one of the Appwrite SDKs, all the
|
||||
* chunking logic will be managed by the SDK internally.
|
||||
*
|
||||
*
|
||||
* @param fileId Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
||||
* @param fileId File ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @param file Binary file.
|
||||
* @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
||||
* @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
||||
* @param read An array of strings with read permissions. By default only the current user is granted with read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
||||
* @param write An array of strings with write permissions. By default only the current user is granted with write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
||||
* @return [io.appwrite.models.File]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun createFile(
|
||||
bucketId: String,
|
||||
fileId: String,
|
||||
file: File,
|
||||
read: List<Any>? = null,
|
||||
write: List<Any>? = null
|
||||
write: List<Any>? = null, onProgress: ((UploadProgress) -> Unit)? = null
|
||||
): io.appwrite.models.File {
|
||||
val path = "/storage/files"
|
||||
val params = mapOf<String, Any?>(
|
||||
val path = "/storage/buckets/{bucketId}/files".replace("{bucketId}", bucketId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"fileId" to fileId,
|
||||
"file" to file,
|
||||
"read" to read,
|
||||
"write" to write
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "multipart/form-data"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.File = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.File = {
|
||||
io.appwrite.models.File.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
"POST",
|
||||
val idParamName: String? = "fileId"
|
||||
val paramName = "file"
|
||||
return client.chunkedUpload(
|
||||
path,
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.File::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
paramName,
|
||||
idParamName,
|
||||
onProgress,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -112,21 +135,23 @@ class Storage(client: Client) : Service(client) {
|
||||
* Get a file by its unique ID. This endpoint response returns a JSON object
|
||||
* with the file metadata.
|
||||
*
|
||||
* @param fileId File unique ID.
|
||||
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
||||
* @param fileId File ID.
|
||||
* @return [io.appwrite.models.File]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getFile(
|
||||
bucketId: String,
|
||||
fileId: String
|
||||
): io.appwrite.models.File {
|
||||
val path = "/storage/files/{fileId}".replace("{fileId}", fileId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.File = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.File = {
|
||||
io.appwrite.models.File.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -135,7 +160,7 @@ class Storage(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.File::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -145,27 +170,29 @@ class Storage(client: Client) : Service(client) {
|
||||
* Update a file by its unique ID. Only users with write permissions have
|
||||
* access to update this resource.
|
||||
*
|
||||
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
||||
* @param fileId File unique ID.
|
||||
* @param read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
||||
* @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](/docs/permissions) and get a full list of available permissions.
|
||||
* @param read An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
||||
* @param write An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.
|
||||
* @return [io.appwrite.models.File]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun updateFile(
|
||||
bucketId: String,
|
||||
fileId: String,
|
||||
read: List<Any>,
|
||||
write: List<Any>
|
||||
read: List<Any>? = null,
|
||||
write: List<Any>? = null
|
||||
): io.appwrite.models.File {
|
||||
val path = "/storage/files/{fileId}".replace("{fileId}", fileId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"read" to read,
|
||||
"write" to write
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.File = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.File = {
|
||||
io.appwrite.models.File.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -174,7 +201,7 @@ class Storage(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.File::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -184,18 +211,20 @@ class Storage(client: Client) : Service(client) {
|
||||
* Delete a file by its unique ID. Only users with write permissions have
|
||||
* access to delete this resource.
|
||||
*
|
||||
* @param fileId File unique ID.
|
||||
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
||||
* @param fileId File ID.
|
||||
* @return [Any]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun deleteFile(
|
||||
bucketId: String,
|
||||
fileId: String
|
||||
): Any {
|
||||
val path = "/storage/files/{fileId}".replace("{fileId}", fileId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val path = "/storage/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
return client.call(
|
||||
@@ -214,16 +243,18 @@ class Storage(client: Client) : Service(client) {
|
||||
* 'Content-Disposition: attachment' header that tells the browser to start
|
||||
* downloading the file to user downloads directory.
|
||||
*
|
||||
* @param fileId File unique ID.
|
||||
* @param bucketId Storage bucket ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
||||
* @param fileId File ID.
|
||||
* @return [ByteArray]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getFileDownload(
|
||||
bucketId: String,
|
||||
fileId: String
|
||||
): ByteArray {
|
||||
val path = "/storage/files/{fileId}/download".replace("{fileId}", fileId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val path = "/storage/buckets/{bucketId}/files/{fileId}/download".replace("{bucketId}", bucketId).replace("{fileId}", fileId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"project" to client.config["project"]
|
||||
)
|
||||
return client.call(
|
||||
@@ -240,9 +271,11 @@ class Storage(client: Client) : Service(client) {
|
||||
* Get a file preview image. Currently, this method supports preview for image
|
||||
* files (jpg, png, and gif), other supported formats, like pdf, docs, slides,
|
||||
* and spreadsheets, will return the file icon image. You can also pass query
|
||||
* string arguments for cutting and resizing your preview image.
|
||||
* string arguments for cutting and resizing your preview image. Preview is
|
||||
* supported only for image files smaller than 10MB.
|
||||
*
|
||||
* @param fileId File unique ID
|
||||
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
||||
* @param fileId File ID
|
||||
* @param width Resize preview image width, Pass an integer between 0 to 4000.
|
||||
* @param height Resize preview image height, Pass an integer between 0 to 4000.
|
||||
* @param gravity Image crop gravity. Can be one of center,top-left,top,top-right,left,right,bottom-left,bottom,bottom-right
|
||||
@@ -251,7 +284,7 @@ class Storage(client: Client) : Service(client) {
|
||||
* @param borderColor Preview image border color. Use a valid HEX color, no # is needed for prefix.
|
||||
* @param borderRadius Preview image border radius in pixels. Pass an integer between 0 to 4000.
|
||||
* @param opacity Preview image opacity. Only works with images having an alpha channel (like png). Pass a number between 0 to 1.
|
||||
* @param rotation Preview image rotation in degrees. Pass an integer between 0 and 360.
|
||||
* @param rotation Preview image rotation in degrees. Pass an integer between -360 and 360.
|
||||
* @param background Preview image background color. Only works with transparent images (png). Use a valid HEX color, no # is needed for prefix.
|
||||
* @param output Output format type (jpeg, jpg, png, gif and webp).
|
||||
* @return [ByteArray]
|
||||
@@ -259,6 +292,7 @@ class Storage(client: Client) : Service(client) {
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getFilePreview(
|
||||
bucketId: String,
|
||||
fileId: String,
|
||||
width: Long? = null,
|
||||
height: Long? = null,
|
||||
@@ -272,8 +306,8 @@ class Storage(client: Client) : Service(client) {
|
||||
background: String? = null,
|
||||
output: String? = null
|
||||
): ByteArray {
|
||||
val path = "/storage/files/{fileId}/preview".replace("{fileId}", fileId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val path = "/storage/buckets/{bucketId}/files/{fileId}/preview".replace("{bucketId}", bucketId).replace("{fileId}", fileId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"width" to width,
|
||||
"height" to height,
|
||||
"gravity" to gravity,
|
||||
@@ -302,16 +336,18 @@ class Storage(client: Client) : Service(client) {
|
||||
* download method but returns with no 'Content-Disposition: attachment'
|
||||
* header.
|
||||
*
|
||||
* @param fileId File unique ID.
|
||||
* @param bucketId Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).
|
||||
* @param fileId File ID.
|
||||
* @return [ByteArray]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@Throws(AppwriteException::class)
|
||||
suspend fun getFileView(
|
||||
bucketId: String,
|
||||
fileId: String
|
||||
): ByteArray {
|
||||
val path = "/storage/files/{fileId}/view".replace("{fileId}", fileId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val path = "/storage/buckets/{bucketId}/files/{fileId}/view".replace("{bucketId}", bucketId).replace("{fileId}", fileId)
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"project" to client.config["project"]
|
||||
)
|
||||
return client.call(
|
||||
|
||||
@@ -13,15 +13,16 @@ class Teams(client: Client) : Service(client) {
|
||||
/**
|
||||
* List Teams
|
||||
*
|
||||
* Get a list of all the current user teams. 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 teams. [Learn more about different API
|
||||
* modes](/docs/admin).
|
||||
* Get a list of all the teams in which the current user is a member. You can
|
||||
* use the parameters to filter your results.
|
||||
*
|
||||
* In admin mode, this endpoint returns a list of all the teams in the current
|
||||
* project. [Learn more about different API modes](/docs/admin).
|
||||
*
|
||||
* @param search Search term to filter your list results. Max length: 256 chars.
|
||||
* @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.
|
||||
* @param offset Results offset. The default value is 0. Use this param to manage 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.
|
||||
* @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 orderType Order result by ASC or DESC order.
|
||||
* @return [io.appwrite.models.TeamList]
|
||||
@@ -37,7 +38,7 @@ class Teams(client: Client) : Service(client) {
|
||||
orderType: String? = null
|
||||
): io.appwrite.models.TeamList {
|
||||
val path = "/teams"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"search" to search,
|
||||
"limit" to limit,
|
||||
"offset" to offset,
|
||||
@@ -45,10 +46,10 @@ class Teams(client: Client) : Service(client) {
|
||||
"cursorDirection" to cursorDirection,
|
||||
"orderType" to orderType
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.TeamList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.TeamList = {
|
||||
io.appwrite.models.TeamList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -57,7 +58,7 @@ class Teams(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.TeamList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -65,13 +66,12 @@ class Teams(client: Client) : Service(client) {
|
||||
* Create Team
|
||||
*
|
||||
* Create a new team. The user who creates the team will automatically be
|
||||
* assigned as the owner of the team. The team owner can invite new members,
|
||||
* who will be able add new owners and update or delete the team from your
|
||||
* project.
|
||||
* assigned as the owner of the team. Only the users with the owner role can
|
||||
* invite new members, add new owners and delete or update the team.
|
||||
*
|
||||
* @param teamId Unique Id. Choose your own unique ID or pass the string `unique()` to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @param teamId Team ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
|
||||
* @param name Team name. Max length: 128 chars.
|
||||
* @param roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.
|
||||
* @param roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
|
||||
* @return [io.appwrite.models.Team]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -82,15 +82,15 @@ class Teams(client: Client) : Service(client) {
|
||||
roles: List<Any>? = null
|
||||
): io.appwrite.models.Team {
|
||||
val path = "/teams"
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"teamId" to teamId,
|
||||
"name" to name,
|
||||
"roles" to roles
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Team = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Team = {
|
||||
io.appwrite.models.Team.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -99,17 +99,16 @@ class Teams(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Team::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Team
|
||||
*
|
||||
* Get a team by its unique ID. All team members have read access for this
|
||||
* resource.
|
||||
* Get a team by its ID. All team members have read access for this resource.
|
||||
*
|
||||
* @param teamId Team unique ID.
|
||||
* @param teamId Team ID.
|
||||
* @return [io.appwrite.models.Team]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -118,12 +117,12 @@ class Teams(client: Client) : Service(client) {
|
||||
teamId: String
|
||||
): io.appwrite.models.Team {
|
||||
val path = "/teams/{teamId}".replace("{teamId}", teamId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Team = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Team = {
|
||||
io.appwrite.models.Team.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -132,18 +131,18 @@ class Teams(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Team::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Team
|
||||
*
|
||||
* Update a team by its unique ID. Only team owners have write access for this
|
||||
* resource.
|
||||
* Update a team using its ID. Only members with the owner role can update the
|
||||
* team.
|
||||
*
|
||||
* @param teamId Team unique ID.
|
||||
* @param name Team name. Max length: 128 chars.
|
||||
* @param teamId Team ID.
|
||||
* @param name New team name. Max length: 128 chars.
|
||||
* @return [io.appwrite.models.Team]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -153,13 +152,13 @@ class Teams(client: Client) : Service(client) {
|
||||
name: String
|
||||
): io.appwrite.models.Team {
|
||||
val path = "/teams/{teamId}".replace("{teamId}", teamId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"name" to name
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Team = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Team = {
|
||||
io.appwrite.models.Team.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -168,17 +167,17 @@ class Teams(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Team::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Team
|
||||
*
|
||||
* Delete a team by its unique ID. Only team owners have write access for this
|
||||
* resource.
|
||||
* Delete a team using its ID. Only team members with the owner role can
|
||||
* delete the team.
|
||||
*
|
||||
* @param teamId Team unique ID.
|
||||
* @param teamId Team ID.
|
||||
* @return [Any]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -187,9 +186,9 @@ class Teams(client: Client) : Service(client) {
|
||||
teamId: String
|
||||
): Any {
|
||||
val path = "/teams/{teamId}".replace("{teamId}", teamId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
return client.call(
|
||||
@@ -204,14 +203,14 @@ class Teams(client: Client) : Service(client) {
|
||||
/**
|
||||
* Get Team Memberships
|
||||
*
|
||||
* Get a team members by the team unique ID. All team members have read access
|
||||
* for this list of resources.
|
||||
* Use this endpoint to list a team's members using the team's ID. All team
|
||||
* members have read access to this endpoint.
|
||||
*
|
||||
* @param teamId Team unique ID.
|
||||
* @param teamId Team ID.
|
||||
* @param search Search term to filter your list results. Max length: 256 chars.
|
||||
* @param limit Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.
|
||||
* @param offset Results offset. The default value is 0. Use this param to manage 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.
|
||||
* @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 orderType Order result by ASC or DESC order.
|
||||
* @return [io.appwrite.models.MembershipList]
|
||||
@@ -228,7 +227,7 @@ class Teams(client: Client) : Service(client) {
|
||||
orderType: String? = null
|
||||
): io.appwrite.models.MembershipList {
|
||||
val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"search" to search,
|
||||
"limit" to limit,
|
||||
"offset" to offset,
|
||||
@@ -236,10 +235,10 @@ class Teams(client: Client) : Service(client) {
|
||||
"cursorDirection" to cursorDirection,
|
||||
"orderType" to orderType
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.MembershipList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.MembershipList = {
|
||||
io.appwrite.models.MembershipList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -248,35 +247,34 @@ class Teams(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.MembershipList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Team Membership
|
||||
*
|
||||
* Use this endpoint to invite a new member to join your team. If initiated
|
||||
* from Client SDK, an email with a link to join the team will be sent to the
|
||||
* new member's email address if the member doesn't exist in the project it
|
||||
* will be created automatically. If initiated from server side SDKs, new
|
||||
* member will automatically be added to the team.
|
||||
* Invite a new member to join your team. If initiated from the client SDK, an
|
||||
* email with a link to join the team will be sent to the member's email
|
||||
* address and an account will be created for them should they not be signed
|
||||
* up already. If initiated from server-side SDKs, the new member will
|
||||
* automatically be added to the team.
|
||||
*
|
||||
* Use the 'URL' parameter to redirect the user from the invitation email back
|
||||
* Use the 'url' parameter to redirect the user from the invitation email back
|
||||
* to your app. When the user is redirected, use the [Update Team Membership
|
||||
* Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow
|
||||
* the user to accept the invitation to the team. While calling from side
|
||||
* SDKs the redirect url can be empty string.
|
||||
* the user to accept the invitation to the team.
|
||||
*
|
||||
* Please note that in order to avoid a [Redirect
|
||||
* Attacks](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
* Please note that to avoid a [Redirect
|
||||
* Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
|
||||
* the only valid redirect URL's are the once from domains you have set when
|
||||
* added your platforms in the console interface.
|
||||
* adding your platforms in the console interface.
|
||||
*
|
||||
* @param teamId Team unique ID.
|
||||
* @param email New team member email.
|
||||
* @param roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.
|
||||
* @param teamId Team ID.
|
||||
* @param email Email of the new team member.
|
||||
* @param roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
|
||||
* @param url URL to redirect the user back to your app from the invitation email. 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 name New team member name. Max length: 128 chars.
|
||||
* @param name Name of the new team member. Max length: 128 chars.
|
||||
* @return [io.appwrite.models.Membership]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -289,16 +287,16 @@ class Teams(client: Client) : Service(client) {
|
||||
name: String? = null
|
||||
): io.appwrite.models.Membership {
|
||||
val path = "/teams/{teamId}/memberships".replace("{teamId}", teamId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"email" to email,
|
||||
"roles" to roles,
|
||||
"url" to url,
|
||||
"name" to name
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Membership = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Membership = {
|
||||
io.appwrite.models.Membership.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -307,7 +305,7 @@ class Teams(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Membership::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -317,8 +315,8 @@ class Teams(client: Client) : Service(client) {
|
||||
* Get a team member by the membership unique id. All team members have read
|
||||
* access for this resource.
|
||||
*
|
||||
* @param teamId Team unique ID.
|
||||
* @param membershipId membership unique ID.
|
||||
* @param teamId Team ID.
|
||||
* @param membershipId Membership ID.
|
||||
* @return [io.appwrite.models.MembershipList]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -328,12 +326,12 @@ class Teams(client: Client) : Service(client) {
|
||||
membershipId: String
|
||||
): io.appwrite.models.MembershipList {
|
||||
val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.MembershipList = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.MembershipList = {
|
||||
io.appwrite.models.MembershipList.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -342,16 +340,20 @@ class Teams(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.MembershipList::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Membership Roles
|
||||
*
|
||||
* @param teamId Team unique ID.
|
||||
* Modify the roles of a team member. Only team members with the owner role
|
||||
* have access to this endpoint. Learn more about [roles and
|
||||
* permissions](/docs/permissions).
|
||||
*
|
||||
* @param teamId Team ID.
|
||||
* @param membershipId Membership ID.
|
||||
* @param roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Max length for each role is 32 chars.
|
||||
* @param roles An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
|
||||
* @return [io.appwrite.models.Membership]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -362,13 +364,13 @@ class Teams(client: Client) : Service(client) {
|
||||
roles: List<Any>
|
||||
): io.appwrite.models.Membership {
|
||||
val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"roles" to roles
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Membership = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Membership = {
|
||||
io.appwrite.models.Membership.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -377,7 +379,7 @@ class Teams(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Membership::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -388,7 +390,7 @@ class Teams(client: Client) : Service(client) {
|
||||
* the membership of any other team member. You can also use this endpoint to
|
||||
* delete a user membership even if it is not accepted.
|
||||
*
|
||||
* @param teamId Team unique ID.
|
||||
* @param teamId Team ID.
|
||||
* @param membershipId Membership ID.
|
||||
* @return [Any]
|
||||
*/
|
||||
@@ -399,9 +401,9 @@ class Teams(client: Client) : Service(client) {
|
||||
membershipId: String
|
||||
): Any {
|
||||
val path = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
return client.call(
|
||||
@@ -417,12 +419,16 @@ class Teams(client: Client) : Service(client) {
|
||||
* Update Team Membership Status
|
||||
*
|
||||
* Use this endpoint to allow a user to accept an invitation to join a team
|
||||
* after being redirected back to your app from the invitation email recieved
|
||||
* after being redirected back to your app from the invitation email received
|
||||
* by the user.
|
||||
*
|
||||
* If the request is successful, a session for the user is automatically
|
||||
* created.
|
||||
*
|
||||
*
|
||||
* @param teamId Team unique ID.
|
||||
* @param teamId Team ID.
|
||||
* @param membershipId Membership ID.
|
||||
* @param userId User unique ID.
|
||||
* @param userId User ID.
|
||||
* @param secret Secret key.
|
||||
* @return [io.appwrite.models.Membership]
|
||||
*/
|
||||
@@ -435,14 +441,14 @@ class Teams(client: Client) : Service(client) {
|
||||
secret: String
|
||||
): io.appwrite.models.Membership {
|
||||
val path = "/teams/{teamId}/memberships/{membershipId}/status".replace("{teamId}", teamId).replace("{membershipId}", membershipId)
|
||||
val params = mapOf<String, Any?>(
|
||||
val params = mutableMapOf<String, Any?>(
|
||||
"userId" to userId,
|
||||
"secret" to secret
|
||||
)
|
||||
val headers = mapOf(
|
||||
val headers = mutableMapOf(
|
||||
"content-type" to "application/json"
|
||||
)
|
||||
val convert: (Map<String, Any>) -> io.appwrite.models.Membership = {
|
||||
val converter: (Map<String, Any>) -> io.appwrite.models.Membership = {
|
||||
io.appwrite.models.Membership.from(map = it)
|
||||
}
|
||||
return client.call(
|
||||
@@ -451,7 +457,7 @@ class Teams(client: Client) : Service(client) {
|
||||
headers,
|
||||
params,
|
||||
responseType = io.appwrite.models.Membership::class.java,
|
||||
convert = convert
|
||||
converter,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user