1
0
Fork 0
mirror of synced 2024-06-03 11:24:48 +12:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
SuuSoJeat 2020-03-28 09:43:37 +07:00
commit 6a7297589d
18 changed files with 190 additions and 106 deletions

View file

@ -1,7 +1,7 @@
# Appwrite SDK for JavaScript
![License](https://img.shields.io/github/license/appwrite/sdk-for-console.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1)
Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
@ -33,6 +33,10 @@ To install with a CDN (content delivery network) add the following scripts to th
## 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

@ -1,7 +1,7 @@
# Appwrite SDK for Dart
![License](https://img.shields.io/github/license/appwrite/sdk-for-dart.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1)
**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.**
@ -26,6 +26,10 @@ You can install packages from the command line:
pub get
```
## 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

@ -2,6 +2,8 @@ import 'package:dio/dio.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'package:cookie_jar/cookie_jar.dart';
import 'enums.dart';
class Client {
String endPoint;
Map<String, String> headers;
@ -71,18 +73,18 @@ class Client {
return this;
}
Future<Response> call(String method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) {
Future<Response> call(HttpMethod method, {String path = '', Map<String, String> headers = const {}, Map<String, dynamic> params = const {}}) {
if(this.selfSigned) {
// Allow self signed requests
}
String reqPath = path;
bool isGet = method.toUpperCase() == "GET";
bool isGet = method == HttpMethod.get;
// Origin is hardcoded for testing
Options options = Options(
headers: {...this.headers, ...headers, "Origin": "http://localhost"},
method: method.toUpperCase(),
method: method.name(),
);
if (isGet) {

View file

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

View file

@ -1,6 +1,11 @@
import 'dart:html';
import "package:appwrite/service.dart";
import "package:appwrite/client.dart";
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import '../enums.dart';
class Account extends Service {
@ -13,7 +18,7 @@ class Account extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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
@ -21,7 +26,7 @@ class Account extends Service {
/// 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/account#createSession).
Future<Response> create({email, password, name = null}) async {
Future<Response> create({@required String email, @required String password, String name = null}) async {
String path = '/account';
Map<String, dynamic> params = {
@ -30,7 +35,7 @@ class Account extends Service {
'name': name,
};
return await this.client.call('post', path: path, params: params);
return await this.client.call(HttpMethod.post, path: path, params: params);
}
/// 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
@ -43,13 +48,13 @@ class Account extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('delete', path: path, params: params);
return await this.client.call(HttpMethod.delete, path: path, params: params);
}
/// 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({email, password}) async {
Future<Response> updateEmail({@required String email, @required String password}) async {
String path = '/account/email';
Map<String, dynamic> params = {
@ -57,7 +62,7 @@ class Account extends Service {
'password': password,
};
return await this.client.call('patch', path: path, params: params);
return await this.client.call(HttpMethod.patch, path: path, params: params);
}
/// Get currently logged in user list of latest security activity logs. Each
/// log returns user IP address, location and date and time of log.
@ -67,21 +72,21 @@ class Account extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// Update currently logged in user account name.
Future<Response> updateName({name}) async {
Future<Response> updateName({@required String name}) async {
String path = '/account/name';
Map<String, dynamic> params = {
'name': name,
};
return await this.client.call('patch', path: path, params: params);
return await this.client.call(HttpMethod.patch, path: path, params: params);
}
/// Update currently logged in user password. For validation, user is required
/// to pass the password twice.
Future<Response> updatePassword({password, oldPassword}) async {
Future<Response> updatePassword({@required String password, @required String oldPassword}) async {
String path = '/account/password';
Map<String, dynamic> params = {
@ -89,7 +94,7 @@ class Account extends Service {
'old-password': oldPassword,
};
return await this.client.call('patch', path: path, params: params);
return await this.client.call(HttpMethod.patch, path: path, params: params);
}
/// Get currently logged in user preferences as a key-value object.
Future<Response> getPrefs() async {
@ -98,18 +103,18 @@ class Account extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// Update currently logged in user account preferences. You can pass only the
/// specific settings you wish to update.
Future<Response> updatePrefs({prefs}) async {
Future<Response> updatePrefs({@required dynamic prefs}) async {
String path = '/account/prefs';
Map<String, dynamic> params = {
'prefs': prefs,
};
return await this.client.call('patch', path: path, params: params);
return await this.client.call(HttpMethod.patch, path: path, params: params);
}
/// 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
@ -117,7 +122,7 @@ class Account extends Service {
/// attached to the URL query string. Use the query string params to submit a
/// request to the [PUT /account/recovery](/docs/account#updateRecovery)
/// endpoint to complete the process.
Future<Response> createRecovery({email, url}) async {
Future<Response> createRecovery({@required String email, @required String url}) async {
String path = '/account/recovery';
Map<String, dynamic> params = {
@ -125,7 +130,7 @@ class Account extends Service {
'url': url,
};
return await this.client.call('post', path: path, params: params);
return await this.client.call(HttpMethod.post, path: path, params: params);
}
/// Use this endpoint to complete the user account password reset. Both the
/// **userId** and **secret** arguments will be passed as query parameters to
@ -136,7 +141,7 @@ class Account extends Service {
/// 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({userId, secret, passwordA, passwordB}) async {
Future<Response> updateRecovery({@required String userId, @required String secret, @required String passwordA, @required String passwordB}) async {
String path = '/account/recovery';
Map<String, dynamic> params = {
@ -146,7 +151,7 @@ class Account extends Service {
'password-b': passwordB,
};
return await this.client.call('put', path: path, params: params);
return await this.client.call(HttpMethod.put, path: path, params: params);
}
/// Get currently logged in user list of active sessions across different
/// devices.
@ -156,11 +161,11 @@ class Account extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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({email, password}) async {
Future<Response> createSession({@required String email, @required String password}) async {
String path = '/account/sessions';
Map<String, dynamic> params = {
@ -168,7 +173,7 @@ class Account extends Service {
'password': password,
};
return await this.client.call('post', path: path, params: params);
return await this.client.call(HttpMethod.post, path: path, params: params);
}
/// Delete all sessions from the user account and remove any sessions cookies
/// from the end client.
@ -178,13 +183,13 @@ class Account extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('delete', path: path, params: params);
return await this.client.call(HttpMethod.delete, path: path, params: params);
}
/// 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<Response> createOAuth2Session({provider, success, failure}) async {
Future<Response> createOAuth2Session({@required String provider, @required String success, @required String failure}) async {
String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
Map<String, dynamic> params = {
@ -192,18 +197,18 @@ class Account extends Service {
'failure': failure,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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({sessionId}) async {
Future<Response> deleteSession({@required String sessionId}) async {
String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId);
Map<String, dynamic> params = {
};
return await this.client.call('delete', path: path, params: params);
return await this.client.call(HttpMethod.delete, path: path, params: params);
}
/// 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**
@ -218,20 +223,20 @@ class Account extends Service {
/// 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({url}) async {
Future<Response> createVerification({@required String url}) async {
String path = '/account/verification';
Map<String, dynamic> params = {
'url': url,
};
return await this.client.call('post', path: path, params: params);
return await this.client.call(HttpMethod.post, path: path, params: params);
}
/// 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({userId, secret}) async {
Future<Response> updateVerification({@required String userId, @required String secret}) async {
String path = '/account/verification';
Map<String, dynamic> params = {
@ -239,6 +244,6 @@ class Account extends Service {
'secret': secret,
};
return await this.client.call('put', path: path, params: params);
return await this.client.call(HttpMethod.put, path: path, params: params);
}
}

View file

@ -1,6 +1,11 @@
import 'dart:html';
import "package:appwrite/service.dart";
import "package:appwrite/client.dart";
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import '../enums.dart';
class Avatars extends Service {
@ -10,7 +15,7 @@ class Avatars extends Service {
/// 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.
Future<Response> getBrowser({code, width = 100, height = 100, quality = 100}) async {
Future<Response> getBrowser({@required String code, int width = 100, int height = 100, int quality = 100}) async {
String path = '/avatars/browsers/{code}'.replaceAll(RegExp('{code}'), code);
Map<String, dynamic> params = {
@ -19,13 +24,13 @@ class Avatars extends Service {
'quality': quality,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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.
Future<Response> getCreditCard({code, width = 100, height = 100, quality = 100}) async {
Future<Response> getCreditCard({@required String code, int width = 100, int height = 100, int quality = 100}) async {
String path = '/avatars/credit-cards/{code}'.replaceAll(RegExp('{code}'), code);
Map<String, dynamic> params = {
@ -34,23 +39,23 @@ class Avatars extends Service {
'quality': quality,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
/// website URL.
Future<Response> getFavicon({url}) async {
Future<Response> getFavicon({@required String url}) async {
String path = '/avatars/favicon';
Map<String, dynamic> params = {
'url': url,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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.
Future<Response> getFlag({code, width = 100, height = 100, quality = 100}) async {
Future<Response> getFlag({@required String code, int width = 100, int height = 100, int quality = 100}) async {
String path = '/avatars/flags/{code}'.replaceAll(RegExp('{code}'), code);
Map<String, dynamic> params = {
@ -59,13 +64,13 @@ class Avatars extends Service {
'quality': quality,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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.
Future<Response> getImage({url, width = 400, height = 400}) async {
Future<Response> getImage({@required String url, int width = 400, int height = 400}) async {
String path = '/avatars/image';
Map<String, dynamic> params = {
@ -74,11 +79,11 @@ class Avatars extends Service {
'height': height,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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.
Future<Response> getQR({text, size = 400, margin = 1, download = null}) async {
Future<Response> getQR({@required String text, int size = 400, int margin = 1, int download = null}) async {
String path = '/avatars/qr';
Map<String, dynamic> params = {
@ -88,6 +93,6 @@ class Avatars extends Service {
'download': download,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
}

View file

@ -1,6 +1,11 @@
import 'dart:html';
import "package:appwrite/service.dart";
import "package:appwrite/client.dart";
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import '../enums.dart';
class Database extends Service {
@ -10,7 +15,7 @@ class Database extends Service {
/// 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({collectionId, filters = const [], offset = null, limit = 50, orderField = '\$id', orderType = 'ASC', orderCast = 'string', search = null, first = null, last = null}) async {
Future<Response> listDocuments({@required String collectionId, List filters = const [], int offset = null, int limit = 50, String orderField = '\$id', String orderType = 'ASC', String orderCast = 'string', String search = null, int first = null, int last = null}) async {
String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
Map<String, dynamic> params = {
@ -25,10 +30,10 @@ class Database extends Service {
'last': last,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// Create a new Document.
Future<Response> createDocument({collectionId, data, read, write, parentDocument = null, parentProperty = null, parentPropertyType = 'assign'}) async {
Future<Response> createDocument({@required String collectionId, @required dynamic data, @required List read, @required List write, String parentDocument = null, String parentProperty = null, String parentPropertyType = 'assign'}) async {
String path = '/database/collections/{collectionId}/documents'.replaceAll(RegExp('{collectionId}'), collectionId);
Map<String, dynamic> params = {
@ -40,19 +45,19 @@ class Database extends Service {
'parentPropertyType': parentPropertyType,
};
return await this.client.call('post', path: path, params: params);
return await this.client.call(HttpMethod.post, path: path, params: params);
}
/// Get document by its unique ID. This endpoint response returns a JSON object
/// with the document data.
Future<Response> getDocument({collectionId, documentId}) async {
Future<Response> getDocument({@required String collectionId, @required String documentId}) async {
String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
Future<Response> updateDocument({collectionId, documentId, data, read, write}) async {
Future<Response> updateDocument({@required String collectionId, @required String documentId, @required dynamic data, @required List read, @required List write}) async {
String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
Map<String, dynamic> params = {
@ -61,17 +66,17 @@ class Database extends Service {
'write': write,
};
return await this.client.call('patch', path: path, params: params);
return await this.client.call(HttpMethod.patch, path: path, params: params);
}
/// 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({collectionId, documentId}) async {
Future<Response> deleteDocument({@required String collectionId, @required String documentId}) async {
String path = '/database/collections/{collectionId}/documents/{documentId}'.replaceAll(RegExp('{collectionId}'), collectionId).replaceAll(RegExp('{documentId}'), documentId);
Map<String, dynamic> params = {
};
return await this.client.call('delete', path: path, params: params);
return await this.client.call(HttpMethod.delete, path: path, params: params);
}
}

View file

@ -1,6 +1,11 @@
import 'dart:html';
import "package:appwrite/service.dart";
import "package:appwrite/client.dart";
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import '../enums.dart';
class Locale extends Service {
@ -18,7 +23,7 @@ class Locale extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// List of all continents. You can use the locale header to get the data in a
/// supported language.
@ -28,7 +33,7 @@ class Locale extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// List of all countries. You can use the locale header to get the data in a
/// supported language.
@ -38,7 +43,7 @@ class Locale extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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.
@ -48,7 +53,7 @@ class Locale extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// List of all countries phone codes. You can use the locale header to get the
/// data in a supported language.
@ -58,7 +63,7 @@ class Locale extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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
@ -69,6 +74,6 @@ class Locale extends Service {
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
}

View file

@ -1,6 +1,11 @@
import 'dart:html';
import "package:appwrite/service.dart";
import "package:appwrite/client.dart";
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import '../enums.dart';
class Storage extends Service {
@ -9,7 +14,7 @@ class Storage extends Service {
/// 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({search = null, limit = 25, offset = null, orderType = 'ASC'}) async {
Future<Response> listFiles({String search = null, int limit = 25, int offset = null, String orderType = 'ASC'}) async {
String path = '/storage/files';
Map<String, dynamic> params = {
@ -19,12 +24,12 @@ class Storage extends Service {
'orderType': orderType,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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({file, read, write}) async {
Future<Response> createFile({@required File file, @required List read, @required List write}) async {
String path = '/storage/files';
Map<String, dynamic> params = {
@ -33,21 +38,21 @@ class Storage extends Service {
'write': write,
};
return await this.client.call('post', path: path, params: params);
return await this.client.call(HttpMethod.post, path: path, params: params);
}
/// Get file by its unique ID. This endpoint response returns a JSON object
/// with the file metadata.
Future<Response> getFile({fileId}) async {
Future<Response> getFile({@required String fileId}) async {
String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// Update file by its unique ID. Only users with write permissions have access
/// to update this resource.
Future<Response> updateFile({fileId, read, write}) async {
Future<Response> updateFile({@required String fileId, @required List read, @required List write}) async {
String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
Map<String, dynamic> params = {
@ -55,34 +60,34 @@ class Storage extends Service {
'write': write,
};
return await this.client.call('put', path: path, params: params);
return await this.client.call(HttpMethod.put, path: path, params: params);
}
/// Delete a file by its unique ID. Only users with write permissions have
/// access to delete this resource.
Future<Response> deleteFile({fileId}) async {
Future<Response> deleteFile({@required String fileId}) async {
String path = '/storage/files/{fileId}'.replaceAll(RegExp('{fileId}'), fileId);
Map<String, dynamic> params = {
};
return await this.client.call('delete', path: path, params: params);
return await this.client.call(HttpMethod.delete, path: path, params: params);
}
/// 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.
Future<Response> getFileDownload({fileId}) async {
Future<Response> getFileDownload({@required String fileId}) async {
String path = '/storage/files/{fileId}/download'.replaceAll(RegExp('{fileId}'), fileId);
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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.
Future<Response> getFilePreview({fileId, width = null, height = null, quality = 100, background = null, output = null}) async {
Future<Response> getFilePreview({@required String fileId, int width = null, int height = null, int quality = 100, String background = null, String output = null}) async {
String path = '/storage/files/{fileId}/preview'.replaceAll(RegExp('{fileId}'), fileId);
Map<String, dynamic> params = {
@ -93,17 +98,17 @@ class Storage extends Service {
'output': output,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// Get file content by its unique ID. This endpoint is similar to the download
/// method but returns with no 'Content-Disposition: attachment' header.
Future<Response> getFileView({fileId, as = null}) async {
Future<Response> getFileView({@required String fileId, String as = null}) async {
String path = '/storage/files/{fileId}/view'.replaceAll(RegExp('{fileId}'), fileId);
Map<String, dynamic> params = {
'as': as,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
}

View file

@ -1,6 +1,11 @@
import 'dart:html';
import "package:appwrite/service.dart";
import "package:appwrite/client.dart";
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import '../enums.dart';
class Teams extends Service {
@ -9,7 +14,7 @@ class Teams extends Service {
/// 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({search = null, limit = 25, offset = null, orderType = 'ASC'}) async {
Future<Response> list({String search = null, int limit = 25, int offset = null, String orderType = 'ASC'}) async {
String path = '/teams';
Map<String, dynamic> params = {
@ -19,13 +24,13 @@ class Teams extends Service {
'orderType': orderType,
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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({name, roles = const ["owner"]}) async {
Future<Response> create({@required String name, List roles = const ["owner"]}) async {
String path = '/teams';
Map<String, dynamic> params = {
@ -33,48 +38,48 @@ class Teams extends Service {
'roles': roles,
};
return await this.client.call('post', path: path, params: params);
return await this.client.call(HttpMethod.post, path: path, params: params);
}
/// Get team by its unique ID. All team members have read access for this
/// resource.
Future<Response> get({teamId}) async {
Future<Response> get({@required String teamId}) async {
String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// Update team by its unique ID. Only team owners have write access for this
/// resource.
Future<Response> update({teamId, name}) async {
Future<Response> update({@required String teamId, @required String name}) async {
String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
Map<String, dynamic> params = {
'name': name,
};
return await this.client.call('put', path: path, params: params);
return await this.client.call(HttpMethod.put, path: path, params: params);
}
/// Delete team by its unique ID. Only team owners have write access for this
/// resource.
Future<Response> delete({teamId}) async {
Future<Response> delete({@required String teamId}) async {
String path = '/teams/{teamId}'.replaceAll(RegExp('{teamId}'), teamId);
Map<String, dynamic> params = {
};
return await this.client.call('delete', path: path, params: params);
return await this.client.call(HttpMethod.delete, path: path, params: params);
}
/// Get team members by the team unique ID. All team members have read access
/// for this list of resources.
Future<Response> getMemberships({teamId}) async {
Future<Response> getMemberships({@required String teamId}) async {
String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
Map<String, dynamic> params = {
};
return await this.client.call('get', path: path, params: params);
return await this.client.call(HttpMethod.get, path: path, params: params);
}
/// 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
@ -89,7 +94,7 @@ class Teams extends Service {
/// 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({teamId, email, roles, url, name = null}) async {
Future<Response> createMembership({@required String teamId, @required String email, @required List roles, @required String url, String name = null}) async {
String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
Map<String, dynamic> params = {
@ -99,23 +104,23 @@ class Teams extends Service {
'url': url,
};
return await this.client.call('post', path: path, params: params);
return await this.client.call(HttpMethod.post, path: path, params: params);
}
/// 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({teamId, inviteId}) async {
Future<Response> deleteMembership({@required String teamId, @required String inviteId}) async {
String path = '/teams/{teamId}/memberships/{inviteId}'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId);
Map<String, dynamic> params = {
};
return await this.client.call('delete', path: path, params: params);
return await this.client.call(HttpMethod.delete, path: path, params: params);
}
/// 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({teamId, inviteId, userId, secret}) async {
Future<Response> updateMembershipStatus({@required String teamId, @required String inviteId, @required String userId, @required String secret}) async {
String path = '/teams/{teamId}/memberships/{inviteId}/status'.replaceAll(RegExp('{teamId}'), teamId).replaceAll(RegExp('{inviteId}'), inviteId);
Map<String, dynamic> params = {
@ -123,6 +128,6 @@ class Teams extends Service {
'secret': secret,
};
return await this.client.call('patch', path: path, params: params);
return await this.client.call(HttpMethod.patch, path: path, params: params);
}
}

View file

@ -4,7 +4,7 @@ description: Appwrite backend as a service cuts up to 70% of the time and costs
author: Appwrite Team <team@appwrite.io>
homepage: https://github.com/appwrite/sdk-for-dart
environment:
sdk: '>=2.2.2 <3.0.0'
sdk: '>=2.6.0 <3.0.0'
dependencies:
dio: ^3.0.0
cookie_jar: ^1.0.0

View file

@ -1,7 +1,7 @@
# Appwrite SDK for Go
![License](https://img.shields.io/github/license/appwrite/sdk-for-go.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1)
**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.**
@ -19,6 +19,10 @@ To install using `go get`:
go get github.com/appwrite/sdk-for-go
```
## 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

@ -1,7 +1,7 @@
# Appwrite SDK for NodeJS
![License](https://img.shields.io/github/license/appwrite/sdk-for-node.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1)
Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
@ -17,6 +17,10 @@ To install via [NPM](https://www.npmjs.com/):
npm install node-appwrite --save
```
## 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

@ -1,7 +1,7 @@
# Appwrite SDK for PHP
![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1)
Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
@ -17,6 +17,10 @@ To install via [Composer](http://getcomposer.org/):
composer require appwrite/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

@ -1,7 +1,7 @@
# Appwrite SDK for Python
![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1)
**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.**
@ -19,6 +19,10 @@ To install via [PyPI](https://pypi.org/):
pip install 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

@ -1,7 +1,7 @@
# Appwrite SDK for Ruby
![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1)
**This SDK is compatible with Appwrite server version . For older versions, please check previous releases.**
@ -19,6 +19,10 @@ To install via [Gem](https://rubygems.org/):
gem install appwrite --save
```
## 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

@ -1,7 +1,7 @@
# Appwrite SDK for JavaScript
![License](https://img.shields.io/github/license/appwrite/sdk-for-js.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.0-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.5.3-blue.svg?v=1)
Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
@ -33,6 +33,10 @@ To install with a CDN (content delivery network) add the following scripts to th
## 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

@ -15,6 +15,7 @@ use Appwrite\SDK\Language\Python;
use Appwrite\SDK\Language\Ruby;
use Appwrite\SDK\Language\Dart;
use Appwrite\SDK\Language\Go;
use Appwrite\SDK\Language\Typescript;
$cli = new CLI();
@ -40,6 +41,7 @@ $cli
$platforms = include __DIR__ . '/../config/platforms.php';
$message = Console::confirm('Please enter your commit message:');
$production = (Console::confirm('Type "Appwrite" to deploy for production') == 'Appwrite');
foreach($platforms as $key => $platform) {
foreach($platform['languages'] as $language) {
@ -51,7 +53,7 @@ $cli
Console::info('Fetching API Spec for '.$language['name'].' for '.$platform['name']);
//$spec = getSSLPage('http://localhost/v1/open-api-2.json?extensions=1&platform='.$language['family']);
$spec = getSSLPage('https://stage.appwrite.io/v1/open-api-2.json?extensions=1&platform='.$language['family']);
$spec = getSSLPage('https://appwrite.io/v1/open-api-2.json?extensions=1&platform='.$language['family']);
$result = realpath(__DIR__.'/..').'/sdks/'.$key.'-'.$language['key'];
$target = realpath(__DIR__.'/..').'/sdks/git/'.$language['key'].'/';
@ -87,6 +89,13 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
->setBowerPackage('appwrite')
;
break;
case 'typescript':
$config = new Typescript();
$config
->setNPMPackage('appwrite')
->setBowerPackage('appwrite')
;
break;
case 'nodejs':
$config = new Node();
$config
@ -157,7 +166,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
continue;
}
#$gitUrl = 'git@github.com:aw-tests/'.$language['gitRepoName'].'.git';
if(!$production) {
$gitUrl = 'git@github.com:aw-tests/'.$language['gitRepoName'].'.git';
}
exec('rm -rf '.$target.' && \
mkdir -p '.$target.' && \