1
0
Fork 0
mirror of synced 2024-05-10 07:42:34 +12:00

Merge branch '6.x' of github.com:appwrite/appwrite

This commit is contained in:
Eldad Fux 2020-07-15 14:30:15 +03:00
commit 0af956fe49
78 changed files with 2872 additions and 40 deletions

View file

@ -19,6 +19,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-js',
'enabled' => true,
'beta' => false,
'dev' => false,
'family' => APP_PLATFORM_CLIENT,
'prism' => 'javascript',
'source' => \realpath(__DIR__ . '/../sdks/client-web'),
@ -29,10 +30,11 @@ return [
[
'key' => 'flutter',
'name' => 'Flutter',
'version' => '0.2.2',
'version' => '0.2.3',
'url' => 'https://github.com/appwrite/sdk-for-flutter',
'enabled' => true,
'beta' => true,
'dev' => false,
'family' => APP_PLATFORM_CLIENT,
'prism' => 'dart',
'source' => \realpath(__DIR__ . '/../sdks/client-flutter'),
@ -40,12 +42,28 @@ return [
'gitRepoName' => 'sdk-for-flutter',
'gitUserName' => 'appwrite',
],
[
'key' => 'flutter-dev',
'name' => 'Flutter (Dev Channel)',
'version' => '0.2.3',
'url' => 'https://github.com/appwrite/sdk-for-flutter-dev',
'enabled' => true,
'beta' => true,
'dev' => true,
'family' => APP_PLATFORM_CLIENT,
'prism' => 'dart',
'source' => realpath(__DIR__ . '/../sdks/client-flutter-dev'),
'gitUrl' => 'git@github.com:appwrite/sdk-for-flutter-dev.git',
'gitRepoName' => 'sdk-for-flutter-dev',
'gitUserName' => 'appwrite',
],
[
'key' => 'swift',
'name' => 'Swift',
'url' => '',
'enabled' => false,
'beta' => false,
'dev' => false,
'family' => APP_PLATFORM_CLIENT,
'prism' => 'swift',
'source' => false,
@ -59,6 +77,7 @@ return [
'url' => '',
'enabled' => false,
'beta' => false,
'dev' => false,
'family' => APP_PLATFORM_CLIENT,
'prism' => '',
'source' => false,
@ -72,6 +91,7 @@ return [
'url' => '',
'enabled' => false,
'beta' => false,
'dev' => false,
'family' => APP_PLATFORM_CLIENT,
'prism' => 'kotlin',
'source' => false,
@ -84,6 +104,7 @@ return [
// 'name' => 'Java',
// 'url' => '',
// 'enabled' => false,
// 'dev' => false,
// 'beta' => false,
// 'family' => APP_PLATFORM_CLIENT,
// 'prism' => 'java',
@ -108,6 +129,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-console',
'enabled' => true,
'beta' => false,
'dev' => false,
'family' => APP_PLATFORM_CONSOLE,
'prism' => 'console',
'source' => \realpath(__DIR__ . '/../sdks/console-web'),
@ -132,6 +154,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-node',
'enabled' => true,
'beta' => false,
'dev' => false,
'family' => APP_PLATFORM_SERVER,
'prism' => 'javascript',
'source' => \realpath(__DIR__ . '/../sdks/server-nodejs'),
@ -146,6 +169,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-deno',
'enabled' => false,
'beta' => true,
'dev' => false,
'family' => APP_PLATFORM_SERVER,
'prism' => 'typescript',
'source' => \realpath(__DIR__ . '/../sdks/server-deno'),
@ -160,6 +184,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-php',
'enabled' => true,
'beta' => false,
'dev' => false,
'family' => APP_PLATFORM_SERVER,
'prism' => 'php',
'source' => \realpath(__DIR__ . '/../sdks/server-php'),
@ -174,6 +199,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-python',
'enabled' => true,
'beta' => true,
'dev' => false,
'family' => APP_PLATFORM_SERVER,
'prism' => 'python',
'source' => \realpath(__DIR__ . '/../sdks/server-python'),
@ -188,6 +214,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-ruby',
'enabled' => true,
'beta' => true,
'dev' => false,
'family' => APP_PLATFORM_SERVER,
'prism' => 'ruby',
'source' => \realpath(__DIR__ . '/../sdks/server-ruby'),
@ -202,6 +229,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-go',
'enabled' => false,
'beta' => true,
'dev' => false,
'family' => APP_PLATFORM_SERVER,
'prism' => 'go',
'source' => \realpath(__DIR__ . '/../sdks/server-go'),
@ -216,6 +244,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-java',
'enabled' => false,
'beta' => true,
'dev' => false,
'family' => APP_PLATFORM_SERVER,
'prism' => 'java',
'source' => \realpath(__DIR__ . '/../sdks/server-java'),
@ -230,6 +259,7 @@ return [
'url' => 'https://github.com/appwrite/sdk-for-dart',
'enabled' => false,
'beta' => true,
'dev' => false,
'family' => APP_PLATFORM_SERVER,
'prism' => 'java',
'source' => \realpath(__DIR__ . '/../sdks/server-dart'),

View file

@ -0,0 +1,51 @@
## 0.2.3
- Fixed OAuth2 cookie bug, where a new session cookie couldn't overwrite an old cookie
## 0.2.2
- Fixed an error that happend when the OAuth session creation request was sent before any other API call
- Fixed a bug in the Avatars service where location URL generation had syntax error
## 0.2.1
- Fixed callback scheme
## 0.2.0
- Updated flutter_web_auth plugin to version 0.2.4
- Added per project unique callback for OAuth2 redirects to aviod conflicts between multiple Appwrite projects
## 0.1.1
- Updated flutter_web_auth version
## 0.1.0
- Added examples file
- Some minor style fixes
## 0.0.14
- Using MultipartFile for file uploads
## 0.0.13
- Fix for file upload method
## 0.0.12
- Added file upload support for storage service
## 0.0.11
- Added integration with web auth plugin to support Appwrite OAuth API
## 0.0.9
- Updated deafult params
## 0.0.8
- Fixed compilation error in Client class
- Shorter description for package

View file

@ -0,0 +1,12 @@
Copyright (c) 2019 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:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name Appwrite nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,38 @@
# Appwrite Flutter (Dev Channel) SDK
[![pub package](https://img.shields.io/pub/v/appwrite.svg)](https://pub.dartlang.org/packages/appwrite)
![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter-dev.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.6.2-blue.svg?v=1)
**This SDK is compatible with Appwrite server version 0.6.2. For older versions, please check previous 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 Flutter (Dev Channel) 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)
![Appwrite](https://appwrite.io/images/github.png)
## Installation
Add this to your package's `pubspec.yaml` file:
```yml
dependencies:
appwrite: ^0.2.3
```
You can install packages from the command line:
```bash
pub get appwrite
```
## Contribution
This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.
## License
Please see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.createOAuth2Session(
provider: 'bitbucket',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.createRecovery(
email: 'email@example.com',
url: 'https://example.com',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.createSession(
email: 'email@example.com',
password: 'password',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.createVerification(
url: 'https://example.com',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.create(
email: 'email@example.com',
password: 'password',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.deleteSession(
sessionId: '[SESSION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.deleteSessions( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.delete( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.getLogs( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.getPrefs( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.getSessions( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.get( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.updateEmail(
email: 'email@example.com',
password: 'password',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.updateName(
name: '[NAME]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.updatePassword(
password: 'password',
oldPassword: 'password',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.updatePrefs(
prefs: {},
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,25 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.updateRecovery(
userId: '[USER_ID]',
secret: '[SECRET]',
password: 'password',
passwordAgain: 'password',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Account account = Account(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = account.updateVerification(
userId: '[USER_ID]',
secret: '[SECRET]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,17 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Avatars avatars = Avatars(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
String result = avatars.getBrowser(
code: 'aa',
);
print(result); // Resource URL string
}

View file

@ -0,0 +1,17 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Avatars avatars = Avatars(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
String result = avatars.getCreditCard(
code: 'amex',
);
print(result); // Resource URL string
}

View file

@ -0,0 +1,17 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Avatars avatars = Avatars(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
String result = avatars.getFavicon(
url: 'https://example.com',
);
print(result); // Resource URL string
}

View file

@ -0,0 +1,17 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Avatars avatars = Avatars(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
String result = avatars.getFlag(
code: 'af',
);
print(result); // Resource URL string
}

View file

@ -0,0 +1,17 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Avatars avatars = Avatars(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
String result = avatars.getImage(
url: 'https://example.com',
);
print(result); // Resource URL string
}

View file

@ -0,0 +1,17 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Avatars avatars = Avatars(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
String result = avatars.getQR(
text: '[TEXT]',
);
print(result); // Resource URL string
}

View file

@ -0,0 +1,25 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Database database = Database(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = database.createDocument(
collectionId: '[COLLECTION_ID]',
data: {},
read: [],
write: [],
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Database database = Database(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = database.deleteDocument(
collectionId: '[COLLECTION_ID]',
documentId: '[DOCUMENT_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Database database = Database(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = database.getDocument(
collectionId: '[COLLECTION_ID]',
documentId: '[DOCUMENT_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Database database = Database(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = database.listDocuments(
collectionId: '[COLLECTION_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,26 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Database database = Database(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = database.updateDocument(
collectionId: '[COLLECTION_ID]',
documentId: '[DOCUMENT_ID]',
data: {},
read: [],
write: [],
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Locale locale = Locale(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = locale.getContinents( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Locale locale = Locale(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = locale.getCountriesEU( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Locale locale = Locale(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = locale.getCountriesPhones( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Locale locale = Locale(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = locale.getCountries( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Locale locale = Locale(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = locale.getCurrencies( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,20 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Locale locale = Locale(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = locale.get( );
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,25 @@
import 'dart:io';
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Storage storage = Storage(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = storage.createFile(
file: await MultipartFile.fromFile('./path-to-files/image.jpg', 'image.jpg'),
read: [],
write: [],
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Storage storage = Storage(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = storage.deleteFile(
fileId: '[FILE_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,17 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Storage storage = Storage(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
String result = storage.getFileDownload(
fileId: '[FILE_ID]',
);
print(result); // Resource URL string
}

View file

@ -0,0 +1,17 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Storage storage = Storage(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
String result = storage.getFilePreview(
fileId: '[FILE_ID]',
);
print(result); // Resource URL string
}

View file

@ -0,0 +1,17 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Storage storage = Storage(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
String result = storage.getFileView(
fileId: '[FILE_ID]',
);
print(result); // Resource URL string
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Storage storage = Storage(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = storage.getFile(
fileId: '[FILE_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,21 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Storage storage = Storage(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = storage.listFiles(
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,24 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Storage storage = Storage(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = storage.updateFile(
fileId: '[FILE_ID]',
read: [],
write: [],
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,25 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Teams teams = Teams(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = teams.createMembership(
teamId: '[TEAM_ID]',
email: 'email@example.com',
roles: [],
url: 'https://example.com',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Teams teams = Teams(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = teams.create(
name: '[NAME]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Teams teams = Teams(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = teams.deleteMembership(
teamId: '[TEAM_ID]',
inviteId: '[INVITE_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Teams teams = Teams(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = teams.delete(
teamId: '[TEAM_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Teams teams = Teams(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = teams.getMemberships(
teamId: '[TEAM_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Teams teams = Teams(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = teams.get(
teamId: '[TEAM_ID]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,21 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Teams teams = Teams(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = teams.list(
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,25 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Teams teams = Teams(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = teams.updateMembershipStatus(
teamId: '[TEAM_ID]',
inviteId: '[INVITE_ID]',
userId: '[USER_ID]',
secret: '[SECRET]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';
void main() { // Init SDK
Client client = Client();
Teams teams = Teams(client);
client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;
Future result = teams.update(
teamId: '[TEAM_ID]',
name: '[NAME]',
);
result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}

View file

@ -0,0 +1,55 @@
# Examples
Init your Appwrite client:
```dart
Client client = Client();
client
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
.setProject('5e8cf4f46b5e8') // Your project ID
.setSelfSigned() // Remove in production
;
```
Create a new user and session:
```dart
Account account = Account(client);
Response user = await account.create(email: 'me@appwrite.io', password: 'password', name: 'My Name');
Response session = await account.createSession(email: 'me@appwrite.io', password: 'password');
```
Fetch user profile:
```dart
Account account = Account(client);
Response profile = await account.get();
```
Upload File:
```dart
Storage storage = Storage(client);
MultipartFile file = MultipartFile.fromFile('./path-to-file/image.jpg', filename: 'image.jpg');
storage.createFile(
file: file,
read: ['*'],
write: []
)
.then((response) {
print(response); // File uploaded!
})
.catchError((error) {
print(error.response);
});
```
All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs)

View file

@ -0,0 +1,10 @@
export 'package:dio/dio.dart' show Response;
export 'client.dart';
export 'enums.dart';
export 'services/account.dart';
export 'services/avatars.dart';
export 'services/database.dart';
export 'services/locale.dart';
export 'services/storage.dart';
export 'services/teams.dart';

View file

@ -0,0 +1,122 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:dio/adapter.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'package:cookie_jar/cookie_jar.dart';
import 'package:path_provider/path_provider.dart';
import 'package:package_info/package_info.dart';
import 'enums.dart';
class Client {
String endPoint;
String type = 'unknown';
Map<String, String> headers;
Map<String, String> config;
bool selfSigned;
bool initialized = false;
Dio http;
PersistCookieJar cookieJar;
Client({this.endPoint = 'https://appwrite.io/v1', this.selfSigned = false, Dio http}) : this.http = http ?? Dio() {
type = (Platform.isIOS) ? 'ios' : type;
type = (Platform.isMacOS) ? 'macos' : type;
type = (Platform.isAndroid) ? 'android' : type;
type = (Platform.isLinux) ? 'linux' : type;
type = (Platform.isWindows) ? 'windows' : type;
type = (Platform.isFuchsia) ? 'fuchsia' : type;
this.headers = {
'content-type': 'application/json',
'x-sdk-version': 'appwrite:dart:0.2.3',
};
this.config = {};
assert(endPoint.startsWith(RegExp("http://|https://")), "endPoint $endPoint must start with 'http'");
}
Future<Directory> _getCookiePath() async {
final directory = await getApplicationDocumentsDirectory();
final path = directory.path;
final Directory dir = new Directory('$path/cookies');
await dir.create();
return dir;
}
/// Your project ID
Client setProject(value) {
config['project'] = value;
addHeader('X-Appwrite-Project', value);
return this;
}
Client setLocale(value) {
config['locale'] = value;
addHeader('X-Appwrite-Locale', value);
return this;
}
Client setSelfSigned({bool status = true}) {
selfSigned = status;
return this;
}
Client setEndpoint(String endPoint) {
this.endPoint = endPoint;
this.http.options.baseUrl = this.endPoint;
return this;
}
Client addHeader(String key, String value) {
headers[key] = value;
return this;
}
Future init() async {
if(!initialized) {
final Directory cookieDir = await _getCookiePath();
cookieJar = new PersistCookieJar(dir:cookieDir.path);
this.http.options.baseUrl = this.endPoint;
this.http.options.validateStatus = (status) => status < 400;
this.http.interceptors.add(CookieManager(cookieJar));
PackageInfo packageInfo = await PackageInfo.fromPlatform();
addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName);
}
}
Future<Response> call(HttpMethod method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) async {
if(selfSigned) {
// Allow self signed requests
(http.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate = (HttpClient client) {
client.badCertificateCallback = (X509Certificate cert, String host, int port) => true;
return client;
};
}
await this.init();
// Origin is hardcoded for testing
Options options = Options(
headers: {...this.headers, ...headers},
method: method.name(),
);
if(headers['content-type'] == 'multipart/form-data') {
return http.request(path, data: FormData.fromMap(params), options: options);
}
if (method == HttpMethod.get) {
return http.get(path, queryParameters: params, options: options);
} else {
return http.request(path, data: params, options: options);
}
}
}

View file

@ -0,0 +1,15 @@
enum HttpMethod { get, post, put, delete, patch }
extension HttpMethodString on HttpMethod {
String name() {
return this.toString().split('.').last.toUpperCase();
}
}
enum OrderType { asc, desc }
extension OrderTypeString on OrderType {
String name() {
return this.toString().split('.').last.toUpperCase();
}
}

View file

@ -0,0 +1,7 @@
import 'client.dart';
class Service {
final Client client;
const Service(this.client);
}

View file

@ -0,0 +1,424 @@
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import 'package:flutter_web_auth/flutter_web_auth.dart';
import "../client.dart";
import '../enums.dart';
import "../service.dart";
class Account extends Service {
Account(Client client): super(client);
/// Get Account
///
/// Get currently logged in user data as JSON object.
///
Future<Response> get() {
final String path = '/account';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// Create Account
///
/// Use this endpoint to allow a new user to register a new account in your
/// project. After the user registration completes successfully, you can use
/// the [/account/verfication](/docs/client/account#createVerification) route
/// to start verifying the user email address. To allow your new user to login
/// to his new account, you need to create a new [account
/// session](/docs/client/account#createSession).
///
Future<Response> create({@required String email, @required String password, String name = ''}) {
final String path = '/account';
final Map<String, dynamic> params = {
'email': email,
'password': password,
'name': name,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
}
/// 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.
///
Future<Response> delete() {
final String path = '/account';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
}
/// 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.
///
Future<Response> updateEmail({@required String email, @required String password}) {
final String path = '/account/email';
final Map<String, dynamic> params = {
'email': email,
'password': password,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
}
/// Get Account Logs
///
/// Get currently logged in user list of latest security activity logs. Each
/// log returns user IP address, location and date and time of log.
///
Future<Response> getLogs() {
final String path = '/account/logs';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// Update Account Name
///
/// Update currently logged in user account name.
///
Future<Response> updateName({@required String name}) {
final String path = '/account/name';
final Map<String, dynamic> params = {
'name': name,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
}
/// Update Account Password
///
/// Update currently logged in user password. For validation, user is required
/// to pass the password twice.
///
Future<Response> updatePassword({@required String password, @required String oldPassword}) {
final String path = '/account/password';
final Map<String, dynamic> params = {
'password': password,
'oldPassword': oldPassword,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
}
/// Get Account Preferences
///
/// Get currently logged in user preferences as a key-value object.
///
Future<Response> getPrefs() {
final String path = '/account/prefs';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// Update Account Preferences
///
/// Update currently logged in user account preferences. You can pass only the
/// specific settings you wish to update.
///
Future<Response> updatePrefs({@required dynamic prefs}) {
final String path = '/account/prefs';
final Map<String, dynamic> params = {
'prefs': prefs,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
}
/// Create Password Recovery
///
/// Sends the user an email with a temporary secret key for password reset.
/// When the user clicks the confirmation link he is redirected back to your
/// app password reset URL with the secret key and email address values
/// attached to the URL query string. Use the query string params to submit a
/// request to the [PUT /account/recovery](/docs/client/account#updateRecovery)
/// endpoint to complete the process.
///
Future<Response> createRecovery({@required String email, @required String url}) {
final String path = '/account/recovery';
final Map<String, dynamic> params = {
'email': email,
'url': url,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
}
/// Complete Password Recovery
///
/// Use this endpoint to complete the user account password reset. Both the
/// **userId** and **secret** arguments will be passed as query parameters to
/// the redirect URL you have provided when sending your request to the [POST
/// /account/recovery](/docs/client/account#createRecovery) endpoint.
///
/// Please note that in order to avoid a [Redirect
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
/// the only valid redirect URLs are the ones from domains you have set when
/// adding your platforms in the console interface.
///
Future<Response> updateRecovery({@required String userId, @required String secret, @required String password, @required String passwordAgain}) {
final String path = '/account/recovery';
final Map<String, dynamic> params = {
'userId': userId,
'secret': secret,
'password': password,
'passwordAgain': passwordAgain,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
}
/// Get Account Sessions
///
/// Get currently logged in user list of active sessions across different
/// devices.
///
Future<Response> getSessions() {
final String path = '/account/sessions';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// Create Account Session
///
/// Allow the user to login into his account by providing a valid email and
/// password combination. This route will create a new session for the user.
///
Future<Response> createSession({@required String email, @required String password}) {
final String path = '/account/sessions';
final Map<String, dynamic> params = {
'email': email,
'password': password,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
}
/// Delete All Account Sessions
///
/// Delete all sessions from the user account and remove any sessions cookies
/// from the end client.
///
Future<Response> deleteSessions() {
final String path = '/account/sessions';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
}
/// Create Account Session with OAuth2
///
/// Allow the user to login to his account using the OAuth2 provider of his
/// choice. Each OAuth2 provider should be enabled from the Appwrite console
/// first. Use the success and failure arguments to provide a redirect URL's
/// back to your app when login is completed.
///
Future createOAuth2Session({@required String provider, String success = 'https://appwrite.io/auth/oauth2/success', String failure = 'https://appwrite.io/auth/oauth2/failure'}) {
final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
final Map<String, dynamic> params = {
'success': success,
'failure': failure,
'project': client.config['project'],
};
final List query = [];
params.forEach((key, value) {
if (value is List) {
for (var item in value) {
query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item));
}
}
else {
query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value));
}
});
Uri endpoint = Uri.parse(client.endPoint);
Uri url = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
query: query.join('&')
);
return FlutterWebAuth.authenticate(
url: url.toString(),
callbackUrlScheme: "appwrite-callback-" + client.config['project']
).then((value) async {
Uri url = Uri.parse(value);
Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']);
cookie.domain = Uri.parse(client.endPoint).host;
cookie.httpOnly = true;
cookie.path = '/';
List<Cookie> cookies = [cookie];
await client.init();
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
});
}
/// Delete Account Session
///
/// Use this endpoint to log out the currently logged in user from all his
/// account sessions across all his different devices. When using the option id
/// argument, only the session unique ID provider will be deleted.
///
Future<Response> deleteSession({@required String sessionId}) {
final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId);
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
}
/// Create Email Verification
///
/// Use this endpoint to send a verification message to your user email address
/// to confirm they are the valid owners of that address. Both the **userId**
/// and **secret** arguments will be passed as query parameters to the URL you
/// have provider to be attached to the verification email. The provided URL
/// should redirect the user back for your app and allow you to complete the
/// verification process by verifying both the **userId** and **secret**
/// parameters. Learn more about how to [complete the verification
/// process](/docs/client/account#updateAccountVerification).
///
/// Please note that in order to avoid a [Redirect
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
/// the only valid redirect URLs are the ones from domains you have set when
/// adding your platforms in the console interface.
///
Future<Response> createVerification({@required String url}) {
final String path = '/account/verification';
final Map<String, dynamic> params = {
'url': url,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
}
/// Complete Email Verification
///
/// Use this endpoint to complete the user email verification process. Use both
/// the **userId** and **secret** parameters that were attached to your app URL
/// to verify the user email ownership. If confirmed this route will return a
/// 200 status code.
///
Future<Response> updateVerification({@required String userId, @required String secret}) {
final String path = '/account/verification';
final Map<String, dynamic> params = {
'userId': userId,
'secret': secret,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
}
}

View file

@ -0,0 +1,174 @@
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import "../client.dart";
import '../enums.dart';
import "../service.dart";
class Avatars extends Service {
Avatars(Client client): super(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.
///
String getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) {
final String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code);
final Map<String, dynamic> params = {
'width': width,
'height': height,
'quality': quality,
'project': client.config['project'],
};
Uri endpoint = Uri.parse(client.endPoint);
Uri location = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
queryParameters:params,
);
return location.toString();
}
/// Get Credit Card Icon
///
/// Need to display your users with your billing method or their payment
/// methods? 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.
///
String getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) {
final String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code);
final Map<String, dynamic> params = {
'width': width,
'height': height,
'quality': quality,
'project': client.config['project'],
};
Uri endpoint = Uri.parse(client.endPoint);
Uri location = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
queryParameters:params,
);
return location.toString();
}
/// Get Favicon
///
/// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
/// website URL.
///
String getFavicon({@required String url}) {
final String path = '/avatars/favicon';
final Map<String, dynamic> params = {
'url': url,
'project': client.config['project'],
};
Uri endpoint = Uri.parse(client.endPoint);
Uri location = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
queryParameters:params,
);
return location.toString();
}
/// Get Country Flag
///
/// 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.
///
String getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) {
final String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code);
final Map<String, dynamic> params = {
'width': width,
'height': height,
'quality': quality,
'project': client.config['project'],
};
Uri endpoint = Uri.parse(client.endPoint);
Uri location = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
queryParameters:params,
);
return location.toString();
}
/// Get Image from URL
///
/// Use this endpoint to fetch a remote image URL and crop it to any image size
/// 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.
///
String getImage({@required String url, int width = 400, int height = 400}) {
final String path = '/avatars/image';
final Map<String, dynamic> params = {
'url': url,
'width': width,
'height': height,
'project': client.config['project'],
};
Uri endpoint = Uri.parse(client.endPoint);
Uri location = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
queryParameters:params,
);
return location.toString();
}
/// Get QR Code
///
/// 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.
///
String getQR({@required String text, int size = 400, int margin = 1, int download = 0}) {
final String path = '/avatars/qr';
final Map<String, dynamic> params = {
'text': text,
'size': size,
'margin': margin,
'download': download,
'project': client.config['project'],
};
Uri endpoint = Uri.parse(client.endPoint);
Uri location = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
queryParameters:params,
);
return location.toString();
}
}

View file

@ -0,0 +1,121 @@
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import "../client.dart";
import '../enums.dart';
import "../service.dart";
class Database extends Service {
Database(Client client): super(client);
/// List Documents
///
/// Get a list of all the user documents. You can use the query params to
/// filter your results. On admin mode, this endpoint will return a list of all
/// of the project documents. [Learn more about different API
/// modes](/docs/admin).
///
Future<Response> listDocuments({@required String collectionId, List filters = const [], int offset = 0, int limit = 50, String orderField = '\$id', OrderType orderType = OrderType.asc, String orderCast = 'string', String search = '', int first = 0, int last = 0}) {
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
final Map<String, dynamic> params = {
'filters': filters,
'offset': offset,
'limit': limit,
'orderField': orderField,
'orderType': orderType.name(),
'orderCast': orderCast,
'search': search,
'first': first,
'last': last,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// Create Document
///
/// Create a new Document. Before using this route, you should create a new
/// collection resource using either a [server
/// integration](/docs/server/database?sdk=nodejs#createCollection) API or
/// directly from your database console.
///
Future<Response> createDocument({@required String collectionId, @required dynamic data, @required List read, @required List write, String parentDocument = '', String parentProperty = '', String parentPropertyType = 'assign'}) {
final String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
final Map<String, dynamic> params = {
'data': data,
'read': read,
'write': write,
'parentDocument': parentDocument,
'parentProperty': parentProperty,
'parentPropertyType': parentPropertyType,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
}
/// Get Document
///
/// Get document by its unique ID. This endpoint response returns a JSON object
/// with the document data.
///
Future<Response> getDocument({@required String collectionId, @required String documentId}) {
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// Update Document
Future<Response> updateDocument({@required String collectionId, @required String documentId, @required dynamic data, @required List read, @required List write}) {
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
final Map<String, dynamic> params = {
'data': data,
'read': read,
'write': write,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
}
/// Delete Document
///
/// Delete document by its unique ID. This endpoint deletes only the parent
/// documents, his attributes and relations to other documents. Child documents
/// **will not** be deleted.
///
Future<Response> deleteDocument({@required String collectionId, @required String documentId}) {
final String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
}
}

View file

@ -0,0 +1,125 @@
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import "../client.dart";
import '../enums.dart';
import "../service.dart";
class Locale extends Service {
Locale(Client client): super(client);
/// Get User Locale
///
/// Get the current user location based on IP. Returns an object with user
/// country code, country name, continent name, continent code, ip address and
/// suggested currency. You can use the locale header to get the data in a
/// supported language.
///
/// ([IP Geolocation by DB-IP](https://db-ip.com))
///
Future<Response> get() {
final String path = '/locale';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// List Continents
///
/// List of all continents. You can use the locale header to get the data in a
/// supported language.
///
Future<Response> getContinents() {
final String path = '/locale/continents';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// List Countries
///
/// List of all countries. You can use the locale header to get the data in a
/// supported language.
///
Future<Response> getCountries() {
final String path = '/locale/countries';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// List EU Countries
///
/// List of all countries that are currently members of the EU. You can use the
/// locale header to get the data in a supported language.
///
Future<Response> getCountriesEU() {
final String path = '/locale/countries/eu';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// List Countries Phone Codes
///
/// List of all countries phone codes. You can use the locale header to get the
/// data in a supported language.
///
Future<Response> getCountriesPhones() {
final String path = '/locale/countries/phones';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// List Currencies
///
/// List of all currencies, including currency symol, name, plural, and decimal
/// digits for all major and minor currencies. You can use the locale header to
/// get the data in a supported language.
///
Future<Response> getCurrencies() {
final String path = '/locale/currencies';
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
}

View file

@ -0,0 +1,191 @@
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import "../client.dart";
import '../enums.dart';
import "../service.dart";
class Storage extends Service {
Storage(Client client): super(client);
/// List Files
///
/// Get a list of all the user files. You can use the query params to filter
/// your results. On admin mode, this endpoint will return a list of all of the
/// project files. [Learn more about different API modes](/docs/admin).
///
Future<Response> listFiles({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
final String path = '/storage/files';
final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// 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.
///
Future<Response> createFile({@required MultipartFile file, @required List read, @required List write}) {
final String path = '/storage/files';
final Map<String, dynamic> params = {
'file': file,
'read': read,
'write': write,
};
final Map<String, String> headers = {
'content-type': 'multipart/form-data',
};
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
}
/// Get File
///
/// Get file by its unique ID. This endpoint response returns a JSON object
/// with the file metadata.
///
Future<Response> getFile({@required String fileId}) {
final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// Update File
///
/// Update file by its unique ID. Only users with write permissions have access
/// to update this resource.
///
Future<Response> updateFile({@required String fileId, @required List read, @required List write}) {
final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
final Map<String, dynamic> params = {
'read': read,
'write': write,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
}
/// Delete File
///
/// Delete a file by its unique ID. Only users with write permissions have
/// access to delete this resource.
///
Future<Response> deleteFile({@required String fileId}) {
final String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
}
/// Get File for Download
///
/// Get file content by its unique ID. The endpoint response return with a
/// 'Content-Disposition: attachment' header that tells the browser to start
/// downloading the file to user downloads directory.
///
String getFileDownload({@required String fileId}) {
final String path = '/storage/files/{fileId}/download'.replaceAll(RegExp('{fileId}'), fileId);
final Map<String, dynamic> params = {
'project': client.config['project'],
};
Uri endpoint = Uri.parse(client.endPoint);
Uri location = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
queryParameters:params,
);
return location.toString();
}
/// Get File Preview
///
/// 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 getFilePreview({@required String fileId, int width = 0, int height = 0, int quality = 100, String background = '', String output = ''}) {
final String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId);
final Map<String, dynamic> params = {
'width': width,
'height': height,
'quality': quality,
'background': background,
'output': output,
'project': client.config['project'],
};
Uri endpoint = Uri.parse(client.endPoint);
Uri location = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
queryParameters:params,
);
return location.toString();
}
/// Get File for View
///
/// Get file content by its unique ID. This endpoint is similar to the download
/// method but returns with no 'Content-Disposition: attachment' header.
///
String getFileView({@required String fileId, String as = ''}) {
final String path = '/storage/files/{fileId}/view'.replaceAll(RegExp('{fileId}'), fileId);
final Map<String, dynamic> params = {
'as': as,
'project': client.config['project'],
};
Uri endpoint = Uri.parse(client.endPoint);
Uri location = new Uri(scheme: endpoint.scheme,
host: endpoint.host,
port: endpoint.port,
path: endpoint.path + path,
queryParameters:params,
);
return location.toString();
}
}

View file

@ -0,0 +1,203 @@
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import "../client.dart";
import '../enums.dart';
import "../service.dart";
class Teams extends Service {
Teams(Client client): super(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 teams. [Learn more about different API modes](/docs/admin).
///
Future<Response> list({String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
final String path = '/teams';
final Map<String, dynamic> params = {
'search': search,
'limit': limit,
'offset': offset,
'orderType': orderType.name(),
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// 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.
///
Future<Response> create({@required String name, List roles = const ["owner"]}) {
final String path = '/teams';
final Map<String, dynamic> params = {
'name': name,
'roles': roles,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
}
/// Get Team
///
/// Get team by its unique ID. All team members have read access for this
/// resource.
///
Future<Response> get({@required String teamId}) {
final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// Update Team
///
/// Update team by its unique ID. Only team owners have write access for this
/// resource.
///
Future<Response> update({@required String teamId, @required String name}) {
final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
final Map<String, dynamic> params = {
'name': name,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.put, path: path, params: params, headers: headers);
}
/// Delete Team
///
/// Delete team by its unique ID. Only team owners have write access for this
/// resource.
///
Future<Response> delete({@required String teamId}) {
final String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
}
/// Get Team Memberships
///
/// Get team members by the team unique ID. All team members have read access
/// for this list of resources.
///
Future<Response> getMemberships({@required String teamId}) {
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
}
/// Create Team Membership
///
/// Use this endpoint to invite a new member to join your team. An email with a
/// link to join the team will be sent to the new member email address if the
/// member doesn't exist in the project it will be created automatically.
///
/// 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#updateMembershipStatus) endpoint to allow 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)
/// the only valid redirect URL's are the once from domains you have set when
/// added your platforms in the console interface.
///
Future<Response> createMembership({@required String teamId, @required String email, @required List roles, @required String url, String name = ''}) {
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
final Map<String, dynamic> params = {
'email': email,
'name': name,
'roles': roles,
'url': url,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.post, path: path, params: params, headers: headers);
}
/// Delete Team Membership
///
/// This endpoint allows a user to leave a team or for a team owner to delete
/// the membership of any other team member. You can also use this endpoint to
/// delete a user membership even if he didn't accept it.
///
Future<Response> deleteMembership({@required String teamId, @required String inviteId}) {
final String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId);
final Map<String, dynamic> params = {
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.delete, path: path, params: params, headers: headers);
}
/// Update Team Membership Status
///
/// Use this endpoint to allow a user to accept an invitation to join a team
/// after he is being redirected back to your app from the invitation email he
/// was sent.
///
Future<Response> updateMembershipStatus({@required String teamId, @required String inviteId, @required String userId, @required String secret}) {
final String path = '/teams/{teamId}/memberships/{inviteId}/status'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId);
final Map<String, dynamic> params = {
'userId': userId,
'secret': secret,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
return client.call(HttpMethod.patch, path: path, params: params, headers: headers);
}
}

View file

@ -0,0 +1,38 @@
name: appwrite
version: 0.2.3
description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
homepage: https://appwrite.io
repository: https://github.com/appwrite/sdk-for-flutter-dev
issue_tracker: https://github.com/appwrite/sdk-generator/issues
documentation: https://appwrite.io/support
environment:
sdk: '>=2.6.0 <3.0.0'
dependencies:
meta: ^1.1.8
path_provider: ^1.6.5
package_info: ^0.4.0+16
dio: ^3.0.0
cookie_jar: ^1.0.0
dio_cookie_manager: ^1.0.0
flutter_web_auth: ^0.2.4
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

View file

@ -1,3 +1,7 @@
## 0.2.3
- Fixed OAuth2 cookie bug, where a new session cookie couldn&#039;t overwrite an old cookie
## 0.2.2
- Fixed an error that happend when the OAuth session creation request was sent before any other API call

View file

@ -20,7 +20,7 @@ Add this to your package's `pubspec.yaml` file:
```yml
dependencies:
appwrite: ^0.2.2
appwrite: ^0.2.3
```
You can install packages from the command line:

View file

@ -30,7 +30,7 @@ class Client {
this.headers = {
'content-type': 'application/json',
'x-sdk-version': 'appwrite:dart:0.2.2',
'x-sdk-version': 'appwrite:dart:0.2.3',
};
this.config = {};

View file

@ -342,9 +342,13 @@ class Account extends Service {
callbackUrlScheme: "appwrite-callback-" + client.config['project']
).then((value) async {
Uri url = Uri.parse(value);
List<Cookie> cookies = [new Cookie(url.queryParameters['key'], url.queryParameters['secret'])];
await client.init();
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
Cookie cookie = new Cookie(url.queryParameters['key'], url.queryParameters['secret']);
cookie.domain = Uri.parse(client.endPoint).host;
cookie.httpOnly = true;
cookie.path = '/';
List<Cookie> cookies = [cookie];
await client.init();
client.cookieJar.saveFromResponse(Uri.parse(client.endPoint), cookies);
});
}

View file

@ -1,5 +1,5 @@
name: appwrite
version: 0.2.2
version: 0.2.3
description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
homepage: https://appwrite.io
repository: https://github.com/appwrite/sdk-for-flutter

View file

@ -16,6 +16,7 @@ use Appwrite\SDK\Language\Python;
use Appwrite\SDK\Language\Ruby;
use Appwrite\SDK\Language\Dart;
use Appwrite\SDK\Language\Deno;
use Appwrite\SDK\Language\Flutter;
use Appwrite\SDK\Language\Go;
use Appwrite\SDK\Language\Java;
@ -89,42 +90,39 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
switch ($language['key']) {
case 'web':
$config = new JS();
$config
->setNPMPackage('appwrite')
->setBowerPackage('appwrite')
;
$config->setNPMPackage('appwrite');
$config->setBowerPackage('appwrite');
break;
case 'php':
$config = new PHP();
$config
->setComposerVendor('appwrite')
->setComposerPackage('appwrite')
;
$config->setComposerVendor('appwrite');
$config->setComposerPackage('appwrite');
break;
case 'nodejs':
$config = new Node();
$config
->setNPMPackage('node-appwrite')
->setBowerPackage('appwrite')
;
$config->setNPMPackage('node-appwrite');
$config->setBowerPackage('appwrite');
break;
case 'deno':
$config = new Deno();
break;
case 'python':
$config = new Python();
$config
->setPipPackage('appwrite')
;
$config->setPipPackage('appwrite');
$license = 'BSD License'; // license edited due to classifiers in pypi
break;
case 'ruby':
$config = new Ruby();
$config
->setGemPackage('appwrite')
;
$config->setGemPackage('appwrite');
break;
case 'flutter':
$config = new Flutter();
$config->setPackageName('appwrite');
break;
case 'flutter-dev':
$config = new Flutter();
$config->setPackageName('appwrite-dev');
break;
case 'dart':
$config = new Dart();
break;

28
composer.lock generated
View file

@ -747,7 +747,7 @@
"version": "dev-master",
"source": {
"type": "git",
"url": "git@github.com:mustangostang/spyc.git",
"url": "https://github.com/mustangostang/spyc.git",
"reference": "daf9fa4ef675519386b4f556c9d5ab5f9c14055a"
},
"dist": {
@ -2239,29 +2239,29 @@
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "451c3cd1418cf640de218914901e51b064abb093"
"reference": "fa7f91090a63296a3c9af65e124384e19dad7e29"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093",
"reference": "451c3cd1418cf640de218914901e51b064abb093",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/fa7f91090a63296a3c9af65e124384e19dad7e29",
"reference": "fa7f91090a63296a3c9af65e124384e19dad7e29",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0",
"sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0"
"doctrine/instantiator": "^1.2",
"php": "^7.2",
"phpdocumentor/reflection-docblock": "^5.0",
"sebastian/comparator": "^3.0 || ^4.0",
"sebastian/recursion-context": "^3.0 || ^4.0"
},
"require-dev": {
"phpspec/phpspec": "^2.5 || ^3.2",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1"
"phpspec/phpspec": "^6.0",
"phpunit/phpunit": "^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.10.x-dev"
"dev-master": "1.11.x-dev"
}
},
"autoload": {
@ -2294,7 +2294,7 @@
"spy",
"stub"
],
"time": "2020-03-05T15:02:03+00:00"
"time": "2020-07-09T10:28:49+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -3380,7 +3380,7 @@
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0",
"php": "^5.3.3 || ^7.0 || ^8.0",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {

View file

@ -0,0 +1,51 @@
## 0.2.3
- Fixed OAuth2 cookie bug, where a new session cookie couldn't overwrite an old cookie
## 0.2.2
- Fixed an error that happend when the OAuth session creation request was sent before any other API call
- Fixed a bug in the Avatars service where location URL generation had syntax error
## 0.2.1
- Fixed callback scheme
## 0.2.0
- Updated flutter_web_auth plugin to version 0.2.4
- Added per project unique callback for OAuth2 redirects to aviod conflicts between multiple Appwrite projects
## 0.1.1
- Updated flutter_web_auth version
## 0.1.0
- Added examples file
- Some minor style fixes
## 0.0.14
- Using MultipartFile for file uploads
## 0.0.13
- Fix for file upload method
## 0.0.12
- Added file upload support for storage service
## 0.0.11
- Added integration with web auth plugin to support Appwrite OAuth API
## 0.0.9
- Updated deafult params
## 0.0.8
- Fixed compilation error in Client class
- Shorter description for package

View file

@ -0,0 +1,55 @@
# Examples
Init your Appwrite client:
```dart
Client client = Client();
client
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
.setProject('5e8cf4f46b5e8') // Your project ID
.setSelfSigned() // Remove in production
;
```
Create a new user and session:
```dart
Account account = Account(client);
Response user = await account.create(email: 'me@appwrite.io', password: 'password', name: 'My Name');
Response session = await account.createSession(email: 'me@appwrite.io', password: 'password');
```
Fetch user profile:
```dart
Account account = Account(client);
Response profile = await account.get();
```
Upload File:
```dart
Storage storage = Storage(client);
MultipartFile file = MultipartFile.fromFile('./path-to-file/image.jpg', filename: 'image.jpg');
storage.createFile(
file: file,
read: ['*'],
write: []
)
.then((response) {
print(response); // File uploaded!
})
.catchError((error) {
print(error.response);
});
```
All examples and API features are available at the [official Appwrite docs](https://appwrite.io/docs)

View file

@ -1,6 +1,6 @@
## 0.2.3
- Added support for custom OAuth2 scopes
- Fixed OAuth2 cookie bug, where a new session cookie couldn't overwrite an old cookie
## 0.2.2