diff --git a/README.md b/README.md index 6e3cb4f..d664721 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.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) diff --git a/appwrite.gemspec b/appwrite.gemspec index 17a406e..a065321 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -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' diff --git a/docs/examples/messaging/create-msg91provider.md b/docs/examples/messaging/create-msg91provider.md index 7005328..951b3bf 100644 --- a/docs/examples/messaging/create-msg91provider.md +++ b/docs/examples/messaging/create-msg91provider.md @@ -12,7 +12,7 @@ messaging = Messaging.new(client) result = messaging.create_msg91_provider( provider_id: '', name: '', - from: '+12065550100', # optional + template_id: '', # optional sender_id: '', # optional auth_key: '', # optional enabled: false # optional diff --git a/docs/examples/messaging/update-msg91provider.md b/docs/examples/messaging/update-msg91provider.md index 23544cb..a8adc2d 100644 --- a/docs/examples/messaging/update-msg91provider.md +++ b/docs/examples/messaging/update-msg91provider.md @@ -13,7 +13,7 @@ result = messaging.update_msg91_provider( provider_id: '', name: '', # optional enabled: false, # optional + template_id: '', # optional sender_id: '', # optional - auth_key: '', # optional - from: '' # optional + auth_key: '' # optional ) diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 79b4c9d..7cc168b 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'=> '11.0.0', + 'x-sdk-version'=> '11.0.1', 'X-Appwrite-Response-Format' => '1.5.0' } @endpoint = 'https://cloud.appwrite.io/v1' diff --git a/lib/appwrite/id.rb b/lib/appwrite/id.rb index 4a5fc42..f98ea1d 100644 --- a/lib/appwrite/id.rb +++ b/lib/appwrite/id.rb @@ -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 \ No newline at end of file +end diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index ccf8f02..342f471 100644 --- a/lib/appwrite/services/messaging.rb +++ b/lib/appwrite/services/messaging.rb @@ -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? @@ -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, @@ -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) @@ -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 = {