Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new push message parameters #67

Merged
merged 2 commits into from
Jan 21, 2025
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
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: ^12.1.0
dart_appwrite: ^12.2.0
```

You can install packages from the command line:
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/databases/update-string-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ AttributeString result = await databases.updateStringAttribute(
key: '',
xrequired: false,
xdefault: '<DEFAULT>',
size: 0, // (optional)
size: 1, // (optional)
newKey: '', // (optional)
);
9 changes: 6 additions & 3 deletions docs/examples/messaging/create-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Messaging messaging = Messaging(client);

Message result = await messaging.createPush(
messageId: '<MESSAGE_ID>',
title: '<TITLE>',
body: '<BODY>',
title: '<TITLE>', // (optional)
body: '<BODY>', // (optional)
topics: [], // (optional)
users: [], // (optional)
targets: [], // (optional)
Expand All @@ -21,7 +21,10 @@ Message result = await messaging.createPush(
sound: '<SOUND>', // (optional)
color: '<COLOR>', // (optional)
tag: '<TAG>', // (optional)
badge: '<BADGE>', // (optional)
badge: 0, // (optional)
draft: false, // (optional)
scheduledAt: '', // (optional)
contentAvailable: false, // (optional)
critical: false, // (optional)
priority: MessagePriority.normal, // (optional)
);
3 changes: 3 additions & 0 deletions docs/examples/messaging/update-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ Message result = await messaging.updatePush(
badge: 0, // (optional)
draft: false, // (optional)
scheduledAt: '', // (optional)
contentAvailable: false, // (optional)
critical: false, // (optional)
priority: MessagePriority.normal, // (optional)
);
1 change: 1 addition & 0 deletions lib/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ part 'src/enums/index_type.dart';
part 'src/enums/runtime.dart';
part 'src/enums/execution_method.dart';
part 'src/enums/name.dart';
part 'src/enums/message_priority.dart';
part 'src/enums/smtp_encryption.dart';
part 'src/enums/compression.dart';
part 'src/enums/image_gravity.dart';
Expand Down
24 changes: 11 additions & 13 deletions lib/services/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Account extends Service {
return models.User.fromMap(res.data);
}

/// List Identities
/// List identities
///
/// Get the list of identities for the currently logged in user.
Future<models.IdentityList> listIdentities({List<String>? queries}) async {
Expand Down Expand Up @@ -186,7 +186,7 @@ class Account extends Service {
return models.User.fromMap(res.data);
}

/// Create Authenticator
/// Create authenticator
///
/// Add an authenticator app to be used as an MFA factor. Verify the
/// authenticator using the [verify
Expand All @@ -209,7 +209,7 @@ class Account extends Service {
return models.MfaType.fromMap(res.data);
}

/// Verify Authenticator
/// Verify authenticator
///
/// Verify an authenticator app after adding it using the [add
/// authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
Expand All @@ -233,7 +233,7 @@ class Account extends Service {
return models.User.fromMap(res.data);
}

/// Delete Authenticator
/// Delete authenticator
///
/// Delete an authenticator for a user by ID.
Future deleteMfaAuthenticator({required enums.AuthenticatorType type}) async {
Expand All @@ -252,7 +252,7 @@ class Account extends Service {
return res.data;
}

/// Create MFA Challenge
/// Create MFA challenge
///
/// Begin the process of MFA verification after sign-in. Finish the flow with
/// [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
Expand All @@ -275,7 +275,7 @@ class Account extends Service {
return models.MfaChallenge.fromMap(res.data);
}

/// Create MFA Challenge (confirmation)
/// Create MFA challenge (confirmation)
///
/// Complete the MFA challenge by providing the one-time password. Finish the
/// process of MFA verification by providing the one-time password. To begin
Expand All @@ -301,7 +301,7 @@ class Account extends Service {
return res.data;
}

/// List Factors
/// List factors
///
/// List the factors available on the account to be used as a MFA challange.
Future<models.MfaFactors> listMfaFactors() async {
Expand All @@ -319,7 +319,7 @@ class Account extends Service {
return models.MfaFactors.fromMap(res.data);
}

/// Get MFA Recovery Codes
/// Get MFA recovery codes
///
/// Get recovery codes that can be used as backup for MFA flow. Before getting
/// codes, they must be generated using
Expand All @@ -340,7 +340,7 @@ class Account extends Service {
return models.MfaRecoveryCodes.fromMap(res.data);
}

/// Create MFA Recovery Codes
/// Create MFA recovery codes
///
/// Generate recovery codes as backup for MFA flow. It's recommended to
/// generate and show then immediately after user successfully adds their
Expand All @@ -362,7 +362,7 @@ class Account extends Service {
return models.MfaRecoveryCodes.fromMap(res.data);
}

/// Regenerate MFA Recovery Codes
/// Regenerate MFA recovery codes
///
/// Regenerate recovery codes that can be used as backup for MFA flow. Before
/// regenerating codes, they must be first generated using
Expand Down Expand Up @@ -843,9 +843,7 @@ class Account extends Service {
/// [POST
/// /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
/// endpoint to complete the login process. The link sent to the user's email
/// address is valid for 1 hour. If you are on a mobile device you can leave
/// the URL parameter empty, so that the login completion will be handled by
/// your Appwrite instance by default.
/// address is valid for 1 hour.
///
/// A user is limited to 10 active sessions at a time by default. [Learn more
/// about session
Expand Down
2 changes: 1 addition & 1 deletion lib/services/locale.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Locale extends Service {
return models.Locale.fromMap(res.data);
}

/// List Locale Codes
/// List locale codes
///
/// List of all locale codes in [ISO
/// 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
Expand Down
22 changes: 17 additions & 5 deletions lib/services/messaging.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class Messaging extends Service {
/// Create a new push notification.
Future<models.Message> createPush(
{required String messageId,
required String title,
required String body,
String? title,
String? body,
List<String>? topics,
List<String>? users,
List<String>? targets,
Expand All @@ -131,9 +131,12 @@ class Messaging extends Service {
String? sound,
String? color,
String? tag,
String? badge,
int? badge,
bool? draft,
String? scheduledAt}) async {
String? scheduledAt,
bool? contentAvailable,
bool? critical,
enums.MessagePriority? priority}) async {
final String apiPath = '/messaging/messages/push';

final Map<String, dynamic> apiParams = {
Expand All @@ -153,6 +156,9 @@ class Messaging extends Service {
'badge': badge,
'draft': draft,
'scheduledAt': scheduledAt,
'contentAvailable': contentAvailable,
'critical': critical,
'priority': priority?.value,
};

final Map<String, String> apiHeaders = {
Expand Down Expand Up @@ -185,7 +191,10 @@ class Messaging extends Service {
String? tag,
int? badge,
bool? draft,
String? scheduledAt}) async {
String? scheduledAt,
bool? contentAvailable,
bool? critical,
enums.MessagePriority? priority}) async {
final String apiPath = '/messaging/messages/push/{messageId}'
.replaceAll('{messageId}', messageId);

Expand All @@ -205,6 +214,9 @@ class Messaging extends Service {
'badge': badge,
'draft': draft,
'scheduledAt': scheduledAt,
'contentAvailable': contentAvailable,
'critical': critical,
'priority': priority?.value,
};

final Map<String, String> apiHeaders = {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class Storage extends Service {
return models.File.fromMap(res.data);
}

/// Delete File
/// Delete file
///
/// Delete a file by its unique ID. Only users with write permissions have
/// access to delete this resource.
Expand Down
6 changes: 4 additions & 2 deletions lib/services/teams.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ class Teams extends Service {
/// List team memberships
///
/// Use this endpoint to list a team's members using the team's ID. All team
/// members have read access to this endpoint.
/// members have read access to this endpoint. Hide sensitive attributes from
/// the response by toggling membership privacy in the Console.
Future<models.MembershipList> listMemberships(
{required String teamId, List<String>? queries, String? search}) async {
final String apiPath =
Expand Down Expand Up @@ -192,7 +193,8 @@ class Teams extends Service {
/// Get team membership
///
/// Get a team member by the membership unique id. All team members have read
/// access for this resource.
/// access for this resource. Hide sensitive attributes from the response by
/// toggling membership privacy in the Console.
Future<models.Membership> getMembership(
{required String teamId, required String membershipId}) async {
final String apiPath = '/teams/{teamId}/memberships/{membershipId}'
Expand Down
20 changes: 10 additions & 10 deletions lib/services/users.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Users extends Service {
return models.User.fromMap(res.data);
}

/// List Identities
/// List identities
///
/// Get identities for all users.
Future<models.IdentityList> listIdentities(
Expand Down Expand Up @@ -503,7 +503,7 @@ class Users extends Service {
return models.User.fromMap(res.data);
}

/// Delete Authenticator
/// Delete authenticator
///
/// Delete an authenticator app.
Future<models.User> deleteMfaAuthenticator(
Expand All @@ -524,7 +524,7 @@ class Users extends Service {
return models.User.fromMap(res.data);
}

/// List Factors
/// List factors
///
/// List the factors available on the account to be used as a MFA challange.
Future<models.MfaFactors> listMfaFactors({required String userId}) async {
Expand All @@ -543,7 +543,7 @@ class Users extends Service {
return models.MfaFactors.fromMap(res.data);
}

/// Get MFA Recovery Codes
/// Get MFA recovery codes
///
/// Get recovery codes that can be used as backup for MFA flow by User ID.
/// Before getting codes, they must be generated using
Expand All @@ -566,7 +566,7 @@ class Users extends Service {
return models.MfaRecoveryCodes.fromMap(res.data);
}

/// Regenerate MFA Recovery Codes
/// Regenerate MFA recovery codes
///
/// Regenerate recovery codes that can be used as backup for MFA flow by User
/// ID. Before regenerating codes, they must be first generated using
Expand All @@ -589,7 +589,7 @@ class Users extends Service {
return models.MfaRecoveryCodes.fromMap(res.data);
}

/// Create MFA Recovery Codes
/// Create MFA recovery codes
///
/// Generate recovery codes used as backup for MFA flow for User ID. Recovery
/// codes can be used as a MFA verification type in
Expand Down Expand Up @@ -827,7 +827,7 @@ class Users extends Service {
return models.User.fromMap(res.data);
}

/// List User Targets
/// List user targets
///
/// List the messaging targets that are associated with a user.
Future<models.TargetList> listTargets(
Expand All @@ -849,7 +849,7 @@ class Users extends Service {
return models.TargetList.fromMap(res.data);
}

/// Create User Target
/// Create user target
///
/// Create a messaging target.
Future<models.Target> createTarget(
Expand Down Expand Up @@ -880,7 +880,7 @@ class Users extends Service {
return models.Target.fromMap(res.data);
}

/// Get User Target
/// Get user target
///
/// Get a user's push notification target by ID.
Future<models.Target> getTarget(
Expand All @@ -901,7 +901,7 @@ class Users extends Service {
return models.Target.fromMap(res.data);
}

/// Update User target
/// Update user target
///
/// Update a messaging target.
Future<models.Target> updateTarget(
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 @@ -33,7 +33,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
'x-sdk-name': 'Dart',
'x-sdk-platform': 'server',
'x-sdk-language': 'dart',
'x-sdk-version': '12.1.0',
'x-sdk-version': '12.2.0',
'X-Appwrite-Response-Format': '1.6.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 @@ -42,9 +42,9 @@ class ClientIO extends ClientBase with ClientMixin {
'x-sdk-name': 'Dart',
'x-sdk-platform': 'server',
'x-sdk-language': 'dart',
'x-sdk-version': '12.1.0',
'x-sdk-version': '12.2.0',
'user-agent':
'AppwriteDartSDK/12.1.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
'AppwriteDartSDK/12.2.0 (${Platform.operatingSystem}; ${Platform.operatingSystemVersion})',
'X-Appwrite-Response-Format': '1.6.0',
};

Expand Down
3 changes: 2 additions & 1 deletion lib/src/enums/image_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ enum ImageFormat {
jpeg(value: 'jpeg'),
gif(value: 'gif'),
png(value: 'png'),
webp(value: 'webp');
webp(value: 'webp'),
avif(value: 'avif');

const ImageFormat({required this.value});

Expand Down
12 changes: 12 additions & 0 deletions lib/src/enums/message_priority.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
part of '../../enums.dart';

enum MessagePriority {
normal(value: 'normal'),
high(value: 'high');

const MessagePriority({required this.value});

final String value;

String toJson() => value;
}
Loading