Skip to content

Commit 0c669d0

Browse files
committed
chore: release rc
1 parent bf7aac5 commit 0c669d0

27 files changed

+576
-33
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![pub package](https://img.shields.io/pub/v/appwrite?style=flat-square)](https://pub.dartlang.org/packages/appwrite)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.5.x-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.6.x-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:
2121

2222
```yml
2323
dependencies:
24-
appwrite: ^13.0.0-rc.1
24+
appwrite: ^13.0.0-rc.2
2525
```
2626
2727
You can install packages from the command line:

docs/examples/account/delete-mfa-authenticator.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ Account account = Account(client);
88

99
await account.deleteMfaAuthenticator(
1010
type: AuthenticatorType.totp,
11-
otp: '<OTP>',
1211
);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import 'package:appwrite/appwrite.dart';
2+
3+
Client client = Client()
4+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('&lt;YOUR_PROJECT_ID&gt;'); // Your project ID
6+
7+
Functions functions = Functions(client);
8+
9+
// Downloading file
10+
UInt8List bytes = await functions.getDeploymentDownload(
11+
functionId: '<FUNCTION_ID>',
12+
deploymentId: '<DEPLOYMENT_ID>',
13+
)
14+
15+
final file = File('path_to_file/filename.ext');
16+
file.writeAsBytesSync(bytes);
17+
18+
// Displaying image preview
19+
FutureBuilder(
20+
future: functions.getDeploymentDownload(
21+
functionId:'<FUNCTION_ID>' ,
22+
deploymentId:'<DEPLOYMENT_ID>' ,
23+
), // Works for both public file and private file, for private files you need to be logged in
24+
builder: (context, snapshot) {
25+
return snapshot.hasData && snapshot.data != null
26+
? Image.memory(snapshot.data)
27+
: CircularProgressIndicator();
28+
}
29+
);
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://cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('&lt;YOUR_PROJECT_ID&gt;'); // Your project ID
6+
7+
Functions functions = Functions(client);
8+
9+
TemplateFunction result = await functions.getTemplate(
10+
templateId: '<TEMPLATE_ID>',
11+
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'package:appwrite/appwrite.dart';
2+
3+
Client client = Client()
4+
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('&lt;YOUR_PROJECT_ID&gt;'); // Your project ID
6+
7+
Functions functions = Functions(client);
8+
9+
TemplateFunctionList result = await functions.listTemplates(
10+
runtimes: [], // optional
11+
useCases: [], // optional
12+
limit: 1, // optional
13+
offset: 0, // optional
14+
);

lib/appwrite.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// Appwrite Flutter SDK
22
///
3-
/// This SDK is compatible with Appwrite server version 1.5.x.
3+
/// This SDK is compatible with Appwrite server version 1.6.x.
44
/// For older versions, please check
55
/// [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).
66
library appwrite;

lib/models.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ part 'src/models/log_list.dart';
99
part 'src/models/file_list.dart';
1010
part 'src/models/team_list.dart';
1111
part 'src/models/membership_list.dart';
12+
part 'src/models/template_function_list.dart';
1213
part 'src/models/execution_list.dart';
1314
part 'src/models/country_list.dart';
1415
part 'src/models/continent_list.dart';
@@ -36,6 +37,9 @@ part 'src/models/locale_code.dart';
3637
part 'src/models/file.dart';
3738
part 'src/models/team.dart';
3839
part 'src/models/membership.dart';
40+
part 'src/models/template_function.dart';
41+
part 'src/models/template_runtime.dart';
42+
part 'src/models/template_variable.dart';
3943
part 'src/models/execution.dart';
4044
part 'src/models/country.dart';
4145
part 'src/models/continent.dart';

lib/services/account.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class Account extends Service {
184184

185185
}
186186

187-
/// Add Authenticator
187+
/// Create Authenticator
188188
///
189189
/// Add an authenticator app to be used as an MFA factor. Verify the
190190
/// authenticator using the [verify
@@ -231,11 +231,10 @@ class Account extends Service {
231231
/// Delete Authenticator
232232
///
233233
/// Delete an authenticator for a user by ID.
234-
Future deleteMfaAuthenticator({required enums.AuthenticatorType type, required String otp}) async {
234+
Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async {
235235
final String apiPath = '/account/mfa/authenticators/{type}'.replaceAll('{type}', type.value);
236236

237237
final Map<String, dynamic> apiParams = {
238-
'otp': otp,
239238
};
240239

241240
final Map<String, String> apiHeaders = {
@@ -248,7 +247,7 @@ class Account extends Service {
248247

249248
}
250249

251-
/// Create 2FA Challenge
250+
/// Create MFA Challenge
252251
///
253252
/// Begin the process of MFA verification after sign-in. Finish the flow with
254253
/// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
@@ -1139,7 +1138,7 @@ class Account extends Service {
11391138

11401139
}
11411140

1142-
/// Create phone verification (confirmation)
1141+
/// Update phone verification (confirmation)
11431142
///
11441143
/// Use this endpoint to complete the user phone verification process. Use the
11451144
/// **userId** and **secret** that were sent to your user's phone number to

lib/services/avatars.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Avatars extends Service {
6666
/// Use this endpoint to fetch the favorite icon (AKA favicon) of any remote
6767
/// website URL.
6868
///
69+
/// This endpoint does not follow HTTP redirects.
6970
Future<Uint8List> getFavicon({required String url}) async {
7071
const String apiPath = '/avatars/favicon';
7172

@@ -120,6 +121,7 @@ class Avatars extends Service {
120121
/// image at source quality. If dimensions are not specified, the default size
121122
/// of image returned is 400x400px.
122123
///
124+
/// This endpoint does not follow HTTP redirects.
123125
Future<Uint8List> getImage({required String url, int? width, int? height}) async {
124126
const String apiPath = '/avatars/image';
125127

lib/services/functions.dart

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,69 @@ class Functions extends Service {
66
/// Initializes a [Functions] service
77
Functions(super.client);
88

9+
/// List function templates
10+
///
11+
/// List available function templates. You can use template details in
12+
/// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
13+
/// method.
14+
Future<models.TemplateFunctionList> listTemplates({List<String>? runtimes, List<String>? useCases, int? limit, int? offset}) async {
15+
const String apiPath = '/functions/templates';
16+
17+
final Map<String, dynamic> apiParams = {
18+
'runtimes': runtimes,
19+
'useCases': useCases,
20+
'limit': limit,
21+
'offset': offset,
22+
};
23+
24+
final Map<String, String> apiHeaders = {
25+
'content-type': 'application/json',
26+
};
27+
28+
final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders);
29+
30+
return models.TemplateFunctionList.fromMap(res.data);
31+
32+
}
33+
34+
/// Get function template
35+
///
36+
/// Get a function template using ID. You can use template details in
37+
/// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
38+
/// method.
39+
Future<models.TemplateFunction> getTemplate({required String templateId}) async {
40+
final String apiPath = '/functions/templates/{templateId}'.replaceAll('{templateId}', templateId);
41+
42+
final Map<String, dynamic> apiParams = {
43+
};
44+
45+
final Map<String, String> apiHeaders = {
46+
'content-type': 'application/json',
47+
};
48+
49+
final res = await client.call(HttpMethod.get, path: apiPath, params: apiParams, headers: apiHeaders);
50+
51+
return models.TemplateFunction.fromMap(res.data);
52+
53+
}
54+
55+
/// Download deployment
56+
///
57+
/// Get a Deployment's contents by its unique ID. This endpoint supports range
58+
/// requests for partial or streaming file download.
59+
Future<Uint8List> getDeploymentDownload({required String functionId, required String deploymentId}) async {
60+
final String apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replaceAll('{functionId}', functionId).replaceAll('{deploymentId}', deploymentId);
61+
62+
final Map<String, dynamic> params = {
63+
64+
65+
'project': client.config['project'],
66+
};
67+
68+
final res = await client.call(HttpMethod.get, path: apiPath, params: params, responseType: ResponseType.bytes);
69+
return res.data;
70+
}
71+
972
/// List executions
1073
///
1174
/// Get a list of all the current user function execution logs. You can use the
@@ -34,10 +97,12 @@ class Functions extends Service {
3497
/// current execution status. You can ping the `Get Execution` endpoint to get
3598
/// updates on the current execution status. Once this endpoint is called, your
3699
/// function execution process will start asynchronously.
37-
Future<models.Execution> createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt}) async {
100+
Future<models.Execution> createExecution({required String functionId, String? body, bool? xasync, String? path, enums.ExecutionMethod? method, Map? headers, String? scheduledAt, Function(UploadProgress)? onProgress}) async {
38101
final String apiPath = '/functions/{functionId}/executions'.replaceAll('{functionId}', functionId);
39102

40103
final Map<String, dynamic> apiParams = {
104+
105+
41106
'body': body,
42107
'async': xasync,
43108
'path': path,
@@ -47,10 +112,18 @@ class Functions extends Service {
47112
};
48113

49114
final Map<String, String> apiHeaders = {
50-
'content-type': 'application/json',
115+
'content-type': 'multipart/form-data',
51116
};
52117

53-
final res = await client.call(HttpMethod.post, path: apiPath, params: apiParams, headers: apiHeaders);
118+
String idParamName = '';
119+
final res = await client.chunkedUpload(
120+
path: apiPath,
121+
params: apiParams,
122+
paramName: paramName,
123+
idParamName: idParamName,
124+
headers: apiHeaders,
125+
onProgress: onProgress,
126+
);
54127

55128
return models.Execution.fromMap(res.data);
56129

0 commit comments

Comments
 (0)