Skip to content

Commit

Permalink
fix(messaging): fix msg91 params
Browse files Browse the repository at this point in the history
  • Loading branch information
stnguyen90 authored Mar 22, 2024
1 parent 1abd928 commit ff21867
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 20 deletions.
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.5.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.4-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 = '11.0.0'
spec.version = '11.0.1'
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
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-msg91provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ messaging = Messaging.new(client)
result = messaging.create_msg91_provider(
provider_id: '<PROVIDER_ID>',
name: '<NAME>',
from: '+12065550100', # optional
template_id: '<TEMPLATE_ID>', # optional
sender_id: '<SENDER_ID>', # optional
auth_key: '<AUTH_KEY>', # optional
enabled: false # optional
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/messaging/update-msg91provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ result = messaging.update_msg91_provider(
provider_id: '<PROVIDER_ID>',
name: '<NAME>', # optional
enabled: false, # optional
template_id: '<TEMPLATE_ID>', # optional
sender_id: '<SENDER_ID>', # optional
auth_key: '<AUTH_KEY>', # optional
from: '<FROM>' # optional
auth_key: '<AUTH_KEY>' # optional
)
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'=> '11.0.0',
'x-sdk-version'=> '11.0.1',
'X-Appwrite-Response-Format' => '1.5.0'
}
@endpoint = 'https://cloud.appwrite.io/v1'
Expand Down
24 changes: 20 additions & 4 deletions lib/appwrite/id.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
require 'securerandom'

module Appwrite
class ID
def self.custom(id)
id
end

def self.unique
'unique()'

# Generate a unique ID with padding to have a longer ID
def self.unique(padding=7)
base_id = self.hex_timestamp
random_padding = SecureRandom.hex(padding)
random_padding = random_padding[0...padding]
base_id + random_padding
end

#Generate an hex ID based on timestamp
#Recreated from https://www.php.net/manual/en/function.uniqid.php
private_class_method def self.hex_timestamp
now = Time.now
sec = now.to_i
usec = now.usec
hex_timestamp = "%08x%05x" % [sec, usec]
hex_timestamp
end
end
end
end
20 changes: 10 additions & 10 deletions lib/appwrite/services/messaging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -789,13 +789,13 @@ def update_mailgun_provider(provider_id:, name: nil, api_key: nil, domain: nil,
#
# @param [String] provider_id Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
# @param [String] name Provider name.
# @param [String] from Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
# @param [String] sender_id Msg91 Sender ID.
# @param [String] auth_key Msg91 Auth Key.
# @param [String] template_id Msg91 template ID
# @param [String] sender_id Msg91 sender ID.
# @param [String] auth_key Msg91 auth key.
# @param [] enabled Set as enabled.
#
# @return [Provider]
def create_msg91_provider(provider_id:, name:, from: nil, sender_id: nil, auth_key: nil, enabled: nil)
def create_msg91_provider(provider_id:, name:, template_id: nil, sender_id: nil, auth_key: nil, enabled: nil)
api_path = '/messaging/providers/msg91'

if provider_id.nil?
Expand All @@ -809,7 +809,7 @@ def create_msg91_provider(provider_id:, name:, from: nil, sender_id: nil, auth_k
api_params = {
providerId: provider_id,
name: name,
from: from,
templateId: template_id,
senderId: sender_id,
authKey: auth_key,
enabled: enabled,
Expand All @@ -834,12 +834,12 @@ def create_msg91_provider(provider_id:, name:, from: nil, sender_id: nil, auth_k
# @param [String] provider_id Provider ID.
# @param [String] name Provider name.
# @param [] enabled Set as enabled.
# @param [String] sender_id Msg91 Sender ID.
# @param [String] auth_key Msg91 Auth Key.
# @param [String] from Sender number.
# @param [String] template_id Msg91 template ID.
# @param [String] sender_id Msg91 sender ID.
# @param [String] auth_key Msg91 auth key.
#
# @return [Provider]
def update_msg91_provider(provider_id:, name: nil, enabled: nil, sender_id: nil, auth_key: nil, from: nil)
def update_msg91_provider(provider_id:, name: nil, enabled: nil, template_id: nil, sender_id: nil, auth_key: nil)
api_path = '/messaging/providers/msg91/{providerId}'
.gsub('{providerId}', provider_id)

Expand All @@ -850,9 +850,9 @@ def update_msg91_provider(provider_id:, name: nil, enabled: nil, sender_id: nil,
api_params = {
name: name,
enabled: enabled,
templateId: template_id,
senderId: sender_id,
authKey: auth_key,
from: from,
}

api_headers = {
Expand Down

0 comments on commit ff21867

Please sign in to comment.