Skip to content

Commit 439d798

Browse files
authored
Merge pull request #275 from appwrite/dev
feat: Flutter SDK update for version 20.1.0
2 parents 7c5b893 + c857cbc commit 439d798

File tree

10 files changed

+145
-10
lines changed

10 files changed

+145
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## 20.1.0
4+
5+
* Deprecate `createVerification` method in `Account` service
6+
* Add `createEmailVerification` method in `Account` service
7+
38
## 19.1.0
49

510
* Add `orderRandom` query support

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:
2121

2222
```yml
2323
dependencies:
24-
appwrite: ^20.0.0
24+
appwrite: ^20.1.0
2525
```
2626
2727
You can install packages from the command line:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'package:appwrite/appwrite.dart';
2+
3+
Client client = Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
Account account = Account(client);
8+
9+
Token result = await account.createEmailVerification(
10+
url: 'https://example.com',
11+
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'package:appwrite/appwrite.dart';
2+
3+
Client client = Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
Account account = Account(client);
8+
9+
Token result = await account.updateEmailVerification(
10+
userId: '<USER_ID>',
11+
secret: '<SECRET>',
12+
);

lib/services/account.dart

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,8 +1378,43 @@ class Account extends Service {
13781378
/// the only valid redirect URLs are the ones from domains you have set when
13791379
/// adding your platforms in the console interface.
13801380
///
1381+
Future<models.Token> createEmailVerification({required String url}) async {
1382+
const String apiPath = '/account/verifications/email';
1383+
1384+
final Map<String, dynamic> apiParams = {'url': url};
1385+
1386+
final Map<String, String> apiHeaders = {'content-type': 'application/json'};
1387+
1388+
final res = await client.call(
1389+
HttpMethod.post,
1390+
path: apiPath,
1391+
params: apiParams,
1392+
headers: apiHeaders,
1393+
);
1394+
1395+
return models.Token.fromMap(res.data);
1396+
}
1397+
1398+
/// Use this endpoint to send a verification message to your user email address
1399+
/// to confirm they are the valid owners of that address. Both the **userId**
1400+
/// and **secret** arguments will be passed as query parameters to the URL you
1401+
/// have provided to be attached to the verification email. The provided URL
1402+
/// should redirect the user back to your app and allow you to complete the
1403+
/// verification process by verifying both the **userId** and **secret**
1404+
/// parameters. Learn more about how to [complete the verification
1405+
/// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
1406+
/// The verification link sent to the user's email address is valid for 7 days.
1407+
///
1408+
/// Please note that in order to avoid a [Redirect
1409+
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
1410+
/// the only valid redirect URLs are the ones from domains you have set when
1411+
/// adding your platforms in the console interface.
1412+
///
1413+
@Deprecated(
1414+
'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.',
1415+
)
13811416
Future<models.Token> createVerification({required String url}) async {
1382-
const String apiPath = '/account/verification';
1417+
const String apiPath = '/account/verifications/email';
13831418

13841419
final Map<String, dynamic> apiParams = {'url': url};
13851420

@@ -1399,11 +1434,38 @@ class Account extends Service {
13991434
/// the **userId** and **secret** parameters that were attached to your app URL
14001435
/// to verify the user email ownership. If confirmed this route will return a
14011436
/// 200 status code.
1437+
Future<models.Token> updateEmailVerification({
1438+
required String userId,
1439+
required String secret,
1440+
}) async {
1441+
const String apiPath = '/account/verifications/email';
1442+
1443+
final Map<String, dynamic> apiParams = {'userId': userId, 'secret': secret};
1444+
1445+
final Map<String, String> apiHeaders = {'content-type': 'application/json'};
1446+
1447+
final res = await client.call(
1448+
HttpMethod.put,
1449+
path: apiPath,
1450+
params: apiParams,
1451+
headers: apiHeaders,
1452+
);
1453+
1454+
return models.Token.fromMap(res.data);
1455+
}
1456+
1457+
/// Use this endpoint to complete the user email verification process. Use both
1458+
/// the **userId** and **secret** parameters that were attached to your app URL
1459+
/// to verify the user email ownership. If confirmed this route will return a
1460+
/// 200 status code.
1461+
@Deprecated(
1462+
'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.',
1463+
)
14021464
Future<models.Token> updateVerification({
14031465
required String userId,
14041466
required String secret,
14051467
}) async {
1406-
const String apiPath = '/account/verification';
1468+
const String apiPath = '/account/verifications/email';
14071469

14081470
final Map<String, dynamic> apiParams = {'userId': userId, 'secret': secret};
14091471

@@ -1428,7 +1490,7 @@ class Account extends Service {
14281490
/// The verification code sent to the user's phone number is valid for 15
14291491
/// minutes.
14301492
Future<models.Token> createPhoneVerification() async {
1431-
const String apiPath = '/account/verification/phone';
1493+
const String apiPath = '/account/verifications/phone';
14321494

14331495
final Map<String, dynamic> apiParams = {};
14341496

@@ -1452,7 +1514,7 @@ class Account extends Service {
14521514
required String userId,
14531515
required String secret,
14541516
}) async {
1455-
const String apiPath = '/account/verification/phone';
1517+
const String apiPath = '/account/verifications/phone';
14561518

14571519
final Map<String, dynamic> apiParams = {'userId': userId, 'secret': secret};
14581520

lib/services/tables_db.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TablesDB extends Service {
3131

3232
/// Create a new Row. Before using this route, you should create a new table
3333
/// resource using either a [server
34-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
34+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
3535
/// API or directly from your database console.
3636
Future<models.Row> createRow({
3737
required String databaseId,
@@ -92,7 +92,7 @@ class TablesDB extends Service {
9292

9393
/// Create or update a Row. Before using this route, you should create a new
9494
/// table resource using either a [server
95-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
95+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
9696
/// API or directly from your database console.
9797
Future<models.Row> upsertRow({
9898
required String databaseId,

lib/src/client_browser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
4040
'x-sdk-name': 'Flutter',
4141
'x-sdk-platform': 'client',
4242
'x-sdk-language': 'flutter',
43-
'x-sdk-version': '20.0.0',
43+
'x-sdk-version': '20.1.0',
4444
'X-Appwrite-Response-Format': '1.8.0',
4545
};
4646

lib/src/client_io.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ClientIO extends ClientBase with ClientMixin {
5858
'x-sdk-name': 'Flutter',
5959
'x-sdk-platform': 'client',
6060
'x-sdk-language': 'flutter',
61-
'x-sdk-version': '20.0.0',
61+
'x-sdk-version': '20.1.0',
6262
'X-Appwrite-Response-Format': '1.8.0',
6363
};
6464

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: appwrite
2-
version: 20.0.0
2+
version: 20.1.0
33
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
44
homepage: https://appwrite.io
55
repository: https://github.com/appwrite/sdk-for-flutter

test/services/account_test.dart

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,28 @@ void main() {
13801380

13811381
});
13821382

1383+
test('test method createEmailVerification()', () async {
1384+
final Map<String, dynamic> data = {
1385+
'\$id': 'bb8ea5c16897e',
1386+
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
1387+
'userId': '5e5ea5c168bb8',
1388+
'secret': '',
1389+
'expire': '2020-10-15T06:38:00.000+00:00',
1390+
'phrase': 'Golden Fox',};
1391+
1392+
1393+
when(client.call(
1394+
HttpMethod.post,
1395+
)).thenAnswer((_) async => Response(data: data));
1396+
1397+
1398+
final response = await account.createEmailVerification(
1399+
url: 'https://example.com',
1400+
);
1401+
expect(response, isA<models.Token>());
1402+
1403+
});
1404+
13831405
test('test method createVerification()', () async {
13841406
final Map<String, dynamic> data = {
13851407
'\$id': 'bb8ea5c16897e',
@@ -1402,6 +1424,29 @@ void main() {
14021424

14031425
});
14041426

1427+
test('test method updateEmailVerification()', () async {
1428+
final Map<String, dynamic> data = {
1429+
'\$id': 'bb8ea5c16897e',
1430+
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
1431+
'userId': '5e5ea5c168bb8',
1432+
'secret': '',
1433+
'expire': '2020-10-15T06:38:00.000+00:00',
1434+
'phrase': 'Golden Fox',};
1435+
1436+
1437+
when(client.call(
1438+
HttpMethod.put,
1439+
)).thenAnswer((_) async => Response(data: data));
1440+
1441+
1442+
final response = await account.updateEmailVerification(
1443+
userId: '<USER_ID>',
1444+
secret: '<SECRET>',
1445+
);
1446+
expect(response, isA<models.Token>());
1447+
1448+
});
1449+
14051450
test('test method updateVerification()', () async {
14061451
final Map<String, dynamic> data = {
14071452
'\$id': 'bb8ea5c16897e',

0 commit comments

Comments
 (0)