Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 19.1.0

* Deprecate `createVerification` method in `Account` service
* Add `createEmailVerification` method in `Account` service

Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Document the updateEmailVerification addition
The 19.1.0 entry mentions only the new createEmailVerification method, but the PR also adds updateEmailVerification. Please document that addition (and any related endpoint shifts) here so the changelog accurately reflects the release contents.

🤖 Prompt for AI Agents
In CHANGELOG.md around lines 5 to 7, the 19.1.0 changelog only lists the new
createEmailVerification method but omits the added updateEmailVerification and
any endpoint changes; update the 19.1.0 entry to include a line documenting the
added updateEmailVerification method and note any related endpoint shifts (e.g.,
renamed or moved endpoints) so the changelog accurately reflects both
createEmailVerification and updateEmailVerification additions and their endpoint
implications.

## 18.1.0

* Add `orderRandom` query support
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
dart_appwrite: ^19.0.0
dart_appwrite: ^19.1.0
```

You can install packages from the command line:
Expand Down
12 changes: 12 additions & 0 deletions docs/examples/account/create-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

Token result = await account.createEmailVerification(
url: 'https://example.com',
);
13 changes: 13 additions & 0 deletions docs/examples/account/update-email-verification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:dart_appwrite/dart_appwrite.dart';

Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>') // Your project ID
.setSession(''); // The user session to authenticate with

Account account = Account(client);

Token result = await account.updateEmailVerification(
userId: '<USER_ID>',
secret: '<SECRET>',
);
70 changes: 66 additions & 4 deletions lib/services/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1235,8 +1235,43 @@ class Account extends Service {
/// the only valid redirect URLs are the ones from domains you have set when
/// adding your platforms in the console interface.
///
Future<models.Token> createEmailVerification({required String url}) async {
final String apiPath = '/account/verifications/email';

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

final Map<String, String> apiHeaders = {'content-type': 'application/json'};

final res = await client.call(
HttpMethod.post,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);

return models.Token.fromMap(res.data);
}

/// Use this endpoint to send a verification message to your user email address
/// to confirm they are the valid owners of that address. Both the **userId**
/// and **secret** arguments will be passed as query parameters to the URL you
/// have provided to be attached to the verification email. The provided URL
/// 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](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification).
/// The verification link sent to the user's email address is valid for 7 days.
///
/// 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),
/// the only valid redirect URLs are the ones from domains you have set when
/// adding your platforms in the console interface.
///
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `Account.createEmailVerification` instead.',
)
Future<models.Token> createVerification({required String url}) async {
final String apiPath = '/account/verification';
final String apiPath = '/account/verifications/email';

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

Expand All @@ -1256,11 +1291,38 @@ class Account extends Service {
/// the **userId** and **secret** parameters that were attached to your app URL
/// to verify the user email ownership. If confirmed this route will return a
/// 200 status code.
Future<models.Token> updateEmailVerification({
required String userId,
required String secret,
}) async {
final String apiPath = '/account/verifications/email';

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

final Map<String, String> apiHeaders = {'content-type': 'application/json'};

final res = await client.call(
HttpMethod.put,
path: apiPath,
params: apiParams,
headers: apiHeaders,
);

return models.Token.fromMap(res.data);
}

/// Use this endpoint to complete the user email verification process. Use both
/// the **userId** and **secret** parameters that were attached to your app URL
/// to verify the user email ownership. If confirmed this route will return a
/// 200 status code.
@Deprecated(
'This API has been deprecated since 1.8.0. Please use `Account.updateEmailVerification` instead.',
)
Future<models.Token> updateVerification({
required String userId,
required String secret,
}) async {
final String apiPath = '/account/verification';
final String apiPath = '/account/verifications/email';

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

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

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

Expand All @@ -1309,7 +1371,7 @@ class Account extends Service {
required String userId,
required String secret,
}) async {
final String apiPath = '/account/verification/phone';
final String apiPath = '/account/verifications/phone';

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

Expand Down
2 changes: 1 addition & 1 deletion lib/services/functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class Functions extends Service {
/// Create a deployment based on a template.
///
/// Use this endpoint with combination of
/// [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to
/// [listTemplates](https://appwrite.io/docs/products/functions/templates) to
/// find the template details.
Future<models.Deployment> createTemplateDeployment({
required String functionId,
Expand Down
4 changes: 2 additions & 2 deletions lib/services/sites.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ class Sites extends Service {
/// Create a deployment based on a template.
///
/// Use this endpoint with combination of
/// [listTemplates](https://appwrite.io/docs/server/sites#listTemplates) to
/// find the template details.
/// [listTemplates](https://appwrite.io/docs/products/sites/templates) to find
/// the template details.
Future<models.Deployment> createTemplateDeployment({
required String siteId,
required String repository,
Expand Down
10 changes: 5 additions & 5 deletions lib/services/tables_db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class TablesDB extends Service {

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

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

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

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

/// Create or update a Row. Before using this route, you should create a new
/// table resource using either a [server
/// integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreateTable)
/// integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable)
/// API or directly from your database console.
Future<models.Row> upsertRow({
required String databaseId,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/client_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
'x-sdk-name': 'Dart',
'x-sdk-platform': 'server',
'x-sdk-language': 'dart',
'x-sdk-version': '19.0.0',
'x-sdk-version': '19.1.0',
'X-Appwrite-Response-Format': '1.8.0',
};

Expand Down
4 changes: 2 additions & 2 deletions lib/src/client_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class ClientIO extends ClientBase with ClientMixin {
'x-sdk-name': 'Dart',
'x-sdk-platform': 'server',
'x-sdk-language': 'dart',
'x-sdk-version': '19.0.0',
'x-sdk-version': '19.1.0',
'user-agent':
'AppwriteDartSDK/19.0.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
'AppwriteDartSDK/19.1.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
'X-Appwrite-Response-Format': '1.8.0',
};

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: dart_appwrite
version: 19.0.0
version: 19.1.0
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
homepage: https://appwrite.io
repository: https://github.com/appwrite/sdk-for-dart
Expand Down
45 changes: 45 additions & 0 deletions test/services/account_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,28 @@ void main() {

});

test('test method createEmailVerification()', () async {
final Map<String, dynamic> data = {
'\$id': 'bb8ea5c16897e',
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
'userId': '5e5ea5c168bb8',
'secret': '',
'expire': '2020-10-15T06:38:00.000+00:00',
'phrase': 'Golden Fox',};


when(client.call(
HttpMethod.post,
)).thenAnswer((_) async => Response(data: data));


final response = await account.createEmailVerification(
url: 'https://example.com',
);
expect(response, isA<models.Token>());

});

test('test method createVerification()', () async {
final Map<String, dynamic> data = {
'\$id': 'bb8ea5c16897e',
Expand All @@ -1322,6 +1344,29 @@ void main() {

});

test('test method updateEmailVerification()', () async {
final Map<String, dynamic> data = {
'\$id': 'bb8ea5c16897e',
'\$createdAt': '2020-10-15T06:38:00.000+00:00',
'userId': '5e5ea5c168bb8',
'secret': '',
'expire': '2020-10-15T06:38:00.000+00:00',
'phrase': 'Golden Fox',};


when(client.call(
HttpMethod.put,
)).thenAnswer((_) async => Response(data: data));


final response = await account.updateEmailVerification(
userId: '<USER_ID>',
secret: '<SECRET>',
);
expect(response, isA<models.Token>());

});

test('test method updateVerification()', () async {
final Map<String, dynamic> data = {
'\$id': 'bb8ea5c16897e',
Expand Down