From 2b0fc57c0514435bbf6f393c9e33c55d3ded5bc6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 11 Dec 2024 01:05:21 +1300 Subject: [PATCH 1/2] Add new push message parameters --- README.md | 2 +- appwrite.gemspec | 2 +- docs/examples/messaging/create-push.md | 11 ++++++---- docs/examples/messaging/update-push.md | 5 ++++- lib/appwrite.rb | 1 + lib/appwrite/client.rb | 2 +- lib/appwrite/enums/message_priority.rb | 8 +++++++ lib/appwrite/enums/runtime.rb | 1 + lib/appwrite/services/account.rb | 4 +--- lib/appwrite/services/messaging.rb | 30 +++++++++++++++----------- 10 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 lib/appwrite/enums/message_priority.rb diff --git a/README.md b/README.md index f52f9c1..70281c0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.6.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/appwrite.gemspec b/appwrite.gemspec index d2bed6a..f7391ad 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '13.0.1' + spec.version = '12.2.0' spec.license = 'BSD-3-Clause' spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API' spec.author = 'Appwrite Team' diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index 1c6700d..61663f4 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -11,8 +11,8 @@ messaging = Messaging.new(client) result = messaging.create_push( message_id: '', - title: '', - body: '<BODY>', + title: '<TITLE>', # optional + body: '<BODY>', # optional topics: [], # optional users: [], # optional targets: [], # optional @@ -23,7 +23,10 @@ result = messaging.create_push( sound: '<SOUND>', # optional color: '<COLOR>', # optional tag: '<TAG>', # optional - badge: '<BADGE>', # optional + badge: null, # optional draft: false, # optional - scheduled_at: '' # optional + scheduled_at: '', # optional + content_available: false, # optional + critical: false, # optional + priority: MessagePriority::NORMAL # optional ) diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 54f6368..6bf9fca 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -25,5 +25,8 @@ result = messaging.update_push( tag: '<TAG>', # optional badge: null, # optional draft: false, # optional - scheduled_at: '' # optional + scheduled_at: '', # optional + content_available: false, # optional + critical: false, # optional + priority: MessagePriority::NORMAL # optional ) diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 5de9c13..ca4ac39 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -116,6 +116,7 @@ require_relative 'appwrite/enums/runtime' require_relative 'appwrite/enums/execution_method' require_relative 'appwrite/enums/name' +require_relative 'appwrite/enums/message_priority' require_relative 'appwrite/enums/smtp_encryption' require_relative 'appwrite/enums/compression' require_relative 'appwrite/enums/image_gravity' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 2fa8de2..477bdc5 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -15,7 +15,7 @@ def initialize 'x-sdk-name'=> 'Ruby', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'ruby', - 'x-sdk-version'=> '13.0.1', + 'x-sdk-version'=> '12.2.0', 'X-Appwrite-Response-Format' => '1.6.0' } @endpoint = 'https://cloud.appwrite.io/v1' diff --git a/lib/appwrite/enums/message_priority.rb b/lib/appwrite/enums/message_priority.rb new file mode 100644 index 0000000..f0745ca --- /dev/null +++ b/lib/appwrite/enums/message_priority.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module MessagePriority + NORMAL = 'normal' + HIGH = 'high' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/enums/runtime.rb b/lib/appwrite/enums/runtime.rb index 23e8be8..37eaf17 100644 --- a/lib/appwrite/enums/runtime.rb +++ b/lib/appwrite/enums/runtime.rb @@ -59,6 +59,7 @@ module Runtime BUN_1_1 = 'bun-1.1' GO_1_23 = 'go-1.23' STATIC_1 = 'static-1' + FLUTTER_3_24 = 'flutter-3.24' end end end \ No newline at end of file diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index aff062d..40bba25 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -1206,9 +1206,7 @@ def create_email_token(user_id:, email:, phrase: nil) # [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 diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index 49e952f..4567aff 100644 --- a/lib/appwrite/services/messaging.rb +++ b/lib/appwrite/services/messaging.rb @@ -156,33 +156,28 @@ def update_email(message_id:, topics: nil, users: nil, targets: nil, subject: ni # @param [Array] topics List of Topic IDs. # @param [Array] users List of User IDs. # @param [Array] targets List of Targets IDs. - # @param [Hash] data Additional Data for push notification. + # @param [Hash] data Additional key-value pair data for push notification. # @param [String] action Action for push notification. # @param [String] image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>. # @param [String] icon Icon for push notification. Available only for Android and Web Platform. - # @param [String] sound Sound for push notification. Available only for Android and IOS Platform. + # @param [String] sound Sound for push notification. Available only for Android and iOS Platform. # @param [String] color Color for push notification. Available only for Android Platform. # @param [String] tag Tag for push notification. Available only for Android Platform. - # @param [String] badge Badge for push notification. Available only for IOS Platform. + # @param [Integer] badge Badge for push notification. Available only for iOS Platform. # @param [] draft Is message a draft # @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + # @param [] content_available If set to true, the notification will be delivered in the background. Available only for iOS Platform. + # @param [] critical If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + # @param [MessagePriority] priority Set the notification priority. "normal" will consider device state and may not deliver notifications immediately. "high" will always attempt to immediately deliver the notification. # # @return [Message] - def create_push(message_id:, title:, body:, topics: nil, users: nil, targets: nil, data: nil, action: nil, image: nil, icon: nil, sound: nil, color: nil, tag: nil, badge: nil, draft: nil, scheduled_at: nil) + def create_push(message_id:, title: nil, body: nil, topics: nil, users: nil, targets: nil, data: nil, action: nil, image: nil, icon: nil, sound: nil, color: nil, tag: nil, badge: nil, draft: nil, scheduled_at: nil, content_available: nil, critical: nil, priority: nil) api_path = '/messaging/messages/push' if message_id.nil? raise Appwrite::Exception.new('Missing required parameter: "messageId"') end - if title.nil? - raise Appwrite::Exception.new('Missing required parameter: "title"') - end - - if body.nil? - raise Appwrite::Exception.new('Missing required parameter: "body"') - end - api_params = { messageId: message_id, title: title, @@ -200,6 +195,9 @@ def create_push(message_id:, title:, body:, topics: nil, users: nil, targets: ni badge: badge, draft: draft, scheduledAt: scheduled_at, + contentAvailable: content_available, + critical: critical, + priority: priority, } api_headers = { @@ -235,9 +233,12 @@ def create_push(message_id:, title:, body:, topics: nil, users: nil, targets: ni # @param [Integer] badge Badge for push notification. Available only for iOS platforms. # @param [] draft Is message a draft # @param [String] scheduled_at Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future. + # @param [] content_available If set to true, the notification will be delivered in the background. Available only for iOS Platform. + # @param [] critical If set to true, the notification will be marked as critical. This requires the app to have the critical notification entitlement. Available only for iOS Platform. + # @param [MessagePriority] priority Set the notification priority. "normal" will consider device battery state and may send notifications later. "high" will always attempt to immediately deliver the notification. # # @return [Message] - def update_push(message_id:, topics: nil, users: nil, targets: nil, title: nil, body: nil, data: nil, action: nil, image: nil, icon: nil, sound: nil, color: nil, tag: nil, badge: nil, draft: nil, scheduled_at: nil) + def update_push(message_id:, topics: nil, users: nil, targets: nil, title: nil, body: nil, data: nil, action: nil, image: nil, icon: nil, sound: nil, color: nil, tag: nil, badge: nil, draft: nil, scheduled_at: nil, content_available: nil, critical: nil, priority: nil) api_path = '/messaging/messages/push/{messageId}' .gsub('{messageId}', message_id) @@ -261,6 +262,9 @@ def update_push(message_id:, topics: nil, users: nil, targets: nil, title: nil, badge: badge, draft: draft, scheduledAt: scheduled_at, + contentAvailable: content_available, + critical: critical, + priority: priority, } api_headers = { From 323ef576295e097155b9bbd901e1e433ad6b2907 Mon Sep 17 00:00:00 2001 From: Jake Barnby <jakeb994@gmail.com> Date: Wed, 22 Jan 2025 00:40:08 +1300 Subject: [PATCH 2/2] Fix version --- LICENSE | 2 +- appwrite.gemspec | 2 +- lib/appwrite/client.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 5479bb8..c1602fc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/appwrite.gemspec b/appwrite.gemspec index f7391ad..a565fd6 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '12.2.0' + spec.version = '13.1.0' spec.license = 'BSD-3-Clause' spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API' spec.author = 'Appwrite Team' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 477bdc5..37dcbbf 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -15,7 +15,7 @@ def initialize 'x-sdk-name'=> 'Ruby', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'ruby', - 'x-sdk-version'=> '12.2.0', + 'x-sdk-version'=> '13.1.0', 'X-Appwrite-Response-Format' => '1.6.0' } @endpoint = 'https://cloud.appwrite.io/v1'