diff --git a/Gemfile b/Gemfile index cd8aa9e..9d5f1d7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,6 @@ source 'https://rubygems.org' -gemspec \ No newline at end of file +gem 'mime-types', '~> 3.4.1' + +gemspec + diff --git a/appwrite.gemspec b/appwrite.gemspec index 7eada07..3ba5dc7 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '12.1.0' + spec.version = '13.0.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/functions/create-deployment.md b/docs/examples/functions/create-deployment.md index 8c0b3a5..ffe1938 100644 --- a/docs/examples/functions/create-deployment.md +++ b/docs/examples/functions/create-deployment.md @@ -11,7 +11,7 @@ functions = Functions.new(client) result = functions.create_deployment( function_id: '', - code: InputFile.from_path('dir/file.png'), + code: Payload.from_file('/path/to/file.png'), activate: false, entrypoint: '', # optional commands: '' # optional diff --git a/docs/examples/functions/create-execution.md b/docs/examples/functions/create-execution.md index bda612c..64c1d50 100644 --- a/docs/examples/functions/create-execution.md +++ b/docs/examples/functions/create-execution.md @@ -11,7 +11,7 @@ functions = Functions.new(client) result = functions.create_execution( function_id: '', - body: '', # optional + body: Payload.from_json({ "x": "y" }), # optional async: false, # optional path: '', # optional method: ExecutionMethod::GET, # optional diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index c6f3e26..3a8fe52 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -12,6 +12,6 @@ storage = Storage.new(client) result = storage.create_file( bucket_id: '', file_id: '', - file: InputFile.from_path('dir/file.png'), + file: Payload.from_file('/path/to/file.png'), permissions: ["read("any")"] # optional ) diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 5de9c13..4260018 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -6,7 +6,8 @@ require_relative 'appwrite/client' require_relative 'appwrite/service' require_relative 'appwrite/exception' -require_relative 'appwrite/input_file' +require_relative 'appwrite/payload' +require_relative 'appwrite/multipart' require_relative 'appwrite/query' require_relative 'appwrite/permission' require_relative 'appwrite/role' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index b9a54d9..32067f9 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -15,17 +15,14 @@ def initialize 'x-sdk-name'=> 'Ruby', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'ruby', - 'x-sdk-version'=> '12.1.0', - 'X-Appwrite-Response-Format' => '1.6.0' - } + 'x-sdk-version'=> '13.0.0', 'X-Appwrite-Response-Format' => '1.6.0' } @endpoint = 'https://cloud.appwrite.io/v1' end # Set Project # # Your project ID - # - # @param [String] value The value to set for the Project header + # # @param [String] value The value to set for the Project header # # @return [self] def set_project(value) @@ -37,8 +34,7 @@ def set_project(value) # Set Key # # Your secret API key - # - # @param [String] value The value to set for the Key header + # # @param [String] value The value to set for the Key header # # @return [self] def set_key(value) @@ -50,8 +46,7 @@ def set_key(value) # Set JWT # # Your secret JSON Web Token - # - # @param [String] value The value to set for the JWT header + # # @param [String] value The value to set for the JWT header # # @return [self] def set_jwt(value) @@ -74,8 +69,7 @@ def set_locale(value) # Set Session # # The user session to authenticate with - # - # @param [String] value The value to set for the Session header + # # @param [String] value The value to set for the Session header # # @return [self] def set_session(value) @@ -87,8 +81,7 @@ def set_session(value) # Set ForwardedUserAgent # # The user agent string of the client that made the request - # - # @param [String] value The value to set for the ForwardedUserAgent header + # # @param [String] value The value to set for the ForwardedUserAgent header # # @return [self] def set_forwarded_user_agent(value) @@ -119,7 +112,6 @@ def set_self_signed(self_signed = true) self end - # Add Header # # @param [String] key The key for the header to add @@ -162,20 +154,9 @@ def chunked_upload( on_progress: nil, response_type: nil ) - input_file = params[param_name.to_sym] - - case input_file.source_type - when 'path' - size = ::File.size(input_file.path) - when 'string' - size = input_file.data.bytesize - end + payload = params[param_name.to_sym] - if size < @chunk_size - if input_file.source_type == 'path' - input_file.data = IO.read(input_file.path) - end - params[param_name.to_sym] = input_file + if payload.size < @chunk_size return call( method: 'POST', path: path, @@ -199,21 +180,13 @@ def chunked_upload( offset = chunks_uploaded * @chunk_size end - while offset < size - case input_file.source_type - when 'path' - string = IO.read(input_file.path, @chunk_size, offset) - when 'string' - string = input_file.data.byteslice(offset, [@chunk_size, size - offset].min) - end - - params[param_name.to_sym] = InputFile::from_string( - string, - filename: input_file.filename, - mime_type: input_file.mime_type + while offset < payload.size + params[param_name.to_sym] = Payload.from_binary( + payload.to_binary(offset, [@chunk_size, payload.size - offset].min), + filename: payload.filename ) - headers['content-range'] = "bytes #{offset}-#{[offset + @chunk_size - 1, size - 1].min}/#{size}" + headers['content-range'] = "bytes #{offset}-#{[offset + @chunk_size - 1, payload.size - 1].min}/#{payload.size}" result = call( method: 'POST', @@ -230,8 +203,8 @@ def chunked_upload( on_progress.call({ id: result['$id'], - progress: ([offset, size].min).to_f/size.to_f * 100.0, - size_uploaded: [offset, size].min, + progress: ([offset, payload.size].min).to_f/payload.size.to_f * 100.0, + size_uploaded: [offset, payload.size].min, chunks_total: result['chunksTotal'], chunks_uploaded: result['chunksUploaded'] }) unless on_progress.nil? @@ -258,18 +231,27 @@ def fetch( @http.use_ssl = !@self_signed payload = '' - headers = @headers.merge(headers) + headers = @headers.merge(headers.transform_keys(&:to_s)) params.compact! - @boundary = "----A30#3ad1" if method != "GET" - case headers[:'content-type'] + case headers['content-type'] when 'application/json' payload = params.to_json when 'multipart/form-data' - payload = encode_form_data(params) + "--#{@boundary}--\r\n" - headers[:'content-type'] = "multipart/form-data; boundary=#{@boundary}" + multipart = MultipartBuilder.new() + + params.each do |name, value| + if value.is_a?(Payload) + multipart.add(name, value.to_s, filename: value.filename) + else + multipart.add(name, value) + end + end + + headers['content-type'] = multipart.content_type + payload = multipart.body else payload = encode(params) end @@ -299,7 +281,7 @@ def fetch( return fetch(method, uri, headers, {}, response_type, limit - 1) end - if response.content_type == 'application/json' + if response.content_type.start_with?('application/json') begin result = JSON.parse(response.body) rescue JSON::ParserError => e @@ -310,48 +292,33 @@ def fetch( raise Appwrite::Exception.new(result['message'], result['status'], result['type'], result) end - unless response_type.respond_to?("from") - return result + if response_type.respond_to?("from") + return response_type.from(map: result) end - return response_type.from(map: result) + return result end if response.code.to_i >= 400 raise Appwrite::Exception.new(response.body, response.code, response) end - if response.respond_to?("body_permitted?") - return response.body if response.body_permitted? - end + if response.content_type.start_with?('multipart/form-data') + multipart = MultipartParser.new(response.body, response['content-type']) + result = multipart.to_hash - return response - end - - def encode_form_data(value, key=nil) - case value - when Hash - value.map { |k,v| encode_form_data(v,k) }.join - when Array - value.map { |v| encode_form_data(v, "#{key}[]") }.join - when nil - '' - else - post_body = [] - if value.instance_of? InputFile - post_body << "--#{@boundary}" - post_body << "Content-Disposition: form-data; name=\"#{key}\"; filename=\"#{value.filename}\"" - post_body << "Content-Type: #{value.mime_type}" - post_body << "" - post_body << value.data - else - post_body << "--#{@boundary}" - post_body << "Content-Disposition: form-data; name=\"#{key}\"" - post_body << "" - post_body << value.to_s + if response_type.respond_to?("from") + return response_type.from(map: result) end - post_body.join("\r\n") + "\r\n" + + return result end + + if response.class.body_permitted? + return response.body + end + + return response end def encode(value, key = nil) diff --git a/lib/appwrite/enums/runtime.rb b/lib/appwrite/enums/runtime.rb index 23464bd..cd21aed 100644 --- a/lib/appwrite/enums/runtime.rb +++ b/lib/appwrite/enums/runtime.rb @@ -21,6 +21,9 @@ module Runtime PYTHON_3_11 = 'python-3.11' PYTHON_3_12 = 'python-3.12' PYTHON_ML_3_11 = 'python-ml-3.11' + DENO_1_21 = 'deno-1.21' + DENO_1_24 = 'deno-1.24' + DENO_1_35 = 'deno-1.35' DENO_1_40 = 'deno-1.40' DART_2_15 = 'dart-2.15' DART_2_16 = 'dart-2.16' diff --git a/lib/appwrite/input_file.rb b/lib/appwrite/input_file.rb deleted file mode 100644 index a704353..0000000 --- a/lib/appwrite/input_file.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'mime/types' - -module Appwrite - class InputFile - attr_accessor :path - attr_accessor :filename - attr_accessor :mime_type - attr_accessor :source_type - attr_accessor :data - - def self.from_path(path) - instance = InputFile.new - instance.path = path - instance.filename = ::File.basename(path) - instance.mime_type = MIME::Types.type_for(path).first.content_type - instance.source_type = 'path' - instance - end - - def self.from_string(string, filename: nil, mime_type: nil) - instance = InputFile.new - instance.data = string - instance.filename = filename - instance.mime_type = mime_type - instance.source_type = 'string' - instance - end - - def self.from_bytes(bytes, filename: nil, mime_type: nil) - self.from_string(bytes.pack('C*'), filename: filename, mime_type: mime_type) - end - end -end \ No newline at end of file diff --git a/lib/appwrite/models/document.rb b/lib/appwrite/models/document.rb index 59d200e..70d1b97 100644 --- a/lib/appwrite/models/document.rb +++ b/lib/appwrite/models/document.rb @@ -10,7 +10,6 @@ class Document attr_reader :updated_at attr_reader :permissions attr_reader :data - def initialize( id:, collection_id:, @@ -18,16 +17,14 @@ def initialize( created_at:, updated_at:, permissions:, - data: - ) + data: ) @id = id @collection_id = collection_id @database_id = database_id @created_at = created_at @updated_at = updated_at @permissions = permissions - @data = data - end + @data = data end def self.from(map:) Document.new( @@ -37,8 +34,7 @@ def self.from(map:) created_at: map["$createdAt"], updated_at: map["$updatedAt"], permissions: map["$permissions"], - data: map - ) + data: map ) end def to_map @@ -49,8 +45,7 @@ def to_map "$createdAt": @created_at, "$updatedAt": @updated_at, "$permissions": @permissions, - "data": @data - } + "data": @data } end def convert_to(from_json) diff --git a/lib/appwrite/models/document_list.rb b/lib/appwrite/models/document_list.rb index b2ae468..3841752 100644 --- a/lib/appwrite/models/document_list.rb +++ b/lib/appwrite/models/document_list.rb @@ -30,7 +30,6 @@ def to_map def convert_to(from_json) documents.map { |it| it.convert_to(from_json) } - end - end + end end end end diff --git a/lib/appwrite/models/preferences.rb b/lib/appwrite/models/preferences.rb index 31eee9b..b1da62e 100644 --- a/lib/appwrite/models/preferences.rb +++ b/lib/appwrite/models/preferences.rb @@ -4,23 +4,18 @@ module Appwrite module Models class Preferences attr_reader :data - def initialize( - data: - ) - @data = data - end + data: ) + @data = data end def self.from(map:) Preferences.new( - data: map - ) + data: map ) end def to_map { - "data": @data - } + "data": @data } end def convert_to(from_json) diff --git a/lib/appwrite/multipart.rb b/lib/appwrite/multipart.rb new file mode 100644 index 0000000..53f1dee --- /dev/null +++ b/lib/appwrite/multipart.rb @@ -0,0 +1,127 @@ +require 'mime/types' + +module Appwrite + class MultipartBuilder + attr_reader :boundary + + def initialize(boundary: nil) + @boundary = boundary ||= "----RubyMultipartPost#{rand(1000000)}" + @parts = [] + end + + def add(name, contents, filename: nil, content_type: nil) + if contents.is_a?(Array) + contents.each_with_index do |element, index| + add("#{name}[#{index}]", element) + end + return + end + + part = "--#{@boundary}\r\n" + part << "Content-Disposition: form-data; name=\"#{name}\"" + part << "; filename=\"#{filename}\"" if filename + part << "\r\n" + if content_type + part << "Content-Type: #{content_type}\r\n" + elsif filename + content_type = MIME::Types.type_for(filename).first&.content_type || 'application/octet-stream' + part << "Content-Type: #{content_type}\r\n" + end + part << "\r\n" + part << contents.to_s + part << "\r\n" + + @parts << part + end + + def body + @parts.join + "--#{@boundary}--\r\n" + end + + def content_type + "multipart/form-data; boundary=#{@boundary}" + end + end + + class MultipartParser + attr_reader :parts + + def initialize(multipart_string, content_type) + @multipart_string = multipart_string + @boundary = _extract_boundary(content_type) + @parts = {} + parse + end + + def _extract_boundary(content_type) + match = content_type.match(/boundary="?(.+?)"?(?:\s*;|$)/) + if match + return match[1] + end + + puts content_type + + raise "Boundary not found in Content-Type header" + end + + def parse + # Split the multipart string into individual parts + parts = @multipart_string.split("--#{@boundary}") + + # Remove the first (empty) and last (boundary end) elements + parts = parts[1...-1] + + parts.each do |part| + # Split headers and content + headers, content = part.strip.split("\r\n\r\n", 2) + + # Parse headers + headers_hash = headers.split("\r\n").each_with_object({}) do |header, hash| + key, value = header.split(": ", 2) + hash[key.downcase] = value + end + + # Extract name from Content-Disposition header + content_disposition = headers_hash["content-disposition"] || "" + name = content_disposition[/name="([^"]*)"/, 1] + + # If no name is found, use a default naming scheme + name ||= "unnamed_part_#{@parts.length}" + + # Store the parsed data + @parts[name] = { + contents: content.strip, + headers: headers_hash + } + end + end + + def to_hash + h = {} + + @parts.each do |name, part| + case name + when "responseBody" + h[name] = Payload.from_binary(part[:contents]) + when "responseHeaders" + h[name] = part[:contents].split("\r\n").each_with_object({}) do |header, hash| + key, value = header.split(": ", 2) + hash[key] = value + end + when "responseStatusCode" + h[name] = part[:contents].to_i + when "duration" + h[name] = part[:contents].to_f + else + begin + h[name] = part[:contents].force_encoding("utf-8") + rescue + h[name] = part[:contents] + end + end + end + + h + end + end +end \ No newline at end of file diff --git a/lib/appwrite/payload.rb b/lib/appwrite/payload.rb new file mode 100644 index 0000000..ae3ab77 --- /dev/null +++ b/lib/appwrite/payload.rb @@ -0,0 +1,94 @@ +require 'fileutils' + +module Appwrite + class Payload + attr_reader :filename + attr_reader :size + + def initialize(data, path, filename) + if data.nil? && path.nil? then + raise ArgumentError.new('Payload must have one of data or path') + end + + @path = path + @data = data + + @filename = filename + @size = if @data then + @data.bytesize + else + File.size(@path) + end + end + + # @param [Integer] offset + # @param [Integer] length + # @return [String] + def to_binary(offset = 0, length = nil) + length ||= @size - offset + if @data then + @data.byteslice(offset, length) + else + IO.read(@path, length, offset) + end + end + + # @return [String] + def to_s() + to_binary().force_encoding('UTF-8') + end + + alias to_string to_s + + # @return [Hash] + def to_json() + JSON.parse(to_s()) + end + + # @param [String] path + # @return [void] + def to_file(path) + FileUtils.mkdir_p(File.dirname(path)) + File.open(path, 'wb') { |f| f.write(to_binary()) } + end + + # @param [String] bytes + # @param [String, nil] filename + # @return [Payload] + def self.from_binary(bytes, filename: nil) + new(bytes, nil, filename) + end + + # @param [String] string + # @param [String, nil] filename + # @return [Payload] + def self.from_string(string, filename: nil) + bytes = string.encode('UTF-8') + new(bytes, nil, filename) + end + + # @param [Hash, Array] object + # @param [String, nil] filename + # @return [Payload] + def self.from_json(object, filename: nil) + if !object.is_a?(Hash) && !object.is_a?(Array) then + raise ArgumentError.new('Object must be a Hash or Array') + end + json = JSON.generate(object) + self.from_string(json, filename: filename) + end + + # @param [String] path + # @param [String, nil] filename + # @return [Payload] + def self.from_file(path, filename: nil) + raise ArgumentError.new('File not found') if !File.exists?(path) + filename = if filename.nil? then + File.basename(path) + else + filename + end + new(nil, path, filename) + 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..e62802b 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -61,10 +61,10 @@ def create(user_id:, email:, password:, name: nil) end api_params = { - userId: user_id, - email: email, - password: password, - name: name, + userId: user_id, + email: email, + password: password, + name: name, } api_headers = { @@ -106,8 +106,8 @@ def update_email(email:, password:) end api_params = { - email: email, - password: password, + email: email, + password: password, } api_headers = { @@ -133,7 +133,7 @@ def list_identities(queries: nil) api_path = '/account/identities' api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -217,7 +217,7 @@ def list_logs(queries: nil) api_path = '/account/logs' api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -247,7 +247,7 @@ def update_mfa(mfa:) end api_params = { - mfa: mfa, + mfa: mfa, } api_headers = { @@ -318,7 +318,7 @@ def update_mfa_authenticator(type:, otp:) end api_params = { - otp: otp, + otp: otp, } api_headers = { @@ -379,7 +379,7 @@ def create_mfa_challenge(factor:) end api_params = { - factor: factor, + factor: factor, } api_headers = { @@ -418,8 +418,8 @@ def update_mfa_challenge(challenge_id:, otp:) end api_params = { - challengeId: challenge_id, - otp: otp, + challengeId: challenge_id, + otp: otp, } api_headers = { @@ -554,7 +554,7 @@ def update_name(name:) end api_params = { - name: name, + name: name, } api_headers = { @@ -587,8 +587,8 @@ def update_password(password:, old_password: nil) end api_params = { - password: password, - oldPassword: old_password, + password: password, + oldPassword: old_password, } api_headers = { @@ -627,8 +627,8 @@ def update_phone(phone:, password:) end api_params = { - phone: phone, - password: password, + phone: phone, + password: password, } api_headers = { @@ -684,7 +684,7 @@ def update_prefs(prefs:) end api_params = { - prefs: prefs, + prefs: prefs, } api_headers = { @@ -726,8 +726,8 @@ def create_recovery(email:, url:) end api_params = { - email: email, - url: url, + email: email, + url: url, } api_headers = { @@ -776,9 +776,9 @@ def update_recovery(user_id:, secret:, password:) end api_params = { - userId: user_id, - secret: secret, - password: password, + userId: user_id, + secret: secret, + password: password, } api_headers = { @@ -897,8 +897,8 @@ def create_email_password_session(email:, password:) end api_params = { - email: email, - password: password, + email: email, + password: password, } api_headers = { @@ -935,8 +935,8 @@ def update_magic_url_session(user_id:, secret:) end api_params = { - userId: user_id, - secret: secret, + userId: user_id, + secret: secret, } api_headers = { @@ -973,8 +973,8 @@ def update_phone_session(user_id:, secret:) end api_params = { - userId: user_id, - secret: secret, + userId: user_id, + secret: secret, } api_headers = { @@ -1011,8 +1011,8 @@ def create_session(user_id:, secret:) end api_params = { - userId: user_id, - secret: secret, + userId: user_id, + secret: secret, } api_headers = { @@ -1179,9 +1179,9 @@ def create_email_token(user_id:, email:, phrase: nil) end api_params = { - userId: user_id, - email: email, - phrase: phrase, + userId: user_id, + email: email, + phrase: phrase, } api_headers = { @@ -1233,10 +1233,10 @@ def create_magic_url_token(user_id:, email:, url: nil, phrase: nil) end api_params = { - userId: user_id, - email: email, - url: url, - phrase: phrase, + userId: user_id, + email: email, + url: url, + phrase: phrase, } api_headers = { @@ -1283,9 +1283,9 @@ def create_o_auth2_token(provider:, success: nil, failure: nil, scopes: nil) end api_params = { - success: success, - failure: failure, - scopes: scopes, + success: success, + failure: failure, + scopes: scopes, } api_headers = { @@ -1329,8 +1329,8 @@ def create_phone_token(user_id:, phone:) end api_params = { - userId: user_id, - phone: phone, + userId: user_id, + phone: phone, } api_headers = { @@ -1374,7 +1374,7 @@ def create_verification(url:) end api_params = { - url: url, + url: url, } api_headers = { @@ -1412,8 +1412,8 @@ def update_verification(user_id:, secret:) end api_params = { - userId: user_id, - secret: secret, + userId: user_id, + secret: secret, } api_headers = { @@ -1482,8 +1482,8 @@ def update_phone_verification(user_id:, secret:) end api_params = { - userId: user_id, - secret: secret, + userId: user_id, + secret: secret, } api_headers = { diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index 60c3f68..58edbcc 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -33,9 +33,9 @@ def get_browser(code:, width: nil, height: nil, quality: nil) end api_params = { - width: width, - height: height, - quality: quality, + width: width, + height: height, + quality: quality, } api_headers = { @@ -76,9 +76,9 @@ def get_credit_card(code:, width: nil, height: nil, quality: nil) end api_params = { - width: width, - height: height, - quality: quality, + width: width, + height: height, + quality: quality, } api_headers = { @@ -110,7 +110,7 @@ def get_favicon(url:) end api_params = { - url: url, + url: url, } api_headers = { @@ -152,9 +152,9 @@ def get_flag(code:, width: nil, height: nil, quality: nil) end api_params = { - width: width, - height: height, - quality: quality, + width: width, + height: height, + quality: quality, } api_headers = { @@ -195,9 +195,9 @@ def get_image(url:, width: nil, height: nil) end api_params = { - url: url, - width: width, - height: height, + url: url, + width: width, + height: height, } api_headers = { @@ -240,10 +240,10 @@ def get_initials(name: nil, width: nil, height: nil, background: nil) api_path = '/avatars/initials' api_params = { - name: name, - width: width, - height: height, - background: background, + name: name, + width: width, + height: height, + background: background, } api_headers = { @@ -277,10 +277,10 @@ def get_qr(text:, size: nil, margin: nil, download: nil) end api_params = { - text: text, - size: size, - margin: margin, - download: download, + text: text, + size: size, + margin: margin, + download: download, } api_headers = { diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index 27e0f13..bee13e2 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -18,8 +18,8 @@ def list(queries: nil, search: nil) api_path = '/databases' api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -56,9 +56,9 @@ def create(database_id:, name:, enabled: nil) end api_params = { - databaseId: database_id, - name: name, - enabled: enabled, + databaseId: database_id, + name: name, + enabled: enabled, } api_headers = { @@ -126,8 +126,8 @@ def update(database_id:, name:, enabled: nil) end api_params = { - name: name, - enabled: enabled, + name: name, + enabled: enabled, } api_headers = { @@ -191,8 +191,8 @@ def list_collections(database_id:, queries: nil, search: nil) end api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -239,11 +239,11 @@ def create_collection(database_id:, collection_id:, name:, permissions: nil, doc end api_params = { - collectionId: collection_id, - name: name, - permissions: permissions, - documentSecurity: document_security, - enabled: enabled, + collectionId: collection_id, + name: name, + permissions: permissions, + documentSecurity: document_security, + enabled: enabled, } api_headers = { @@ -325,10 +325,10 @@ def update_collection(database_id:, collection_id:, name:, permissions: nil, doc end api_params = { - name: name, - permissions: permissions, - documentSecurity: document_security, - enabled: enabled, + name: name, + permissions: permissions, + documentSecurity: document_security, + enabled: enabled, } api_headers = { @@ -402,7 +402,7 @@ def list_attributes(database_id:, collection_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -452,10 +452,10 @@ def create_boolean_attribute(database_id:, collection_id:, key:, required:, defa end api_params = { - key: key, - required: required, - default: default, - array: array, + key: key, + required: required, + default: default, + array: array, } api_headers = { @@ -510,9 +510,9 @@ def update_boolean_attribute(database_id:, collection_id:, key:, required:, defa end api_params = { - required: required, - default: default, - newKey: new_key, + required: required, + default: default, + newKey: new_key, } api_headers = { @@ -561,10 +561,10 @@ def create_datetime_attribute(database_id:, collection_id:, key:, required:, def end api_params = { - key: key, - required: required, - default: default, - array: array, + key: key, + required: required, + default: default, + array: array, } api_headers = { @@ -619,9 +619,9 @@ def update_datetime_attribute(database_id:, collection_id:, key:, required:, def end api_params = { - required: required, - default: default, - newKey: new_key, + required: required, + default: default, + newKey: new_key, } api_headers = { @@ -671,10 +671,10 @@ def create_email_attribute(database_id:, collection_id:, key:, required:, defaul end api_params = { - key: key, - required: required, - default: default, - array: array, + key: key, + required: required, + default: default, + array: array, } api_headers = { @@ -730,9 +730,9 @@ def update_email_attribute(database_id:, collection_id:, key:, required:, defaul end api_params = { - required: required, - default: default, - newKey: new_key, + required: required, + default: default, + newKey: new_key, } api_headers = { @@ -788,11 +788,11 @@ def create_enum_attribute(database_id:, collection_id:, key:, elements:, require end api_params = { - key: key, - elements: elements, - required: required, - default: default, - array: array, + key: key, + elements: elements, + required: required, + default: default, + array: array, } api_headers = { @@ -853,10 +853,10 @@ def update_enum_attribute(database_id:, collection_id:, key:, elements:, require end api_params = { - elements: elements, - required: required, - default: default, - newKey: new_key, + elements: elements, + required: required, + default: default, + newKey: new_key, } api_headers = { @@ -909,12 +909,12 @@ def create_float_attribute(database_id:, collection_id:, key:, required:, min: n end api_params = { - key: key, - required: required, - min: min, - max: max, - default: default, - array: array, + key: key, + required: required, + min: min, + max: max, + default: default, + array: array, } api_headers = { @@ -980,11 +980,11 @@ def update_float_attribute(database_id:, collection_id:, key:, required:, min:, end api_params = { - required: required, - min: min, - max: max, - default: default, - newKey: new_key, + required: required, + min: min, + max: max, + default: default, + newKey: new_key, } api_headers = { @@ -1037,12 +1037,12 @@ def create_integer_attribute(database_id:, collection_id:, key:, required:, min: end api_params = { - key: key, - required: required, - min: min, - max: max, - default: default, - array: array, + key: key, + required: required, + min: min, + max: max, + default: default, + array: array, } api_headers = { @@ -1108,11 +1108,11 @@ def update_integer_attribute(database_id:, collection_id:, key:, required:, min: end api_params = { - required: required, - min: min, - max: max, - default: default, - newKey: new_key, + required: required, + min: min, + max: max, + default: default, + newKey: new_key, } api_headers = { @@ -1162,10 +1162,10 @@ def create_ip_attribute(database_id:, collection_id:, key:, required:, default: end api_params = { - key: key, - required: required, - default: default, - array: array, + key: key, + required: required, + default: default, + array: array, } api_headers = { @@ -1221,9 +1221,9 @@ def update_ip_attribute(database_id:, collection_id:, key:, required:, default:, end api_params = { - required: required, - default: default, - newKey: new_key, + required: required, + default: default, + newKey: new_key, } api_headers = { @@ -1276,12 +1276,12 @@ def create_relationship_attribute(database_id:, collection_id:, related_collecti end api_params = { - relatedCollectionId: related_collection_id, - type: type, - twoWay: two_way, - key: key, - twoWayKey: two_way_key, - onDelete: on_delete, + relatedCollectionId: related_collection_id, + type: type, + twoWay: two_way, + key: key, + twoWayKey: two_way_key, + onDelete: on_delete, } api_headers = { @@ -1337,12 +1337,12 @@ def create_string_attribute(database_id:, collection_id:, key:, size:, required: end api_params = { - key: key, - size: size, - required: required, - default: default, - array: array, - encrypt: encrypt, + key: key, + size: size, + required: required, + default: default, + array: array, + encrypt: encrypt, } api_headers = { @@ -1399,10 +1399,10 @@ def update_string_attribute(database_id:, collection_id:, key:, required:, defau end api_params = { - required: required, - default: default, - size: size, - newKey: new_key, + required: required, + default: default, + size: size, + newKey: new_key, } api_headers = { @@ -1452,10 +1452,10 @@ def create_url_attribute(database_id:, collection_id:, key:, required:, default: end api_params = { - key: key, - required: required, - default: default, - array: array, + key: key, + required: required, + default: default, + array: array, } api_headers = { @@ -1511,9 +1511,9 @@ def update_url_attribute(database_id:, collection_id:, key:, required:, default: end api_params = { - required: required, - default: default, - newKey: new_key, + required: required, + default: default, + newKey: new_key, } api_headers = { @@ -1642,8 +1642,8 @@ def update_relationship_attribute(database_id:, collection_id:, key:, on_delete: end api_params = { - onDelete: on_delete, - newKey: new_key, + onDelete: on_delete, + newKey: new_key, } api_headers = { @@ -1682,7 +1682,7 @@ def list_documents(database_id:, collection_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -1733,9 +1733,9 @@ def create_document(database_id:, collection_id:, document_id:, data:, permissio end api_params = { - documentId: document_id, - data: data, - permissions: permissions, + documentId: document_id, + data: data, + permissions: permissions, } api_headers = { @@ -1780,7 +1780,7 @@ def get_document(database_id:, collection_id:, document_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -1826,8 +1826,8 @@ def update_document(database_id:, collection_id:, document_id:, data: nil, permi end api_params = { - data: data, - permissions: permissions, + data: data, + permissions: permissions, } api_headers = { @@ -1906,7 +1906,7 @@ def list_indexes(database_id:, collection_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -1961,10 +1961,10 @@ def create_index(database_id:, collection_id:, key:, type:, attributes:, orders: end api_params = { - key: key, - type: type, - attributes: attributes, - orders: orders, + key: key, + type: type, + attributes: attributes, + orders: orders, } api_headers = { diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index 2022149..2dac625 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -18,8 +18,8 @@ def list(queries: nil, search: nil) api_path = '/functions' api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -81,28 +81,28 @@ def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: n end api_params = { - functionId: function_id, - name: name, - runtime: runtime, - execute: execute, - events: events, - schedule: schedule, - timeout: timeout, - enabled: enabled, - logging: logging, - entrypoint: entrypoint, - commands: commands, - scopes: scopes, - installationId: installation_id, - providerRepositoryId: provider_repository_id, - providerBranch: provider_branch, - providerSilentMode: provider_silent_mode, - providerRootDirectory: provider_root_directory, - templateRepository: template_repository, - templateOwner: template_owner, - templateRootDirectory: template_root_directory, - templateVersion: template_version, - specification: specification, + functionId: function_id, + name: name, + runtime: runtime, + execute: execute, + events: events, + schedule: schedule, + timeout: timeout, + enabled: enabled, + logging: logging, + entrypoint: entrypoint, + commands: commands, + scopes: scopes, + installationId: installation_id, + providerRepositoryId: provider_repository_id, + providerBranch: provider_branch, + providerSilentMode: provider_silent_mode, + providerRootDirectory: provider_root_directory, + templateRepository: template_repository, + templateOwner: template_owner, + templateRootDirectory: template_root_directory, + templateVersion: template_version, + specification: specification, } api_headers = { @@ -233,23 +233,23 @@ def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedul end api_params = { - name: name, - runtime: runtime, - execute: execute, - events: events, - schedule: schedule, - timeout: timeout, - enabled: enabled, - logging: logging, - entrypoint: entrypoint, - commands: commands, - scopes: scopes, - installationId: installation_id, - providerRepositoryId: provider_repository_id, - providerBranch: provider_branch, - providerSilentMode: provider_silent_mode, - providerRootDirectory: provider_root_directory, - specification: specification, + name: name, + runtime: runtime, + execute: execute, + events: events, + schedule: schedule, + timeout: timeout, + enabled: enabled, + logging: logging, + entrypoint: entrypoint, + commands: commands, + scopes: scopes, + installationId: installation_id, + providerRepositoryId: provider_repository_id, + providerBranch: provider_branch, + providerSilentMode: provider_silent_mode, + providerRootDirectory: provider_root_directory, + specification: specification, } api_headers = { @@ -312,8 +312,8 @@ def list_deployments(function_id:, queries: nil, search: nil) end api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -342,7 +342,7 @@ def list_deployments(function_id:, queries: nil, search: nil) # Use the "command" param to set the entrypoint used to execute your code. # # @param [String] function_id Function ID. - # @param [file] code Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. + # @param [Payload] code Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory. # @param [] activate Automatically activate the deployment when it is finished building. # @param [String] entrypoint Entrypoint File. # @param [String] commands Build Commands. @@ -365,10 +365,10 @@ def create_deployment(function_id:, code:, activate:, entrypoint: nil, commands: end api_params = { - entrypoint: entrypoint, - commands: commands, - code: code, - activate: activate, + entrypoint: entrypoint, + commands: commands, + code: code, + activate: activate, } api_headers = { @@ -520,7 +520,7 @@ def create_build(function_id:, deployment_id:, build_id: nil) end api_params = { - buildId: build_id, + buildId: build_id, } api_headers = { @@ -625,8 +625,8 @@ def list_executions(function_id:, queries: nil, search: nil) end api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -649,7 +649,7 @@ def list_executions(function_id:, queries: nil, search: nil) # function execution process will start asynchronously. # # @param [String] function_id Function ID. - # @param [String] body HTTP body of execution. Default value is empty string. + # @param [Payload] body HTTP body of execution. Default value is empty string. # @param [] async Execute code in the background. Default value is false. # @param [String] xpath HTTP path of execution. Path can include query params. Default value is / # @param [ExecutionMethod] method HTTP method of execution. Default value is GET. @@ -657,7 +657,7 @@ def list_executions(function_id:, queries: nil, search: nil) # @param [String] scheduled_at Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. # # @return [Execution] - def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: nil, headers: nil, scheduled_at: nil) + def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: nil, headers: nil, scheduled_at: nil, on_progress: nil) api_path = '/functions/{functionId}/executions' .gsub('{functionId}', function_id) @@ -666,16 +666,16 @@ def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: ni end api_params = { - body: body, - async: async, - path: xpath, - method: method, - headers: headers, - scheduledAt: scheduled_at, + body: body, + async: async, + path: xpath, + method: method, + headers: headers, + scheduledAt: scheduled_at, } api_headers = { - "content-type": 'application/json', + "content-type": 'multipart/form-data', } @client.call( @@ -815,8 +815,8 @@ def create_variable(function_id:, key:, value:) end api_params = { - key: key, - value: value, + key: key, + value: value, } api_headers = { @@ -895,8 +895,8 @@ def update_variable(function_id:, variable_id:, key:, value: nil) end api_params = { - key: key, - value: value, + key: key, + value: value, } api_headers = { diff --git a/lib/appwrite/services/graphql.rb b/lib/appwrite/services/graphql.rb index b9db9a0..c222e0e 100644 --- a/lib/appwrite/services/graphql.rb +++ b/lib/appwrite/services/graphql.rb @@ -20,7 +20,7 @@ def query(query:) end api_params = { - query: query, + query: query, } api_headers = { @@ -50,7 +50,7 @@ def mutation(query:) end api_params = { - query: query, + query: query, } api_headers = { diff --git a/lib/appwrite/services/health.rb b/lib/appwrite/services/health.rb index 4415a13..5bebc5f 100644 --- a/lib/appwrite/services/health.rb +++ b/lib/appwrite/services/health.rb @@ -89,7 +89,7 @@ def get_certificate(domain: nil) api_path = '/health/certificate' api_params = { - domain: domain, + domain: domain, } api_headers = { @@ -189,7 +189,7 @@ def get_queue_builds(threshold: nil) api_path = '/health/queue/builds' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -217,7 +217,7 @@ def get_queue_certificates(threshold: nil) api_path = '/health/queue/certificates' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -245,8 +245,8 @@ def get_queue_databases(name: nil, threshold: nil) api_path = '/health/queue/databases' api_params = { - name: name, - threshold: threshold, + name: name, + threshold: threshold, } api_headers = { @@ -273,7 +273,7 @@ def get_queue_deletes(threshold: nil) api_path = '/health/queue/deletes' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -306,7 +306,7 @@ def get_failed_jobs(name:, threshold: nil) end api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -333,7 +333,7 @@ def get_queue_functions(threshold: nil) api_path = '/health/queue/functions' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -360,7 +360,7 @@ def get_queue_logs(threshold: nil) api_path = '/health/queue/logs' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -387,7 +387,7 @@ def get_queue_mails(threshold: nil) api_path = '/health/queue/mails' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -414,7 +414,7 @@ def get_queue_messaging(threshold: nil) api_path = '/health/queue/messaging' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -441,7 +441,7 @@ def get_queue_migrations(threshold: nil) api_path = '/health/queue/migrations' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -468,7 +468,7 @@ def get_queue_usage(threshold: nil) api_path = '/health/queue/usage' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -495,7 +495,7 @@ def get_queue_usage_dump(threshold: nil) api_path = '/health/queue/usage-dump' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { @@ -522,7 +522,7 @@ def get_queue_webhooks(threshold: nil) api_path = '/health/queue/webhooks' api_params = { - threshold: threshold, + threshold: threshold, } api_headers = { diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index 49e952f..ee7ccf8 100644 --- a/lib/appwrite/services/messaging.rb +++ b/lib/appwrite/services/messaging.rb @@ -17,8 +17,8 @@ def list_messages(queries: nil, search: nil) api_path = '/messaging/messages' api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -67,18 +67,18 @@ def create_email(message_id:, subject:, content:, topics: nil, users: nil, targe end api_params = { - messageId: message_id, - subject: subject, - content: content, - topics: topics, - users: users, - targets: targets, - cc: cc, - bcc: bcc, - attachments: attachments, - draft: draft, - html: html, - scheduledAt: scheduled_at, + messageId: message_id, + subject: subject, + content: content, + topics: topics, + users: users, + targets: targets, + cc: cc, + bcc: bcc, + attachments: attachments, + draft: draft, + html: html, + scheduledAt: scheduled_at, } api_headers = { @@ -121,17 +121,17 @@ def update_email(message_id:, topics: nil, users: nil, targets: nil, subject: ni end api_params = { - topics: topics, - users: users, - targets: targets, - subject: subject, - content: content, - draft: draft, - html: html, - cc: cc, - bcc: bcc, - scheduledAt: scheduled_at, - attachments: attachments, + topics: topics, + users: users, + targets: targets, + subject: subject, + content: content, + draft: draft, + html: html, + cc: cc, + bcc: bcc, + scheduledAt: scheduled_at, + attachments: attachments, } api_headers = { @@ -184,22 +184,22 @@ def create_push(message_id:, title:, body:, topics: nil, users: nil, targets: ni end api_params = { - messageId: message_id, - title: title, - body: body, - topics: topics, - users: users, - targets: targets, - data: data, - action: action, - image: image, - icon: icon, - sound: sound, - color: color, - tag: tag, - badge: badge, - draft: draft, - scheduledAt: scheduled_at, + messageId: message_id, + title: title, + body: body, + topics: topics, + users: users, + targets: targets, + data: data, + action: action, + image: image, + icon: icon, + sound: sound, + color: color, + tag: tag, + badge: badge, + draft: draft, + scheduledAt: scheduled_at, } api_headers = { @@ -246,21 +246,21 @@ def update_push(message_id:, topics: nil, users: nil, targets: nil, title: nil, end api_params = { - topics: topics, - users: users, - targets: targets, - title: title, - body: body, - data: data, - action: action, - image: image, - icon: icon, - sound: sound, - color: color, - tag: tag, - badge: badge, - draft: draft, - scheduledAt: scheduled_at, + topics: topics, + users: users, + targets: targets, + title: title, + body: body, + data: data, + action: action, + image: image, + icon: icon, + sound: sound, + color: color, + tag: tag, + badge: badge, + draft: draft, + scheduledAt: scheduled_at, } api_headers = { @@ -300,13 +300,13 @@ def create_sms(message_id:, content:, topics: nil, users: nil, targets: nil, dra end api_params = { - messageId: message_id, - content: content, - topics: topics, - users: users, - targets: targets, - draft: draft, - scheduledAt: scheduled_at, + messageId: message_id, + content: content, + topics: topics, + users: users, + targets: targets, + draft: draft, + scheduledAt: scheduled_at, } api_headers = { @@ -344,12 +344,12 @@ def update_sms(message_id:, topics: nil, users: nil, targets: nil, content: nil, end api_params = { - topics: topics, - users: users, - targets: targets, - content: content, - draft: draft, - scheduledAt: scheduled_at, + topics: topics, + users: users, + targets: targets, + content: content, + draft: draft, + scheduledAt: scheduled_at, } api_headers = { @@ -442,7 +442,7 @@ def list_message_logs(message_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -474,7 +474,7 @@ def list_targets(message_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -501,8 +501,8 @@ def list_providers(queries: nil, search: nil) api_path = '/messaging/providers' api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -543,14 +543,14 @@ def create_apns_provider(provider_id:, name:, auth_key: nil, auth_key_id: nil, t end api_params = { - providerId: provider_id, - name: name, - authKey: auth_key, - authKeyId: auth_key_id, - teamId: team_id, - bundleId: bundle_id, - sandbox: sandbox, - enabled: enabled, + providerId: provider_id, + name: name, + authKey: auth_key, + authKeyId: auth_key_id, + teamId: team_id, + bundleId: bundle_id, + sandbox: sandbox, + enabled: enabled, } api_headers = { @@ -588,13 +588,13 @@ def update_apns_provider(provider_id:, name: nil, enabled: nil, auth_key: nil, a end api_params = { - name: name, - enabled: enabled, - authKey: auth_key, - authKeyId: auth_key_id, - teamId: team_id, - bundleId: bundle_id, - sandbox: sandbox, + name: name, + enabled: enabled, + authKey: auth_key, + authKeyId: auth_key_id, + teamId: team_id, + bundleId: bundle_id, + sandbox: sandbox, } api_headers = { @@ -631,10 +631,10 @@ def create_fcm_provider(provider_id:, name:, service_account_json: nil, enabled: end api_params = { - providerId: provider_id, - name: name, - serviceAccountJSON: service_account_json, - enabled: enabled, + providerId: provider_id, + name: name, + serviceAccountJSON: service_account_json, + enabled: enabled, } api_headers = { @@ -668,9 +668,9 @@ def update_fcm_provider(provider_id:, name: nil, enabled: nil, service_account_j end api_params = { - name: name, - enabled: enabled, - serviceAccountJSON: service_account_json, + name: name, + enabled: enabled, + serviceAccountJSON: service_account_json, } api_headers = { @@ -713,16 +713,16 @@ def create_mailgun_provider(provider_id:, name:, api_key: nil, domain: nil, is_e end api_params = { - providerId: provider_id, - name: name, - apiKey: api_key, - domain: domain, - isEuRegion: is_eu_region, - fromName: from_name, - fromEmail: from_email, - replyToName: reply_to_name, - replyToEmail: reply_to_email, - enabled: enabled, + providerId: provider_id, + name: name, + apiKey: api_key, + domain: domain, + isEuRegion: is_eu_region, + fromName: from_name, + fromEmail: from_email, + replyToName: reply_to_name, + replyToEmail: reply_to_email, + enabled: enabled, } api_headers = { @@ -762,15 +762,15 @@ def update_mailgun_provider(provider_id:, name: nil, api_key: nil, domain: nil, end api_params = { - name: name, - apiKey: api_key, - domain: domain, - isEuRegion: is_eu_region, - enabled: enabled, - fromName: from_name, - fromEmail: from_email, - replyToName: reply_to_name, - replyToEmail: reply_to_email, + name: name, + apiKey: api_key, + domain: domain, + isEuRegion: is_eu_region, + enabled: enabled, + fromName: from_name, + fromEmail: from_email, + replyToName: reply_to_name, + replyToEmail: reply_to_email, } api_headers = { @@ -809,12 +809,12 @@ def create_msg91_provider(provider_id:, name:, template_id: nil, sender_id: nil, end api_params = { - providerId: provider_id, - name: name, - templateId: template_id, - senderId: sender_id, - authKey: auth_key, - enabled: enabled, + providerId: provider_id, + name: name, + templateId: template_id, + senderId: sender_id, + authKey: auth_key, + enabled: enabled, } api_headers = { @@ -850,11 +850,11 @@ def update_msg91_provider(provider_id:, name: nil, enabled: nil, template_id: ni end api_params = { - name: name, - enabled: enabled, - templateId: template_id, - senderId: sender_id, - authKey: auth_key, + name: name, + enabled: enabled, + templateId: template_id, + senderId: sender_id, + authKey: auth_key, } api_headers = { @@ -895,14 +895,14 @@ def create_sendgrid_provider(provider_id:, name:, api_key: nil, from_name: nil, end api_params = { - providerId: provider_id, - name: name, - apiKey: api_key, - fromName: from_name, - fromEmail: from_email, - replyToName: reply_to_name, - replyToEmail: reply_to_email, - enabled: enabled, + providerId: provider_id, + name: name, + apiKey: api_key, + fromName: from_name, + fromEmail: from_email, + replyToName: reply_to_name, + replyToEmail: reply_to_email, + enabled: enabled, } api_headers = { @@ -940,13 +940,13 @@ def update_sendgrid_provider(provider_id:, name: nil, enabled: nil, api_key: nil end api_params = { - name: name, - enabled: enabled, - apiKey: api_key, - fromName: from_name, - fromEmail: from_email, - replyToName: reply_to_name, - replyToEmail: reply_to_email, + name: name, + enabled: enabled, + apiKey: api_key, + fromName: from_name, + fromEmail: from_email, + replyToName: reply_to_name, + replyToEmail: reply_to_email, } api_headers = { @@ -997,20 +997,20 @@ def create_smtp_provider(provider_id:, name:, host:, port: nil, username: nil, p end api_params = { - providerId: provider_id, - name: name, - host: host, - port: port, - username: username, - password: password, - encryption: encryption, - autoTLS: auto_tls, - mailer: mailer, - fromName: from_name, - fromEmail: from_email, - replyToName: reply_to_name, - replyToEmail: reply_to_email, - enabled: enabled, + providerId: provider_id, + name: name, + host: host, + port: port, + username: username, + password: password, + encryption: encryption, + autoTLS: auto_tls, + mailer: mailer, + fromName: from_name, + fromEmail: from_email, + replyToName: reply_to_name, + replyToEmail: reply_to_email, + enabled: enabled, } api_headers = { @@ -1054,19 +1054,19 @@ def update_smtp_provider(provider_id:, name: nil, host: nil, port: nil, username end api_params = { - name: name, - host: host, - port: port, - username: username, - password: password, - encryption: encryption, - autoTLS: auto_tls, - mailer: mailer, - fromName: from_name, - fromEmail: from_email, - replyToName: reply_to_name, - replyToEmail: reply_to_email, - enabled: enabled, + name: name, + host: host, + port: port, + username: username, + password: password, + encryption: encryption, + autoTLS: auto_tls, + mailer: mailer, + fromName: from_name, + fromEmail: from_email, + replyToName: reply_to_name, + replyToEmail: reply_to_email, + enabled: enabled, } api_headers = { @@ -1105,12 +1105,12 @@ def create_telesign_provider(provider_id:, name:, from: nil, customer_id: nil, a end api_params = { - providerId: provider_id, - name: name, - from: from, - customerId: customer_id, - apiKey: api_key, - enabled: enabled, + providerId: provider_id, + name: name, + from: from, + customerId: customer_id, + apiKey: api_key, + enabled: enabled, } api_headers = { @@ -1146,11 +1146,11 @@ def update_telesign_provider(provider_id:, name: nil, enabled: nil, customer_id: end api_params = { - name: name, - enabled: enabled, - customerId: customer_id, - apiKey: api_key, - from: from, + name: name, + enabled: enabled, + customerId: customer_id, + apiKey: api_key, + from: from, } api_headers = { @@ -1189,12 +1189,12 @@ def create_textmagic_provider(provider_id:, name:, from: nil, username: nil, api end api_params = { - providerId: provider_id, - name: name, - from: from, - username: username, - apiKey: api_key, - enabled: enabled, + providerId: provider_id, + name: name, + from: from, + username: username, + apiKey: api_key, + enabled: enabled, } api_headers = { @@ -1230,11 +1230,11 @@ def update_textmagic_provider(provider_id:, name: nil, enabled: nil, username: n end api_params = { - name: name, - enabled: enabled, - username: username, - apiKey: api_key, - from: from, + name: name, + enabled: enabled, + username: username, + apiKey: api_key, + from: from, } api_headers = { @@ -1273,12 +1273,12 @@ def create_twilio_provider(provider_id:, name:, from: nil, account_sid: nil, aut end api_params = { - providerId: provider_id, - name: name, - from: from, - accountSid: account_sid, - authToken: auth_token, - enabled: enabled, + providerId: provider_id, + name: name, + from: from, + accountSid: account_sid, + authToken: auth_token, + enabled: enabled, } api_headers = { @@ -1314,11 +1314,11 @@ def update_twilio_provider(provider_id:, name: nil, enabled: nil, account_sid: n end api_params = { - name: name, - enabled: enabled, - accountSid: account_sid, - authToken: auth_token, - from: from, + name: name, + enabled: enabled, + accountSid: account_sid, + authToken: auth_token, + from: from, } api_headers = { @@ -1357,12 +1357,12 @@ def create_vonage_provider(provider_id:, name:, from: nil, api_key: nil, api_sec end api_params = { - providerId: provider_id, - name: name, - from: from, - apiKey: api_key, - apiSecret: api_secret, - enabled: enabled, + providerId: provider_id, + name: name, + from: from, + apiKey: api_key, + apiSecret: api_secret, + enabled: enabled, } api_headers = { @@ -1398,11 +1398,11 @@ def update_vonage_provider(provider_id:, name: nil, enabled: nil, api_key: nil, end api_params = { - name: name, - enabled: enabled, - apiKey: api_key, - apiSecret: api_secret, - from: from, + name: name, + enabled: enabled, + apiKey: api_key, + apiSecret: api_secret, + from: from, } api_headers = { @@ -1494,7 +1494,7 @@ def list_provider_logs(provider_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -1526,7 +1526,7 @@ def list_subscriber_logs(subscriber_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -1553,8 +1553,8 @@ def list_topics(queries: nil, search: nil) api_path = '/messaging/topics' api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -1590,9 +1590,9 @@ def create_topic(topic_id:, name:, subscribe: nil) end api_params = { - topicId: topic_id, - name: name, - subscribe: subscribe, + topicId: topic_id, + name: name, + subscribe: subscribe, } api_headers = { @@ -1657,8 +1657,8 @@ def update_topic(topic_id:, name: nil, subscribe: nil) end api_params = { - name: name, - subscribe: subscribe, + name: name, + subscribe: subscribe, } api_headers = { @@ -1719,7 +1719,7 @@ def list_topic_logs(topic_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -1752,8 +1752,8 @@ def list_subscribers(topic_id:, queries: nil, search: nil) end api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -1794,8 +1794,8 @@ def create_subscriber(topic_id:, subscriber_id:, target_id:) end api_params = { - subscriberId: subscriber_id, - targetId: target_id, + subscriberId: subscriber_id, + targetId: target_id, } api_headers = { diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index 9fd8add..d81a882 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -18,8 +18,8 @@ def list_buckets(queries: nil, search: nil) api_path = '/storage/buckets' api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -62,16 +62,16 @@ def create_bucket(bucket_id:, name:, permissions: nil, file_security: nil, enabl end api_params = { - bucketId: bucket_id, - name: name, - permissions: permissions, - fileSecurity: file_security, - enabled: enabled, - maximumFileSize: maximum_file_size, - allowedFileExtensions: allowed_file_extensions, - compression: compression, - encryption: encryption, - antivirus: antivirus, + bucketId: bucket_id, + name: name, + permissions: permissions, + fileSecurity: file_security, + enabled: enabled, + maximumFileSize: maximum_file_size, + allowedFileExtensions: allowed_file_extensions, + compression: compression, + encryption: encryption, + antivirus: antivirus, } api_headers = { @@ -146,15 +146,15 @@ def update_bucket(bucket_id:, name:, permissions: nil, file_security: nil, enabl end api_params = { - name: name, - permissions: permissions, - fileSecurity: file_security, - enabled: enabled, - maximumFileSize: maximum_file_size, - allowedFileExtensions: allowed_file_extensions, - compression: compression, - encryption: encryption, - antivirus: antivirus, + name: name, + permissions: permissions, + fileSecurity: file_security, + enabled: enabled, + maximumFileSize: maximum_file_size, + allowedFileExtensions: allowed_file_extensions, + compression: compression, + encryption: encryption, + antivirus: antivirus, } api_headers = { @@ -217,8 +217,8 @@ def list_files(bucket_id:, queries: nil, search: nil) end api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -256,7 +256,7 @@ def list_files(bucket_id:, queries: nil, search: nil) # # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). # @param [String] file_id File 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 [file] file Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). + # @param [Payload] file Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). # @param [Array] permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). # # @return [File] @@ -277,9 +277,9 @@ def create_file(bucket_id:, file_id:, file:, permissions: nil, on_progress: nil) end api_params = { - fileId: file_id, - file: file, - permissions: permissions, + fileId: file_id, + file: file, + permissions: permissions, } api_headers = { @@ -361,8 +361,8 @@ def update_file(bucket_id:, file_id:, name: nil, permissions: nil) end api_params = { - name: name, - permissions: permissions, + name: name, + permissions: permissions, } api_headers = { @@ -487,17 +487,17 @@ def get_file_preview(bucket_id:, file_id:, width: nil, height: nil, gravity: nil end api_params = { - width: width, - height: height, - gravity: gravity, - quality: quality, - borderWidth: border_width, - borderColor: border_color, - borderRadius: border_radius, - opacity: opacity, - rotation: rotation, - background: background, - output: output, + width: width, + height: height, + gravity: gravity, + quality: quality, + borderWidth: border_width, + borderColor: border_color, + borderRadius: border_radius, + opacity: opacity, + rotation: rotation, + background: background, + output: output, } api_headers = { diff --git a/lib/appwrite/services/teams.rb b/lib/appwrite/services/teams.rb index 235a11a..ea6bebd 100644 --- a/lib/appwrite/services/teams.rb +++ b/lib/appwrite/services/teams.rb @@ -18,8 +18,8 @@ def list(queries: nil, search: nil) api_path = '/teams' api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -57,9 +57,9 @@ def create(team_id:, name:, roles: nil) end api_params = { - teamId: team_id, - name: name, - roles: roles, + teamId: team_id, + name: name, + roles: roles, } api_headers = { @@ -125,7 +125,7 @@ def update_name(team_id:, name:) end api_params = { - name: name, + name: name, } api_headers = { @@ -189,8 +189,8 @@ def list_memberships(team_id:, queries: nil, search: nil) end api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -251,12 +251,12 @@ def create_membership(team_id:, roles:, email: nil, user_id: nil, phone: nil, ur end api_params = { - email: email, - userId: user_id, - phone: phone, - roles: roles, - url: url, - name: name, + email: email, + userId: user_id, + phone: phone, + roles: roles, + url: url, + name: name, } api_headers = { @@ -338,7 +338,7 @@ def update_membership(team_id:, membership_id:, roles:) end api_params = { - roles: roles, + roles: roles, } api_headers = { @@ -428,8 +428,8 @@ def update_membership_status(team_id:, membership_id:, user_id:, secret:) end api_params = { - userId: user_id, - secret: secret, + userId: user_id, + secret: secret, } api_headers = { @@ -499,7 +499,7 @@ def update_prefs(team_id:, prefs:) end api_params = { - prefs: prefs, + prefs: prefs, } api_headers = { diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index af5d429..f3b8039 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -18,8 +18,8 @@ def list(queries: nil, search: nil) api_path = '/users' api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -53,11 +53,11 @@ def create(user_id:, email: nil, phone: nil, password: nil, name: nil) end api_params = { - userId: user_id, - email: email, - phone: phone, - password: password, - name: name, + userId: user_id, + email: email, + phone: phone, + password: password, + name: name, } api_headers = { @@ -101,10 +101,10 @@ def create_argon2_user(user_id:, email:, password:, name: nil) end api_params = { - userId: user_id, - email: email, - password: password, - name: name, + userId: user_id, + email: email, + password: password, + name: name, } api_headers = { @@ -148,10 +148,10 @@ def create_bcrypt_user(user_id:, email:, password:, name: nil) end api_params = { - userId: user_id, - email: email, - password: password, - name: name, + userId: user_id, + email: email, + password: password, + name: name, } api_headers = { @@ -178,8 +178,8 @@ def list_identities(queries: nil, search: nil) api_path = '/users/identities' api_params = { - queries: queries, - search: search, + queries: queries, + search: search, } api_headers = { @@ -252,10 +252,10 @@ def create_md5_user(user_id:, email:, password:, name: nil) end api_params = { - userId: user_id, - email: email, - password: password, - name: name, + userId: user_id, + email: email, + password: password, + name: name, } api_headers = { @@ -299,10 +299,10 @@ def create_ph_pass_user(user_id:, email:, password:, name: nil) end api_params = { - userId: user_id, - email: email, - password: password, - name: name, + userId: user_id, + email: email, + password: password, + name: name, } api_headers = { @@ -371,15 +371,15 @@ def create_scrypt_user(user_id:, email:, password:, password_salt:, password_cpu end api_params = { - userId: user_id, - email: email, - password: password, - passwordSalt: password_salt, - passwordCpu: password_cpu, - passwordMemory: password_memory, - passwordParallel: password_parallel, - passwordLength: password_length, - name: name, + userId: user_id, + email: email, + password: password, + passwordSalt: password_salt, + passwordCpu: password_cpu, + passwordMemory: password_memory, + passwordParallel: password_parallel, + passwordLength: password_length, + name: name, } api_headers = { @@ -439,13 +439,13 @@ def create_scrypt_modified_user(user_id:, email:, password:, password_salt:, pas end api_params = { - userId: user_id, - email: email, - password: password, - passwordSalt: password_salt, - passwordSaltSeparator: password_salt_separator, - passwordSignerKey: password_signer_key, - name: name, + userId: user_id, + email: email, + password: password, + passwordSalt: password_salt, + passwordSaltSeparator: password_salt_separator, + passwordSignerKey: password_signer_key, + name: name, } api_headers = { @@ -490,11 +490,11 @@ def create_sha_user(user_id:, email:, password:, password_version: nil, name: ni end api_params = { - userId: user_id, - email: email, - password: password, - passwordVersion: password_version, - name: name, + userId: user_id, + email: email, + password: password, + passwordVersion: password_version, + name: name, } api_headers = { @@ -594,7 +594,7 @@ def update_email(user_id:, email:) end api_params = { - email: email, + email: email, } api_headers = { @@ -629,8 +629,8 @@ def create_jwt(user_id:, session_id: nil, duration: nil) end api_params = { - sessionId: session_id, - duration: duration, + sessionId: session_id, + duration: duration, } api_headers = { @@ -671,7 +671,7 @@ def update_labels(user_id:, labels:) end api_params = { - labels: labels, + labels: labels, } api_headers = { @@ -703,7 +703,7 @@ def list_logs(user_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -769,7 +769,7 @@ def update_mfa(user_id:, mfa:) end api_params = { - mfa: mfa, + mfa: mfa, } api_headers = { @@ -970,7 +970,7 @@ def update_name(user_id:, name:) end api_params = { - name: name, + name: name, } api_headers = { @@ -1006,7 +1006,7 @@ def update_password(user_id:, password:) end api_params = { - password: password, + password: password, } api_headers = { @@ -1042,7 +1042,7 @@ def update_phone(user_id:, number:) end api_params = { - number: number, + number: number, } api_headers = { @@ -1110,7 +1110,7 @@ def update_prefs(user_id:, prefs:) end api_params = { - prefs: prefs, + prefs: prefs, } api_headers = { @@ -1276,7 +1276,7 @@ def update_status(user_id:, status:) end api_params = { - status: status, + status: status, } api_headers = { @@ -1308,7 +1308,7 @@ def list_targets(user_id:, queries: nil) end api_params = { - queries: queries, + queries: queries, } api_headers = { @@ -1356,11 +1356,11 @@ def create_target(user_id:, target_id:, provider_type:, identifier:, provider_id end api_params = { - targetId: target_id, - providerType: provider_type, - identifier: identifier, - providerId: provider_id, - name: name, + targetId: target_id, + providerType: provider_type, + identifier: identifier, + providerId: provider_id, + name: name, } api_headers = { @@ -1436,9 +1436,9 @@ def update_target(user_id:, target_id:, identifier: nil, provider_id: nil, name: end api_params = { - identifier: identifier, - providerId: provider_id, - name: name, + identifier: identifier, + providerId: provider_id, + name: name, } api_headers = { @@ -1510,8 +1510,8 @@ def create_token(user_id:, length: nil, expire: nil) end api_params = { - length: length, - expire: expire, + length: length, + expire: expire, } api_headers = { @@ -1547,7 +1547,7 @@ def update_email_verification(user_id:, email_verification:) end api_params = { - emailVerification: email_verification, + emailVerification: email_verification, } api_headers = { @@ -1583,7 +1583,7 @@ def update_phone_verification(user_id:, phone_verification:) end api_params = { - phoneVerification: phone_verification, + phoneVerification: phone_verification, } api_headers = {