Skip to content

Commit

Permalink
Update for 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
abnegate committed Sep 14, 2022
1 parent 0e1916c commit 5a27780
Show file tree
Hide file tree
Showing 20 changed files with 256 additions and 41 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
## 8.0.0-dev.2 Latest

### NEW
* Support for Appwrite 1.0.0-RC1
* More verbose headers have been included in the Clients - `x-sdk-name`, `x-sdk-platform`, `x-sdk-language`, `x-sdk-version`
* Helper classes and methods for Permissions, Roles and IDs
* Helper methods to suport new queries
* All Dates and times are now returned in the ISO 8601 format

### BREAKING CHANGES

* `databaseId` is no longer part of the `Database` Service constructor. `databaseId` will be part of the respective methods of the database service.
* `color` attribute is no longer supported in the Avatars Service
* The `number` argument in phone endpoints have been renamed to `phone`
* List endpoints no longer support `limit`, `offset`, `cursor`, `cursorDirection`, `orderAttributes`, `orderTypes` as they have been moved to the `queries` array
* `read` and `write` permission have been deprecated and they are now included in the `permissions` array
* Renamed methods of the Query helper
1. `lesser` renamed to `lessThan`
2. `lesserEqual` renamed to `lessThanEqual`
3. `greater` renamed to `greaterThan`
4. `greaterEqual` renamed to `greaterThanEqual`
* `User` response model is now renamed to `Account`

**Full Changelog for Appwrite 1.0.0-RC1 can be found here**:
https://github.com/appwrite/appwrite/blob/master/CHANGES.md

## 7.0.0
* **BREAKING** Switched to using [flutter_web_auth_2](https://pub.dev/packages/flutter_web_auth_2), check Getting Started section in Readme for changes (Android and Web will require adjustments for OAuth to work properly)
* Fixes Concurrent modification issue
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

[![pub package](https://img.shields.io/pub/v/appwrite?style=flat-square)](https://pub.dartlang.org/packages/appwrite)
![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.0.0-RC1-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.0.0-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

**This SDK is compatible with Appwrite server version 1.0.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).**
**This SDK is compatible with Appwrite server version 1.0.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. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)

Expand All @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
appwrite: ^8.0.0-dev.2
appwrite: ^8.0.0
```
You can install packages from the command line:
Expand Down Expand Up @@ -134,9 +134,9 @@ When trying to connect to Appwrite from an emulator or a mobile device, localhos
```dart
// Register User
Account account = Account(client);
Response user = await account
final user = await account
.create(
userId: '[USER_ID]',
userId: ID.unique(),
email: 'me@appwrite.io',
password: 'password',
name: 'My Name'
Expand All @@ -162,9 +162,9 @@ void main() {
// Register User
Account account = Account(client);
Response user = await account
final user = await account
.create(
userId: '[USER_ID]',
userId: ID.unique(),
email: 'me@appwrite.io',
password: 'password',
name: 'My Name'
Expand All @@ -173,14 +173,14 @@ void main() {
```

### Error Handling
The Appwrite Flutter SDK raises `AppwriteException` object with `message`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.
The Appwrite Flutter SDK raises `AppwriteException` object with `message`, `type`, `code` and `response` properties. You can handle any errors by catching `AppwriteException` and present the `message` to the user or handle it yourself based on the provided error information. Below is an example.

```dart
Users users = Users(client);
Account account = Account(client);
try {
final response = await users.create(userId: '[USER_ID]', email: ‘email@example.com’,password: ‘password’, name: ‘name’);
print(response.data);
final user = await account.create(userId: ID.unique(), email: ‘email@example.com’,password: ‘password’, name: ‘name’);
print(user.toMap());
} on AppwriteException catch(e) {
//show message to user or do other operation based on error as required
print(e.message);
Expand Down
20 changes: 20 additions & 0 deletions docs/examples/account/list-logs.md
Original file line number Diff line number Diff line change
@@ -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.listLogs(
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
19 changes: 19 additions & 0 deletions docs/examples/account/list-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.listSessions();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
19 changes: 19 additions & 0 deletions docs/examples/locale/list-continents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.listContinents();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
19 changes: 19 additions & 0 deletions docs/examples/locale/list-countries-e-u.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.listCountriesEU();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
19 changes: 19 additions & 0 deletions docs/examples/locale/list-countries-phones.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.listCountriesPhones();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
19 changes: 19 additions & 0 deletions docs/examples/locale/list-countries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.listCountries();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
19 changes: 19 additions & 0 deletions docs/examples/locale/list-currencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.listCurrencies();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
19 changes: 19 additions & 0 deletions docs/examples/locale/list-languages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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.listLanguages();

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
21 changes: 21 additions & 0 deletions docs/examples/teams/list-memberships.md
Original file line number Diff line number Diff line change
@@ -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.listMemberships(
teamId: '[TEAM_ID]',
);

result
.then((response) {
print(response);
}).catchError((error) {
print(error.response);
});
}
18 changes: 14 additions & 4 deletions lib/role.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ class Role {
return 'any';
}

static String user(String id) {
return 'user:$id';
static String user(String id, [String status = '']) {
if(status.isEmpty) {
return 'user:$id';
}
return 'user:$id/$status';
}

static String users() {
return 'users';
static String users([String status = '']) {
if(status.isEmpty) {
return 'users';
}
return 'users/$status';
}

static String guests() {
Expand All @@ -23,6 +29,10 @@ class Role {
}
return 'team:$id/$role';
}

static String member(String id) {
return 'member:$id';
}

static String status(String status) {
return 'status:$status';
Expand Down
8 changes: 4 additions & 4 deletions lib/services/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ class Account extends Service {

}

/// Get Account Logs
/// List 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<models.LogList> getLogs({List<String>? queries}) async {
Future<models.LogList> listLogs({List<String>? queries}) async {
const String path = '/account/logs';

final Map<String, dynamic> params = {
Expand Down Expand Up @@ -303,12 +303,12 @@ class Account extends Service {

}

/// Get Account Sessions
/// List Account Sessions
///
/// Get currently logged in user list of active sessions across different
/// devices.
///
Future<models.SessionList> getSessions() async {
Future<models.SessionList> listSessions() async {
const String path = '/account/sessions';

final Map<String, dynamic> params = {
Expand Down
12 changes: 6 additions & 6 deletions lib/services/locale.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Locale extends Service {
/// List of all continents. You can use the locale header to get the data in a
/// supported language.
///
Future<models.ContinentList> getContinents() async {
Future<models.ContinentList> listContinents() async {
const String path = '/locale/continents';

final Map<String, dynamic> params = {
Expand All @@ -56,7 +56,7 @@ class Locale extends Service {
/// List of all countries. You can use the locale header to get the data in a
/// supported language.
///
Future<models.CountryList> getCountries() async {
Future<models.CountryList> listCountries() async {
const String path = '/locale/countries';

final Map<String, dynamic> params = {
Expand All @@ -77,7 +77,7 @@ class Locale extends Service {
/// 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<models.CountryList> getCountriesEU() async {
Future<models.CountryList> listCountriesEU() async {
const String path = '/locale/countries/eu';

final Map<String, dynamic> params = {
Expand All @@ -98,7 +98,7 @@ class Locale extends Service {
/// List of all countries phone codes. You can use the locale header to get the
/// data in a supported language.
///
Future<models.PhoneList> getCountriesPhones() async {
Future<models.PhoneList> listCountriesPhones() async {
const String path = '/locale/countries/phones';

final Map<String, dynamic> params = {
Expand All @@ -120,7 +120,7 @@ class Locale extends Service {
/// decimal digits for all major and minor currencies. You can use the locale
/// header to get the data in a supported language.
///
Future<models.CurrencyList> getCurrencies() async {
Future<models.CurrencyList> listCurrencies() async {
const String path = '/locale/currencies';

final Map<String, dynamic> params = {
Expand All @@ -141,7 +141,7 @@ class Locale extends Service {
/// List of all languages classified by ISO 639-1 including 2-letter code, name
/// in English, and name in the respective language.
///
Future<models.LanguageList> getLanguages() async {
Future<models.LanguageList> listLanguages() async {
const String path = '/locale/languages';

final Map<String, dynamic> params = {
Expand Down
Loading

0 comments on commit 5a27780

Please sign in to comment.