Merge pull request #275 from appwrite/dev

feat: Flutter SDK update for version 20.1.0
This commit is contained in:
Jake Barnby
2025-10-08 18:52:29 +13:00
committed by GitHub
10 changed files with 145 additions and 10 deletions
+5
View File
@@ -1,5 +1,10 @@
# Change Log
## 20.1.0
* Deprecate `createVerification` method in `Account` service
* Add `createEmailVerification` method in `Account` service
## 19.1.0
* Add `orderRandom` query support
+1 -1
View File
@@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:
```yml
dependencies:
appwrite: ^20.0.0
appwrite: ^20.1.0
```
You can install packages from the command line:
@@ -0,0 +1,11 @@
import 'package:appwrite/appwrite.dart';
Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
Account account = Account(client);
Token result = await account.createEmailVerification(
url: 'https://example.com',
);
@@ -0,0 +1,12 @@
import 'package:appwrite/appwrite.dart';
Client client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
Account account = Account(client);
Token result = await account.updateEmailVerification(
userId: '<USER_ID>',
secret: '<SECRET>',
);
+66 -4
View File
@@ -1378,8 +1378,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 {
const 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 {
const String apiPath = '/account/verification';
const String apiPath = '/account/verifications/email';
final Map<String, dynamic> apiParams = {'url': url};
@@ -1399,11 +1434,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 {
const 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 {
const String apiPath = '/account/verification';
const String apiPath = '/account/verifications/email';
final Map<String, dynamic> apiParams = {'userId': userId, 'secret': secret};
@@ -1428,7 +1490,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 {
const String apiPath = '/account/verification/phone';
const String apiPath = '/account/verifications/phone';
final Map<String, dynamic> apiParams = {};
@@ -1452,7 +1514,7 @@ class Account extends Service {
required String userId,
required String secret,
}) async {
const String apiPath = '/account/verification/phone';
const String apiPath = '/account/verifications/phone';
final Map<String, dynamic> apiParams = {'userId': userId, 'secret': secret};
+2 -2
View File
@@ -31,7 +31,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,
@@ -92,7 +92,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,
+1 -1
View File
@@ -40,7 +40,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '20.0.0',
'x-sdk-version': '20.1.0',
'X-Appwrite-Response-Format': '1.8.0',
};
+1 -1
View File
@@ -58,7 +58,7 @@ class ClientIO extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '20.0.0',
'x-sdk-version': '20.1.0',
'X-Appwrite-Response-Format': '1.8.0',
};
+1 -1
View File
@@ -1,5 +1,5 @@
name: appwrite
version: 20.0.0
version: 20.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-flutter
+45
View File
@@ -1380,6 +1380,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',
@@ -1402,6 +1424,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',