Skip to content

Commit

Permalink
Upgraded to support Appwrite 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eldadfux committed Feb 11, 2021
1 parent 876a3c0 commit ac0fc40
Show file tree
Hide file tree
Showing 27 changed files with 224 additions and 77 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2019 Appwrite (https://appwrite.io) and individual contributors.
Copyright (c) 2021 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:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.2-blue.svg?v=1)
![Version](https://img.shields.io/badge/api%20version-0.7.0-blue.svg?v=1)

**This SDK is compatible with Appwrite server version 0.6.2. For older versions, please check previous releases.**
**This SDK is compatible with Appwrite server version 0.7.0. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/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.
Expand All @@ -20,7 +20,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
appwrite: ^0.3.0-dev.2
appwrite: ^0.3.0
```
You can install packages from the command line:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/delete-sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = account.deleteSessions( );
Future result = account.deleteSessions();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = account.delete( );
Future result = account.delete();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/get-logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = account.getLogs( );
Future result = account.getLogs();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/get-prefs.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = account.getPrefs( );
Future result = account.getPrefs();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/get-sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = account.getSessions( );
Future result = account.getSessions();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/account/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = account.get( );
Future result = account.get();

result
.then((response) {
Expand Down
22 changes: 22 additions & 0 deletions docs/examples/functions/create-execution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';

void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = functions.createExecution(
functionId: '[FUNCTION_ID]',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
23 changes: 23 additions & 0 deletions docs/examples/functions/get-execution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:appwrite/appwrite.dart';

void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = functions.getExecution(
functionId: '[FUNCTION_ID]',
executionId: '[EXECUTION_ID]',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
22 changes: 22 additions & 0 deletions docs/examples/functions/list-executions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:appwrite/appwrite.dart';

void main() { // Init SDK
Client client = Client();
Functions functions = Functions(client);

client
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = functions.listExecutions(
functionId: '[FUNCTION_ID]',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
2 changes: 1 addition & 1 deletion docs/examples/locale/get-continents.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = locale.getContinents( );
Future result = locale.getContinents();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/locale/get-countries-e-u.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = locale.getCountriesEU( );
Future result = locale.getCountriesEU();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/locale/get-countries-phones.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = locale.getCountriesPhones( );
Future result = locale.getCountriesPhones();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/locale/get-countries.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = locale.getCountries( );
Future result = locale.getCountries();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/locale/get-currencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = locale.getCurrencies( );
Future result = locale.getCurrencies();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/locale/get-languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = locale.getLanguages( );
Future result = locale.getLanguages();

result
.then((response) {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/locale/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() { // Init SDK
.setProject('5df5acd0d48c2') // Your project ID
;

Future result = locale.get( );
Future result = locale.get();

result
.then((response) {
Expand Down
1 change: 1 addition & 0 deletions lib/appwrite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export 'enums.dart';
export 'services/account.dart';
export 'services/avatars.dart';
export 'services/database.dart';
export 'services/functions.dart';
export 'services/locale.dart';
export 'services/storage.dart';
export 'services/teams.dart';
8 changes: 4 additions & 4 deletions lib/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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 'package:package_info_plus/package_info_plus.dart';

import 'enums.dart';

Expand Down Expand Up @@ -35,7 +35,7 @@ class Client {

this.headers = {
'content-type': 'application/json',
'x-sdk-version': 'appwrite:flutter:0.3.0-dev.2',
'x-sdk-version': 'appwrite:flutter:0.3.0',
};

this.config = {};
Expand Down Expand Up @@ -89,7 +89,7 @@ class Client {
cookieJar = new PersistCookieJar(dir:cookieDir.path);
this.http.interceptors.add(CookieManager(cookieJar));
PackageInfo packageInfo = await PackageInfo.fromPlatform();
addHeader('Origin', 'appwrite-' + type + '://' + packageInfo.packageName);
addHeader('Origin', 'appwrite-$type://${packageInfo.packageName ?? packageInfo.appName}');
}else{
// if web set httpClientAdapter as BrowserHttpClientAdapter with withCredentials true to make cookies work
this.http.options.extra['withCredentials'] = true;
Expand Down Expand Up @@ -131,4 +131,4 @@ class Client {
return http.request(path, data: params, options: options);
}
}
}
}
29 changes: 15 additions & 14 deletions lib/services/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,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/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).
/// the [/account/verfication](/docs/client/account#accountCreateVerification)
/// route to start verifying the user email address. To allow the new user to
/// login to their new account, you need to create a new [account
/// session](/docs/client/account#accountCreateSession).
///
Future<Response> create({@required String email, @required String password, String name = ''}) {
final String path = '/account';
Expand Down Expand Up @@ -177,7 +177,7 @@ class Account extends Service {
/// Update currently logged in user account preferences. You can pass only the
/// specific settings you wish to update.
///
Future<Response> updatePrefs({@required dynamic prefs}) {
Future<Response> updatePrefs({@required Map prefs}) {
final String path = '/account/prefs';

final Map<String, dynamic> params = {
Expand All @@ -197,8 +197,9 @@ 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/client/account#updateRecovery)
/// endpoint to complete the process.
/// request to the [PUT
/// /account/recovery](/docs/client/account#accountUpdateRecovery) endpoint to
/// complete the process.
///
Future<Response> createRecovery({@required String email, @required String url}) {
final String path = '/account/recovery';
Expand All @@ -220,7 +221,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/client/account#createRecovery) endpoint.
/// /account/recovery](/docs/client/account#accountCreateRecovery) 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)
Expand Down Expand Up @@ -264,7 +265,7 @@ class Account extends Service {

/// Create Account Session
///
/// Allow the user to login into his account by providing a valid email and
/// Allow the user to login into their account by providing a valid email and
/// password combination. This route will create a new session for the user.
///
Future<Response> createSession({@required String email, @required String password}) {
Expand Down Expand Up @@ -302,7 +303,7 @@ class Account extends Service {

/// Create Account Session with OAuth2
///
/// Allow the user to login to his account using the OAuth2 provider of his
/// Allow the user to login to their account using the OAuth2 provider of their
/// 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.
Expand Down Expand Up @@ -363,9 +364,9 @@ class Account extends Service {

/// 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.
/// Use this endpoint to log out the currently logged in user from all their
/// account sessions across all of their different devices. When using the
/// option id argument, only the session unique ID provider will be deleted.
///
Future<Response> deleteSession({@required String sessionId}) {
final String path = '/account/sessions/{sessionId}'.replaceAll(RegExp('{sessionId}'), sessionId);
Expand All @@ -389,7 +390,7 @@ class Account extends Service {
/// should redirect the user back to your app and allow you to complete the
/// verification process by verifying both the **userId** and **secret**
/// parameters. Learn more about how to [complete the verification
/// process](/docs/client/account#updateAccountVerification).
/// process](/docs/client/account#accountUpdateVerification).
///
/// 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),
Expand Down
10 changes: 5 additions & 5 deletions lib/services/avatars.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ class Avatars extends Service {

/// 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.
/// 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);
Expand Down Expand Up @@ -76,8 +75,9 @@ class Avatars extends Service {

/// Get Favicon
///
/// Use this endpoint to fetch the favorite icon (AKA favicon) of a any remote
/// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
/// website URL.
///
///
String getFavicon({@required String url}) {
final String path = '/avatars/favicon';
Expand Down
Loading

0 comments on commit ac0fc40

Please sign in to comment.