Skip to content

Commit

Permalink
Merge pull request #35 from appwrite/feat-push-params
Browse files Browse the repository at this point in the history
Add new push message parameters
  • Loading branch information
christyjacob4 authored Jan 21, 2025
2 parents 33bfc16 + 323ef57 commit fdf87cd
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion appwrite.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |spec|

spec.name = 'appwrite'
spec.version = '13.0.1'
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'
Expand Down
11 changes: 7 additions & 4 deletions docs/examples/messaging/create-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ messaging = Messaging.new(client)

result = messaging.create_push(
message_id: '<MESSAGE_ID>',
title: '<TITLE>',
body: '<BODY>',
title: '<TITLE>', # optional
body: '<BODY>', # optional
topics: [], # optional
users: [], # optional
targets: [], # optional
Expand All @@ -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
)
5 changes: 4 additions & 1 deletion docs/examples/messaging/update-push.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
1 change: 1 addition & 0 deletions lib/appwrite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/appwrite/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'=> '13.1.0',
'X-Appwrite-Response-Format' => '1.6.0'
}
@endpoint = 'https://cloud.appwrite.io/v1'
Expand Down
8 changes: 8 additions & 0 deletions lib/appwrite/enums/message_priority.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Appwrite
module Enums
module MessagePriority
NORMAL = 'normal'
HIGH = 'high'
end
end
end
1 change: 1 addition & 0 deletions lib/appwrite/enums/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions lib/appwrite/services/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 17 additions & 13 deletions lib/appwrite/services/messaging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = {
Expand Down Expand Up @@ -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)

Expand All @@ -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 = {
Expand Down

0 comments on commit fdf87cd

Please sign in to comment.