Updated Web SDK
This commit is contained in:
parent
2366a0dcb4
commit
3f2524e17a
|
@ -2,9 +2,9 @@
|
|||
|
||||
[![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.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.6.1-blue.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.1. For older versions, please check previous releases.**
|
||||
**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 SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools.
|
||||
|
|
|
@ -10,7 +10,7 @@ void main() { // Init SDK
|
|||
;
|
||||
|
||||
Future result = account.createOAuth2Session(
|
||||
provider: 'bitbucket',
|
||||
provider: 'amazon',
|
||||
);
|
||||
|
||||
result
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
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.getInitials(
|
||||
);
|
||||
|
||||
print(result); // Resource URL string
|
||||
}
|
|
@ -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.getLanguages( );
|
||||
|
||||
result
|
||||
.then((response) {
|
||||
print(response);
|
||||
}).catchError((error) {
|
||||
print(error.response);
|
||||
});
|
||||
}
|
|
@ -33,10 +33,10 @@ class Account extends Service {
|
|||
///
|
||||
/// 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/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/account#createSession).
|
||||
/// 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';
|
||||
|
@ -195,7 +195,7 @@ class Account extends Service {
|
|||
/// 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/account#updateRecovery)
|
||||
/// request to the [PUT /account/recovery](/docs/client/account#updateRecovery)
|
||||
/// endpoint to complete the process.
|
||||
///
|
||||
Future<Response> createRecovery({@required String email, @required String url}) {
|
||||
|
@ -218,7 +218,7 @@ class Account extends Service {
|
|||
/// 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/account#createRecovery) endpoint.
|
||||
/// /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)
|
||||
|
@ -305,12 +305,13 @@ class Account extends Service {
|
|||
/// 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'}) {
|
||||
Future createOAuth2Session({@required String provider, String success = 'https://appwrite.io/auth/oauth2/success', String failure = 'https://appwrite.io/auth/oauth2/failure', List scopes = const []}) {
|
||||
final String path = '/account/sessions/oauth2/{provider}'.replaceAll(RegExp('{provider}'), provider);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'success': success,
|
||||
'failure': failure,
|
||||
'scopes': scopes,
|
||||
'project': client.config['project'],
|
||||
};
|
||||
|
||||
|
@ -361,7 +362,7 @@ class Account extends Service {
|
|||
/// 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/account#updateAccountVerification).
|
||||
/// 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)
|
||||
|
|
|
@ -145,6 +145,42 @@ class Avatars extends Service {
|
|||
return location.toString();
|
||||
}
|
||||
|
||||
/// Get User Initials
|
||||
///
|
||||
/// Use this endpoint to show your user initials avatar icon on your website or
|
||||
/// app. By default, this route will try to print your logged-in user name or
|
||||
/// email initials. You can also overwrite the user name if you pass the 'name'
|
||||
/// parameter. If no name is given and no user is logged, an empty avatar will
|
||||
/// be returned.
|
||||
///
|
||||
/// You can use the color and background params to change the avatar colors. By
|
||||
/// default, a random theme will be selected. The random theme will persist for
|
||||
/// the user's initials when reloading the same theme will always return for
|
||||
/// the same initials.
|
||||
///
|
||||
String getInitials({String name = '', int width = 500, int height = 500, String color = '', String background = ''}) {
|
||||
final String path = '/avatars/initials';
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'name': name,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'color': color,
|
||||
'background': background,
|
||||
'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
|
||||
|
|
|
@ -41,7 +41,10 @@ class Database extends Service {
|
|||
|
||||
/// Create Document
|
||||
///
|
||||
/// Create a new 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);
|
||||
|
|
|
@ -106,9 +106,9 @@ class Locale extends Service {
|
|||
|
||||
/// 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.
|
||||
/// List of all currencies, including currency symbol, 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';
|
||||
|
@ -120,6 +120,24 @@ class Locale extends Service {
|
|||
'content-type': 'application/json',
|
||||
};
|
||||
|
||||
return client.call(HttpMethod.get, path: path, params: params, headers: headers);
|
||||
}
|
||||
|
||||
/// List Languages
|
||||
///
|
||||
/// List of all languages classified by ISO 639-1 including 2-letter code, name
|
||||
/// in English, and name in the respective language.
|
||||
///
|
||||
Future<Response> getLanguages() {
|
||||
final String path = '/locale/languages';
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -115,10 +115,14 @@ class Teams extends Service {
|
|||
/// 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}) {
|
||||
Future<Response> getMemberships({@required String teamId, String search = '', int limit = 25, int offset = 0, OrderType orderType = OrderType.asc}) {
|
||||
final String path = '/teams/{teamId}/memberships'.replaceAll(RegExp('{teamId}'), teamId);
|
||||
|
||||
final Map<String, dynamic> params = {
|
||||
'search': search,
|
||||
'limit': limit,
|
||||
'offset': offset,
|
||||
'orderType': orderType.name(),
|
||||
};
|
||||
|
||||
final Map<String, String> headers = {
|
||||
|
@ -136,8 +140,8 @@ class Teams extends Service {
|
|||
///
|
||||
/// 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/teams#updateMembershipStatus) endpoint to allow the user to
|
||||
/// accept the invitation to the team.
|
||||
/// 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)
|
||||
|
|
12
composer.lock
generated
12
composer.lock
generated
|
@ -485,12 +485,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "ba7930ff4209374c2817738e408eeeedcf42fa7b"
|
||||
"reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/ba7930ff4209374c2817738e408eeeedcf42fa7b",
|
||||
"reference": "ba7930ff4209374c2817738e408eeeedcf42fa7b",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
|
||||
"reference": "9d4290de1cfd701f38099ef7e183b64b4b7b0c5e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -544,7 +544,7 @@
|
|||
"rest",
|
||||
"web service"
|
||||
],
|
||||
"time": "2020-06-16T09:06:57+00:00"
|
||||
"time": "2020-06-16T21:01:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
|
@ -1753,7 +1753,7 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/appwrite/sdk-generator",
|
||||
"reference": "e2b2752bd789defc87475a4fe118d10702807683"
|
||||
"reference": "0125b705aa78e4432972fdcc9de3c42b65ee2024"
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
|
@ -1783,7 +1783,7 @@
|
|||
}
|
||||
],
|
||||
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
||||
"time": "2020-06-16T19:14:00+00:00"
|
||||
"time": "2020-06-17T10:09:35+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
|
|
Loading…
Reference in a new issue