Skip to content

Commit 11b3b91

Browse files
Merge pull request #23 from appwrite/dev
Fix msg91 params
2 parents 1844aa0 + ff21867 commit 11b3b91

File tree

7 files changed

+36
-20
lines changed

7 files changed

+36
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Appwrite Ruby SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.5.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

appwrite.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |spec|
22

33
spec.name = 'appwrite'
4-
spec.version = '11.0.0'
4+
spec.version = '11.0.1'
55
spec.license = 'BSD-3-Clause'
66
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'
77
spec.author = 'Appwrite Team'

docs/examples/messaging/create-msg91provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ messaging = Messaging.new(client)
1212
result = messaging.create_msg91_provider(
1313
provider_id: '<PROVIDER_ID>',
1414
name: '<NAME>',
15-
from: '+12065550100', # optional
15+
template_id: '<TEMPLATE_ID>', # optional
1616
sender_id: '<SENDER_ID>', # optional
1717
auth_key: '<AUTH_KEY>', # optional
1818
enabled: false # optional

docs/examples/messaging/update-msg91provider.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ result = messaging.update_msg91_provider(
1313
provider_id: '<PROVIDER_ID>',
1414
name: '<NAME>', # optional
1515
enabled: false, # optional
16+
template_id: '<TEMPLATE_ID>', # optional
1617
sender_id: '<SENDER_ID>', # optional
17-
auth_key: '<AUTH_KEY>', # optional
18-
from: '<FROM>' # optional
18+
auth_key: '<AUTH_KEY>' # optional
1919
)

lib/appwrite/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize
1515
'x-sdk-name'=> 'Ruby',
1616
'x-sdk-platform'=> 'server',
1717
'x-sdk-language'=> 'ruby',
18-
'x-sdk-version'=> '11.0.0',
18+
'x-sdk-version'=> '11.0.1',
1919
'X-Appwrite-Response-Format' => '1.5.0'
2020
}
2121
@endpoint = 'https://cloud.appwrite.io/v1'

lib/appwrite/id.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1+
require 'securerandom'
2+
13
module Appwrite
24
class ID
35
def self.custom(id)
46
id
57
end
6-
7-
def self.unique
8-
'unique()'
8+
9+
# Generate a unique ID with padding to have a longer ID
10+
def self.unique(padding=7)
11+
base_id = self.hex_timestamp
12+
random_padding = SecureRandom.hex(padding)
13+
random_padding = random_padding[0...padding]
14+
base_id + random_padding
15+
end
16+
17+
#Generate an hex ID based on timestamp
18+
#Recreated from https://www.php.net/manual/en/function.uniqid.php
19+
private_class_method def self.hex_timestamp
20+
now = Time.now
21+
sec = now.to_i
22+
usec = now.usec
23+
hex_timestamp = "%08x%05x" % [sec, usec]
24+
hex_timestamp
925
end
1026
end
11-
end
27+
end

lib/appwrite/services/messaging.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -789,13 +789,13 @@ def update_mailgun_provider(provider_id:, name: nil, api_key: nil, domain: nil,
789789
#
790790
# @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.
791791
# @param [String] name Provider name.
792-
# @param [String] from Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
793-
# @param [String] sender_id Msg91 Sender ID.
794-
# @param [String] auth_key Msg91 Auth Key.
792+
# @param [String] template_id Msg91 template ID
793+
# @param [String] sender_id Msg91 sender ID.
794+
# @param [String] auth_key Msg91 auth key.
795795
# @param [] enabled Set as enabled.
796796
#
797797
# @return [Provider]
798-
def create_msg91_provider(provider_id:, name:, from: nil, sender_id: nil, auth_key: nil, enabled: nil)
798+
def create_msg91_provider(provider_id:, name:, template_id: nil, sender_id: nil, auth_key: nil, enabled: nil)
799799
api_path = '/messaging/providers/msg91'
800800

801801
if provider_id.nil?
@@ -809,7 +809,7 @@ def create_msg91_provider(provider_id:, name:, from: nil, sender_id: nil, auth_k
809809
api_params = {
810810
providerId: provider_id,
811811
name: name,
812-
from: from,
812+
templateId: template_id,
813813
senderId: sender_id,
814814
authKey: auth_key,
815815
enabled: enabled,
@@ -834,12 +834,12 @@ def create_msg91_provider(provider_id:, name:, from: nil, sender_id: nil, auth_k
834834
# @param [String] provider_id Provider ID.
835835
# @param [String] name Provider name.
836836
# @param [] enabled Set as enabled.
837-
# @param [String] sender_id Msg91 Sender ID.
838-
# @param [String] auth_key Msg91 Auth Key.
839-
# @param [String] from Sender number.
837+
# @param [String] template_id Msg91 template ID.
838+
# @param [String] sender_id Msg91 sender ID.
839+
# @param [String] auth_key Msg91 auth key.
840840
#
841841
# @return [Provider]
842-
def update_msg91_provider(provider_id:, name: nil, enabled: nil, sender_id: nil, auth_key: nil, from: nil)
842+
def update_msg91_provider(provider_id:, name: nil, enabled: nil, template_id: nil, sender_id: nil, auth_key: nil)
843843
api_path = '/messaging/providers/msg91/{providerId}'
844844
.gsub('{providerId}', provider_id)
845845

@@ -850,9 +850,9 @@ def update_msg91_provider(provider_id:, name: nil, enabled: nil, sender_id: nil,
850850
api_params = {
851851
name: name,
852852
enabled: enabled,
853+
templateId: template_id,
853854
senderId: sender_id,
854855
authKey: auth_key,
855-
from: from,
856856
}
857857

858858
api_headers = {

0 commit comments

Comments
 (0)