Skip to content

Commit a450e75

Browse files
authored
Merge pull request #93 from appwrite/dev
feat: Dart SDK update for version 19.1.0
2 parents 79e7367 + f1e4ae2 commit a450e75

File tree

12 files changed

+154
-17
lines changed

12 files changed

+154
-17
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+
## 19.1.0
4+
5+
* Deprecate `createVerification` method in `Account` service
6+
* Add `createEmailVerification` method in `Account` service
7+
38
## 18.1.0
49

510
* Add `orderRandom` query support

README.md

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

2424
```yml
2525
dependencies:
26-
dart_appwrite: ^19.0.0
26+
dart_appwrite: ^19.1.0
2727
```
2828
2929
You can install packages from the command line:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import 'package:dart_appwrite/dart_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+
.setSession(''); // The user session to authenticate with
7+
8+
Account account = Account(client);
9+
10+
Token result = await account.createEmailVerification(
11+
url: 'https://example.com',
12+
);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'package:dart_appwrite/dart_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+
.setSession(''); // The user session to authenticate with
7+
8+
Account account = Account(client);
9+
10+
Token result = await account.updateEmailVerification(
11+
userId: '<USER_ID>',
12+
secret: '<SECRET>',
13+
);

lib/services/account.dart

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,8 +1235,43 @@ class Account extends Service {
12351235
/// the only valid redirect URLs are the ones from domains you have set when
12361236
/// adding your platforms in the console interface.
12371237
///
1238+
Future<models.Token> createEmailVerification({required String url}) async {
1239+
final String apiPath = '/account/verifications/email';
1240+
1241+
final Map<String, dynamic> apiParams = {'url': url};
1242+
1243+
final Map<String, String> apiHeaders = {'content-type': 'application/json'};
1244+
1245+
final res = await client.call(
1246+
HttpMethod.post,
1247+
path: apiPath,
1248+
params: apiParams,
1249+
headers: apiHeaders,
1250+
);
1251+
1252+
return models.Token.fromMap(res.data);
1253+
}
1254+
1255+
/// Use this endpoint to send a verification message to your user email address
1256+
/// to confirm they are the valid owners of that address. Both the **userId**
1257+
/// and **secret** arguments will be passed as query parameters to the URL you
1258+
/// have provided to be attached to the verification email. The provided URL
1259+
/// should redirect the user back to your app and allow you to complete the
1260+
/// verification process by verifying both the **userId** and **secret**
1261+
/// parameters. Learn more about how to [complete the verification
1262+
/// process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
1263+
/// The verification link sent to the user's email address is valid for 7 days.
1264+
///
1265+
/// Please note that in order to avoid a [Redirect
1266+
/// Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md),
1267+
/// the only valid redirect URLs are the ones from domains you have set when
1268+
/// adding your platforms in the console interface.
1269+
///
1270+
@Deprecated(
1271+
'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.',
1272+
)
12381273
Future<models.Token> createVerification({required String url}) async {
1239-
final String apiPath = '/account/verification';
1274+
final String apiPath = '/account/verifications/email';
12401275

12411276
final Map<String, dynamic> apiParams = {'url': url};
12421277

@@ -1256,11 +1291,38 @@ class Account extends Service {
12561291
/// the **userId** and **secret** parameters that were attached to your app URL
12571292
/// to verify the user email ownership. If confirmed this route will return a
12581293
/// 200 status code.
1294+
Future<models.Token> updateEmailVerification({
1295+
required String userId,
1296+
required String secret,
1297+
}) async {
1298+
final String apiPath = '/account/verifications/email';
1299+
1300+
final Map<String, dynamic> apiParams = {'userId': userId, 'secret': secret};
1301+
1302+
final Map<String, String> apiHeaders = {'content-type': 'application/json'};
1303+
1304+
final res = await client.call(
1305+
HttpMethod.put,
1306+
path: apiPath,
1307+
params: apiParams,
1308+
headers: apiHeaders,
1309+
);
1310+
1311+
return models.Token.fromMap(res.data);
1312+
}
1313+
1314+
/// Use this endpoint to complete the user email verification process. Use both
1315+
/// the **userId** and **secret** parameters that were attached to your app URL
1316+
/// to verify the user email ownership. If confirmed this route will return a
1317+
/// 200 status code.
1318+
@Deprecated(
1319+
'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.',
1320+
)
12591321
Future<models.Token> updateVerification({
12601322
required String userId,
12611323
required String secret,
12621324
}) async {
1263-
final String apiPath = '/account/verification';
1325+
final String apiPath = '/account/verifications/email';
12641326

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

@@ -1285,7 +1347,7 @@ class Account extends Service {
12851347
/// The verification code sent to the user's phone number is valid for 15
12861348
/// minutes.
12871349
Future<models.Token> createPhoneVerification() async {
1288-
final String apiPath = '/account/verification/phone';
1350+
final String apiPath = '/account/verifications/phone';
12891351

12901352
final Map<String, dynamic> apiParams = {};
12911353

@@ -1309,7 +1371,7 @@ class Account extends Service {
13091371
required String userId,
13101372
required String secret,
13111373
}) async {
1312-
final String apiPath = '/account/verification/phone';
1374+
final String apiPath = '/account/verifications/phone';
13131375

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

lib/services/functions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ class Functions extends Service {
360360
/// Create a deployment based on a template.
361361
///
362362
/// Use this endpoint with combination of
363-
/// [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to
363+
/// [listTemplates](https://appwrite.io/docs/products/functions/templates) to
364364
/// find the template details.
365365
Future<models.Deployment> createTemplateDeployment({
366366
required String functionId,

lib/services/sites.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ class Sites extends Service {
338338
/// Create a deployment based on a template.
339339
///
340340
/// Use this endpoint with combination of
341-
/// [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to
342-
/// find the template details.
341+
/// [listTemplates](https://appwrite.io/docs/products/sites/templates) to find
342+
/// the template details.
343343
Future<models.Deployment> createTemplateDeployment({
344344
required String siteId,
345345
required String repository,

lib/services/tables_db.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class TablesDB extends Service {
155155

156156
/// Create a new Table. Before using this route, you should create a new
157157
/// database resource using either a [server
158-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
158+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
159159
/// API or directly from your database console.
160160
Future<models.Table> createTable({
161161
required String databaseId,
@@ -1396,7 +1396,7 @@ class TablesDB extends Service {
13961396

13971397
/// Create a new Row. Before using this route, you should create a new table
13981398
/// resource using either a [server
1399-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1399+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
14001400
/// API or directly from your database console.
14011401
Future<models.Row> createRow({
14021402
required String databaseId,
@@ -1429,7 +1429,7 @@ class TablesDB extends Service {
14291429

14301430
/// Create new Rows. Before using this route, you should create a new table
14311431
/// resource using either a [server
1432-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1432+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
14331433
/// API or directly from your database console.
14341434
Future<models.RowList> createRows({
14351435
required String databaseId,
@@ -1456,7 +1456,7 @@ class TablesDB extends Service {
14561456

14571457
/// Create or update Rows. Before using this route, you should create a new
14581458
/// table resource using either a [server
1459-
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
1459+
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
14601460
/// API or directly from your database console.
14611461
///
14621462
Future<models.RowList> upsertRows({
@@ -1563,7 +1563,7 @@ class TablesDB extends Service {
15631563

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

lib/src/client_browser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
3030
'x-sdk-name': 'Dart',
3131
'x-sdk-platform': 'server',
3232
'x-sdk-language': 'dart',
33-
'x-sdk-version': '19.0.0',
33+
'x-sdk-version': '19.1.0',
3434
'X-Appwrite-Response-Format': '1.8.0',
3535
};
3636

lib/src/client_io.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class ClientIO extends ClientBase with ClientMixin {
3636
'x-sdk-name': 'Dart',
3737
'x-sdk-platform': 'server',
3838
'x-sdk-language': 'dart',
39-
'x-sdk-version': '19.0.0',
39+
'x-sdk-version': '19.1.0',
4040
'user-agent':
41-
'AppwriteDartSDK/19.0.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
41+
'AppwriteDartSDK/19.1.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
4242
'X-Appwrite-Response-Format': '1.8.0',
4343
};
4444

0 commit comments

Comments
 (0)