diff --git a/appwrite.gemspec b/appwrite.gemspec index 4654522..63d6aa4 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'appwrite' - s.version = '2.1.1' + s.version = '2.1.2' s.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" s.author = 'Appwrite Team' s.homepage = 'https://appwrite.io/support' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index 4b7e8f3..88109b2 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -20,7 +20,7 @@ def initialize() @headers = { 'content-type' => '', 'user-agent' => RUBY_PLATFORM + ':ruby-' + RUBY_VERSION, - 'x-sdk-version' => 'appwrite:ruby:2.1.1', + 'x-sdk-version' => 'appwrite:ruby:2.1.2', 'X-Appwrite-Response-Format' => '0.8.0' } @endpoint = 'https://appwrite.io/v1'; diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index bc4ee79..bf3cf02 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -4,8 +4,7 @@ class Account < Service def get() path = '/account' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -15,8 +14,7 @@ def get() def delete() path = '/account' - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', @@ -24,12 +22,25 @@ def delete() end def update_email(email:, password:) + if email.nil? + raise Appwrite::Exception.new('Missing required parameter: "email"') + end + + if password.nil? + raise Appwrite::Exception.new('Missing required parameter: "password"') + end + path = '/account/email' - params = { - 'email': email, - 'password': password - } + params = {} + + if !email.nil? + params[:email] = email + end + + if !password.nil? + params[:password] = password + end return @client.call('patch', path, { 'content-type' => 'application/json', @@ -39,8 +50,7 @@ def update_email(email:, password:) def get_logs() path = '/account/logs' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -48,24 +58,39 @@ def get_logs() end def update_name(name:) + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + path = '/account/name' - params = { - 'name': name - } + params = {} + + if !name.nil? + params[:name] = name + end return @client.call('patch', path, { 'content-type' => 'application/json', }, params); end - def update_password(password:, old_password: '') + def update_password(password:, old_password: nil) + if password.nil? + raise Appwrite::Exception.new('Missing required parameter: "password"') + end + path = '/account/password' - params = { - 'password': password, - 'oldPassword': old_password - } + params = {} + + if !password.nil? + params[:password] = password + end + + if !old_password.nil? + params[:oldPassword] = old_password + end return @client.call('patch', path, { 'content-type' => 'application/json', @@ -75,8 +100,7 @@ def update_password(password:, old_password: '') def get_prefs() path = '/account/prefs' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -84,11 +108,17 @@ def get_prefs() end def update_prefs(prefs:) + if prefs.nil? + raise Appwrite::Exception.new('Missing required parameter: "prefs"') + end + path = '/account/prefs' - params = { - 'prefs': prefs - } + params = {} + + if !prefs.nil? + params[:prefs] = prefs + end return @client.call('patch', path, { 'content-type' => 'application/json', @@ -96,12 +126,25 @@ def update_prefs(prefs:) end def create_recovery(email:, url:) + if email.nil? + raise Appwrite::Exception.new('Missing required parameter: "email"') + end + + if url.nil? + raise Appwrite::Exception.new('Missing required parameter: "url"') + end + path = '/account/recovery' - params = { - 'email': email, - 'url': url - } + params = {} + + if !email.nil? + params[:email] = email + end + + if !url.nil? + params[:url] = url + end return @client.call('post', path, { 'content-type' => 'application/json', @@ -109,14 +152,41 @@ def create_recovery(email:, url:) end def update_recovery(user_id:, secret:, password:, password_again:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if secret.nil? + raise Appwrite::Exception.new('Missing required parameter: "secret"') + end + + if password.nil? + raise Appwrite::Exception.new('Missing required parameter: "password"') + end + + if password_again.nil? + raise Appwrite::Exception.new('Missing required parameter: "passwordAgain"') + end + path = '/account/recovery' - params = { - 'userId': user_id, - 'secret': secret, - 'password': password, - 'passwordAgain': password_again - } + params = {} + + if !user_id.nil? + params[:userId] = user_id + end + + if !secret.nil? + params[:secret] = secret + end + + if !password.nil? + params[:password] = password + end + + if !password_again.nil? + params[:passwordAgain] = password_again + end return @client.call('put', path, { 'content-type' => 'application/json', @@ -126,8 +196,7 @@ def update_recovery(user_id:, secret:, password:, password_again:) def get_sessions() path = '/account/sessions' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -137,8 +206,7 @@ def get_sessions() def delete_sessions() path = '/account/sessions' - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', @@ -146,11 +214,14 @@ def delete_sessions() end def delete_session(session_id:) + if session_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "sessionId"') + end + path = '/account/sessions/{sessionId}' .gsub('{sessionId}', session_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', @@ -158,11 +229,17 @@ def delete_session(session_id:) end def create_verification(url:) + if url.nil? + raise Appwrite::Exception.new('Missing required parameter: "url"') + end + path = '/account/verification' - params = { - 'url': url - } + params = {} + + if !url.nil? + params[:url] = url + end return @client.call('post', path, { 'content-type' => 'application/json', @@ -170,12 +247,25 @@ def create_verification(url:) end def update_verification(user_id:, secret:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if secret.nil? + raise Appwrite::Exception.new('Missing required parameter: "secret"') + end + path = '/account/verification' - params = { - 'userId': user_id, - 'secret': secret - } + params = {} + + if !user_id.nil? + params[:userId] = user_id + end + + if !secret.nil? + params[:secret] = secret + end return @client.call('put', path, { 'content-type' => 'application/json', diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index afc94c2..1dd6cdc 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -1,30 +1,54 @@ module Appwrite class Avatars < Service - def get_browser(code:, width: 100, height: 100, quality: 100) + def get_browser(code:, width: nil, height: nil, quality: nil) + if code.nil? + raise Appwrite::Exception.new('Missing required parameter: "code"') + end + path = '/avatars/browsers/{code}' .gsub('{code}', code) - params = { - 'width': width, - 'height': height, - 'quality': quality - } + params = {} + + if !width.nil? + params[:width] = width + end + + if !height.nil? + params[:height] = height + end + + if !quality.nil? + params[:quality] = quality + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def get_credit_card(code:, width: 100, height: 100, quality: 100) + def get_credit_card(code:, width: nil, height: nil, quality: nil) + if code.nil? + raise Appwrite::Exception.new('Missing required parameter: "code"') + end + path = '/avatars/credit-cards/{code}' .gsub('{code}', code) - params = { - 'width': width, - 'height': height, - 'quality': quality - } + params = {} + + if !width.nil? + params[:width] = width + end + + if !height.nil? + params[:height] = height + end + + if !quality.nil? + params[:quality] = quality + end return @client.call('get', path, { 'content-type' => 'application/json', @@ -32,71 +56,130 @@ def get_credit_card(code:, width: 100, height: 100, quality: 100) end def get_favicon(url:) + if url.nil? + raise Appwrite::Exception.new('Missing required parameter: "url"') + end + path = '/avatars/favicon' - params = { - 'url': url - } + params = {} + + if !url.nil? + params[:url] = url + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def get_flag(code:, width: 100, height: 100, quality: 100) + def get_flag(code:, width: nil, height: nil, quality: nil) + if code.nil? + raise Appwrite::Exception.new('Missing required parameter: "code"') + end + path = '/avatars/flags/{code}' .gsub('{code}', code) - params = { - 'width': width, - 'height': height, - 'quality': quality - } + params = {} + + if !width.nil? + params[:width] = width + end + + if !height.nil? + params[:height] = height + end + + if !quality.nil? + params[:quality] = quality + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def get_image(url:, width: 400, height: 400) + def get_image(url:, width: nil, height: nil) + if url.nil? + raise Appwrite::Exception.new('Missing required parameter: "url"') + end + path = '/avatars/image' - params = { - 'url': url, - 'width': width, - 'height': height - } + params = {} + + if !url.nil? + params[:url] = url + end + + if !width.nil? + params[:width] = width + end + + if !height.nil? + params[:height] = height + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def get_initials(name: '', width: 500, height: 500, color: '', background: '') + def get_initials(name: nil, width: nil, height: nil, color: nil, background: nil) path = '/avatars/initials' - params = { - 'name': name, - 'width': width, - 'height': height, - 'color': color, - 'background': background - } + params = {} + + if !name.nil? + params[:name] = name + end + + if !width.nil? + params[:width] = width + end + + if !height.nil? + params[:height] = height + end + + if !color.nil? + params[:color] = color + end + + if !background.nil? + params[:background] = background + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def get_q_r(text:, size: 400, margin: 1, download: false) + def get_q_r(text:, size: nil, margin: nil, download: nil) + if text.nil? + raise Appwrite::Exception.new('Missing required parameter: "text"') + end + path = '/avatars/qr' - params = { - 'text': text, - 'size': size, - 'margin': margin, - 'download': download - } + params = {} + + if !text.nil? + params[:text] = text + end + + if !size.nil? + params[:size] = size + end + + if !margin.nil? + params[:margin] = margin + end + + if !download.nil? + params[:download] = download + end return @client.call('get', path, { 'content-type' => 'application/json', diff --git a/lib/appwrite/services/database.rb b/lib/appwrite/services/database.rb index 166a8b5..1030af9 100644 --- a/lib/appwrite/services/database.rb +++ b/lib/appwrite/services/database.rb @@ -1,15 +1,26 @@ module Appwrite class Database < Service - def list_collections(search: '', limit: 25, offset: 0, order_type: 'ASC') + def list_collections(search: nil, limit: nil, offset: nil, order_type: nil) path = '/database/collections' - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } + params = {} + + if !search.nil? + params[:search] = search + end + + if !limit.nil? + params[:limit] = limit + end + + if !offset.nil? + params[:offset] = offset + end + + if !order_type.nil? + params[:orderType] = order_type + end return @client.call('get', path, { 'content-type' => 'application/json', @@ -17,14 +28,41 @@ def list_collections(search: '', limit: 25, offset: 0, order_type: 'ASC') end def create_collection(name:, read:, write:, rules:) + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if read.nil? + raise Appwrite::Exception.new('Missing required parameter: "read"') + end + + if write.nil? + raise Appwrite::Exception.new('Missing required parameter: "write"') + end + + if rules.nil? + raise Appwrite::Exception.new('Missing required parameter: "rules"') + end + path = '/database/collections' - params = { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules - } + params = {} + + if !name.nil? + params[:name] = name + end + + if !read.nil? + params[:read] = read + end + + if !write.nil? + params[:write] = write + end + + if !rules.nil? + params[:rules] = rules + end return @client.call('post', path, { 'content-type' => 'application/json', @@ -32,27 +70,49 @@ def create_collection(name:, read:, write:, rules:) end def get_collection(collection_id:) + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + path = '/database/collections/{collectionId}' .gsub('{collectionId}', collection_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def update_collection(collection_id:, name:, read: [], write: [], rules: []) + def update_collection(collection_id:, name:, read: nil, write: nil, rules: nil) + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + path = '/database/collections/{collectionId}' .gsub('{collectionId}', collection_id) - params = { - 'name': name, - 'read': read, - 'write': write, - 'rules': rules - } + params = {} + + if !name.nil? + params[:name] = name + end + + if !read.nil? + params[:read] = read + end + + if !write.nil? + params[:write] = write + end + + if !rules.nil? + params[:rules] = rules + end return @client.call('put', path, { 'content-type' => 'application/json', @@ -60,48 +120,100 @@ def update_collection(collection_id:, name:, read: [], write: [], rules: []) end def delete_collection(collection_id:) + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + path = '/database/collections/{collectionId}' .gsub('{collectionId}', collection_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', }, params); end - def list_documents(collection_id:, filters: [], limit: 25, offset: 0, order_field: '', order_type: 'ASC', order_cast: 'string', search: '') + def list_documents(collection_id:, filters: nil, limit: nil, offset: nil, order_field: nil, order_type: nil, order_cast: nil, search: nil) + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + path = '/database/collections/{collectionId}/documents' .gsub('{collectionId}', collection_id) - params = { - 'filters': filters, - 'limit': limit, - 'offset': offset, - 'orderField': order_field, - 'orderType': order_type, - 'orderCast': order_cast, - 'search': search - } + params = {} + + if !filters.nil? + params[:filters] = filters + end + + if !limit.nil? + params[:limit] = limit + end + + if !offset.nil? + params[:offset] = offset + end + + if !order_field.nil? + params[:orderField] = order_field + end + + if !order_type.nil? + params[:orderType] = order_type + end + + if !order_cast.nil? + params[:orderCast] = order_cast + end + + if !search.nil? + params[:search] = search + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def create_document(collection_id:, data:, read: [], write: [], parent_document: '', parent_property: '', parent_property_type: 'assign') + def create_document(collection_id:, data:, read: nil, write: nil, parent_document: nil, parent_property: nil, parent_property_type: nil) + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if data.nil? + raise Appwrite::Exception.new('Missing required parameter: "data"') + end + path = '/database/collections/{collectionId}/documents' .gsub('{collectionId}', collection_id) - params = { - 'data': data, - 'read': read, - 'write': write, - 'parentDocument': parent_document, - 'parentProperty': parent_property, - 'parentPropertyType': parent_property_type - } + params = {} + + if !data.nil? + params[:data] = data + end + + if !read.nil? + params[:read] = read + end + + if !write.nil? + params[:write] = write + end + + if !parent_document.nil? + params[:parentDocument] = parent_document + end + + if !parent_property.nil? + params[:parentProperty] = parent_property + end + + if !parent_property_type.nil? + params[:parentPropertyType] = parent_property_type + end return @client.call('post', path, { 'content-type' => 'application/json', @@ -109,28 +221,55 @@ def create_document(collection_id:, data:, read: [], write: [], parent_document: end def get_document(collection_id:, document_id:) + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if document_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "documentId"') + end + path = '/database/collections/{collectionId}/documents/{documentId}' .gsub('{collectionId}', collection_id) .gsub('{documentId}', document_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def update_document(collection_id:, document_id:, data:, read: [], write: []) + def update_document(collection_id:, document_id:, data:, read: nil, write: nil) + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if document_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "documentId"') + end + + if data.nil? + raise Appwrite::Exception.new('Missing required parameter: "data"') + end + path = '/database/collections/{collectionId}/documents/{documentId}' .gsub('{collectionId}', collection_id) .gsub('{documentId}', document_id) - params = { - 'data': data, - 'read': read, - 'write': write - } + params = {} + + if !data.nil? + params[:data] = data + end + + if !read.nil? + params[:read] = read + end + + if !write.nil? + params[:write] = write + end return @client.call('patch', path, { 'content-type' => 'application/json', @@ -138,12 +277,19 @@ def update_document(collection_id:, document_id:, data:, read: [], write: []) end def delete_document(collection_id:, document_id:) + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if document_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "documentId"') + end + path = '/database/collections/{collectionId}/documents/{documentId}' .gsub('{collectionId}', collection_id) .gsub('{documentId}', document_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index a942622..349c4c0 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -1,33 +1,76 @@ module Appwrite class Functions < Service - def list(search: '', limit: 25, offset: 0, order_type: 'ASC') + def list(search: nil, limit: nil, offset: nil, order_type: nil) path = '/functions' - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } + params = {} + + if !search.nil? + params[:search] = search + end + + if !limit.nil? + params[:limit] = limit + end + + if !offset.nil? + params[:offset] = offset + end + + if !order_type.nil? + params[:orderType] = order_type + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def create(name:, execute:, env:, vars: {}, events: [], schedule: '', timeout: 15) + def create(name:, execute:, env:, vars: nil, events: nil, schedule: nil, timeout: nil) + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if execute.nil? + raise Appwrite::Exception.new('Missing required parameter: "execute"') + end + + if env.nil? + raise Appwrite::Exception.new('Missing required parameter: "env"') + end + path = '/functions' - params = { - 'name': name, - 'execute': execute, - 'env': env, - 'vars': vars, - 'events': events, - 'schedule': schedule, - 'timeout': timeout - } + params = {} + + if !name.nil? + params[:name] = name + end + + if !execute.nil? + params[:execute] = execute + end + + if !env.nil? + params[:env] = env + end + + if !vars.nil? + params[:vars] = vars + end + + if !events.nil? + params[:events] = events + end + + if !schedule.nil? + params[:schedule] = schedule + end + + if !timeout.nil? + params[:timeout] = timeout + end return @client.call('post', path, { 'content-type' => 'application/json', @@ -35,29 +78,61 @@ def create(name:, execute:, env:, vars: {}, events: [], schedule: '', timeout: 1 end def get(function_id:) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + path = '/functions/{functionId}' .gsub('{functionId}', function_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def update(function_id:, name:, execute:, vars: {}, events: [], schedule: '', timeout: 15) + def update(function_id:, name:, execute:, vars: nil, events: nil, schedule: nil, timeout: nil) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if execute.nil? + raise Appwrite::Exception.new('Missing required parameter: "execute"') + end + path = '/functions/{functionId}' .gsub('{functionId}', function_id) - params = { - 'name': name, - 'execute': execute, - 'vars': vars, - 'events': events, - 'schedule': schedule, - 'timeout': timeout - } + params = {} + + if !name.nil? + params[:name] = name + end + + if !execute.nil? + params[:execute] = execute + end + + if !vars.nil? + params[:vars] = vars + end + + if !events.nil? + params[:events] = events + end + + if !schedule.nil? + params[:schedule] = schedule + end + + if !timeout.nil? + params[:timeout] = timeout + end return @client.call('put', path, { 'content-type' => 'application/json', @@ -65,40 +140,64 @@ def update(function_id:, name:, execute:, vars: {}, events: [], schedule: '', ti end def delete(function_id:) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + path = '/functions/{functionId}' .gsub('{functionId}', function_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', }, params); end - def list_executions(function_id:, search: '', limit: 25, offset: 0, order_type: 'ASC') + def list_executions(function_id:, search: nil, limit: nil, offset: nil, order_type: nil) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + path = '/functions/{functionId}/executions' .gsub('{functionId}', function_id) - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } + params = {} + + if !search.nil? + params[:search] = search + end + + if !limit.nil? + params[:limit] = limit + end + + if !offset.nil? + params[:offset] = offset + end + + if !order_type.nil? + params[:orderType] = order_type + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def create_execution(function_id:, data: '') + def create_execution(function_id:, data: nil) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + path = '/functions/{functionId}/executions' .gsub('{functionId}', function_id) - params = { - 'data': data - } + params = {} + + if !data.nil? + params[:data] = data + end return @client.call('post', path, { 'content-type' => 'application/json', @@ -106,12 +205,19 @@ def create_execution(function_id:, data: '') end def get_execution(function_id:, execution_id:) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + + if execution_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "executionId"') + end + path = '/functions/{functionId}/executions/{executionId}' .gsub('{functionId}', function_id) .gsub('{executionId}', execution_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -119,28 +225,53 @@ def get_execution(function_id:, execution_id:) end def update_tag(function_id:, tag:) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + + if tag.nil? + raise Appwrite::Exception.new('Missing required parameter: "tag"') + end + path = '/functions/{functionId}/tag' .gsub('{functionId}', function_id) - params = { - 'tag': tag - } + params = {} + + if !tag.nil? + params[:tag] = tag + end return @client.call('patch', path, { 'content-type' => 'application/json', }, params); end - def list_tags(function_id:, search: '', limit: 25, offset: 0, order_type: 'ASC') + def list_tags(function_id:, search: nil, limit: nil, offset: nil, order_type: nil) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + path = '/functions/{functionId}/tags' .gsub('{functionId}', function_id) - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } + params = {} + + if !search.nil? + params[:search] = search + end + + if !limit.nil? + params[:limit] = limit + end + + if !offset.nil? + params[:offset] = offset + end + + if !order_type.nil? + params[:orderType] = order_type + end return @client.call('get', path, { 'content-type' => 'application/json', @@ -148,13 +279,30 @@ def list_tags(function_id:, search: '', limit: 25, offset: 0, order_type: 'ASC') end def create_tag(function_id:, command:, code:) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + + if command.nil? + raise Appwrite::Exception.new('Missing required parameter: "command"') + end + + if code.nil? + raise Appwrite::Exception.new('Missing required parameter: "code"') + end + path = '/functions/{functionId}/tags' .gsub('{functionId}', function_id) - params = { - 'command': command, - 'code': code - } + params = {} + + if !command.nil? + params[:command] = command + end + + if !code.nil? + params[:code] = code + end return @client.call('post', path, { 'content-type' => 'multipart/form-data', @@ -162,12 +310,19 @@ def create_tag(function_id:, command:, code:) end def get_tag(function_id:, tag_id:) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + + if tag_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tagId"') + end + path = '/functions/{functionId}/tags/{tagId}' .gsub('{functionId}', function_id) .gsub('{tagId}', tag_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -175,12 +330,19 @@ def get_tag(function_id:, tag_id:) end def delete_tag(function_id:, tag_id:) + if function_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "functionId"') + end + + if tag_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tagId"') + end + path = '/functions/{functionId}/tags/{tagId}' .gsub('{functionId}', function_id) .gsub('{tagId}', tag_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', diff --git a/lib/appwrite/services/health.rb b/lib/appwrite/services/health.rb index d2c6bc7..09438b1 100644 --- a/lib/appwrite/services/health.rb +++ b/lib/appwrite/services/health.rb @@ -4,8 +4,7 @@ class Health < Service def get() path = '/health' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -15,8 +14,7 @@ def get() def get_anti_virus() path = '/health/anti-virus' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -26,8 +24,7 @@ def get_anti_virus() def get_cache() path = '/health/cache' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -37,8 +34,7 @@ def get_cache() def get_d_b() path = '/health/db' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -48,8 +44,7 @@ def get_d_b() def get_queue_certificates() path = '/health/queue/certificates' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -59,8 +54,7 @@ def get_queue_certificates() def get_queue_functions() path = '/health/queue/functions' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -70,8 +64,7 @@ def get_queue_functions() def get_queue_logs() path = '/health/queue/logs' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -81,8 +74,7 @@ def get_queue_logs() def get_queue_tasks() path = '/health/queue/tasks' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -92,8 +84,7 @@ def get_queue_tasks() def get_queue_usage() path = '/health/queue/usage' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -103,8 +94,7 @@ def get_queue_usage() def get_queue_webhooks() path = '/health/queue/webhooks' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -114,8 +104,7 @@ def get_queue_webhooks() def get_storage_local() path = '/health/storage/local' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -125,8 +114,7 @@ def get_storage_local() def get_time() path = '/health/time' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', diff --git a/lib/appwrite/services/locale.rb b/lib/appwrite/services/locale.rb index e71756b..e6aa736 100644 --- a/lib/appwrite/services/locale.rb +++ b/lib/appwrite/services/locale.rb @@ -4,8 +4,7 @@ class Locale < Service def get() path = '/locale' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -15,8 +14,7 @@ def get() def get_continents() path = '/locale/continents' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -26,8 +24,7 @@ def get_continents() def get_countries() path = '/locale/countries' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -37,8 +34,7 @@ def get_countries() def get_countries_e_u() path = '/locale/countries/eu' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -48,8 +44,7 @@ def get_countries_e_u() def get_countries_phones() path = '/locale/countries/phones' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -59,8 +54,7 @@ def get_countries_phones() def get_currencies() path = '/locale/currencies' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -70,8 +64,7 @@ def get_currencies() def get_languages() path = '/locale/languages' - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index e5a3b0f..64352ab 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -1,29 +1,52 @@ module Appwrite class Storage < Service - def list_files(search: '', limit: 25, offset: 0, order_type: 'ASC') + def list_files(search: nil, limit: nil, offset: nil, order_type: nil) path = '/storage/files' - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } + params = {} + + if !search.nil? + params[:search] = search + end + + if !limit.nil? + params[:limit] = limit + end + + if !offset.nil? + params[:offset] = offset + end + + if !order_type.nil? + params[:orderType] = order_type + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def create_file(file:, read: [], write: []) + def create_file(file:, read: nil, write: nil) + if file.nil? + raise Appwrite::Exception.new('Missing required parameter: "file"') + end + path = '/storage/files' - params = { - 'file': file, - 'read': read, - 'write': write - } + params = {} + + if !file.nil? + params[:file] = file + end + + if !read.nil? + params[:read] = read + end + + if !write.nil? + params[:write] = write + end return @client.call('post', path, { 'content-type' => 'multipart/form-data', @@ -31,11 +54,14 @@ def create_file(file:, read: [], write: []) end def get_file(file_id:) + if file_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "fileId"') + end + path = '/storage/files/{fileId}' .gsub('{fileId}', file_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -43,13 +69,30 @@ def get_file(file_id:) end def update_file(file_id:, read:, write:) + if file_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "fileId"') + end + + if read.nil? + raise Appwrite::Exception.new('Missing required parameter: "read"') + end + + if write.nil? + raise Appwrite::Exception.new('Missing required parameter: "write"') + end + path = '/storage/files/{fileId}' .gsub('{fileId}', file_id) - params = { - 'read': read, - 'write': write - } + params = {} + + if !read.nil? + params[:read] = read + end + + if !write.nil? + params[:write] = write + end return @client.call('put', path, { 'content-type' => 'application/json', @@ -57,11 +100,14 @@ def update_file(file_id:, read:, write:) end def delete_file(file_id:) + if file_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "fileId"') + end + path = '/storage/files/{fileId}' .gsub('{fileId}', file_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', @@ -69,33 +115,69 @@ def delete_file(file_id:) end def get_file_download(file_id:) + if file_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "fileId"') + end + path = '/storage/files/{fileId}/download' .gsub('{fileId}', file_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def get_file_preview(file_id:, width: 0, height: 0, quality: 100, border_width: 0, border_color: '', border_radius: 0, opacity: 1, rotation: 0, background: '', output: '') + def get_file_preview(file_id:, width: nil, height: nil, quality: nil, border_width: nil, border_color: nil, border_radius: nil, opacity: nil, rotation: nil, background: nil, output: nil) + if file_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "fileId"') + end + path = '/storage/files/{fileId}/preview' .gsub('{fileId}', file_id) - params = { - 'width': width, - 'height': height, - 'quality': quality, - 'borderWidth': border_width, - 'borderColor': border_color, - 'borderRadius': border_radius, - 'opacity': opacity, - 'rotation': rotation, - 'background': background, - 'output': output - } + params = {} + + if !width.nil? + params[:width] = width + end + + if !height.nil? + params[:height] = height + end + + if !quality.nil? + params[:quality] = quality + end + + if !border_width.nil? + params[:borderWidth] = border_width + end + + if !border_color.nil? + params[:borderColor] = border_color + end + + if !border_radius.nil? + params[:borderRadius] = border_radius + end + + if !opacity.nil? + params[:opacity] = opacity + end + + if !rotation.nil? + params[:rotation] = rotation + end + + if !background.nil? + params[:background] = background + end + + if !output.nil? + params[:output] = output + end return @client.call('get', path, { 'content-type' => 'application/json', @@ -103,11 +185,14 @@ def get_file_preview(file_id:, width: 0, height: 0, quality: 100, border_width: end def get_file_view(file_id:) + if file_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "fileId"') + end + path = '/storage/files/{fileId}/view' .gsub('{fileId}', file_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', diff --git a/lib/appwrite/services/teams.rb b/lib/appwrite/services/teams.rb index 2a14be9..53e8aec 100644 --- a/lib/appwrite/services/teams.rb +++ b/lib/appwrite/services/teams.rb @@ -1,28 +1,48 @@ module Appwrite class Teams < Service - def list(search: '', limit: 25, offset: 0, order_type: 'ASC') + def list(search: nil, limit: nil, offset: nil, order_type: nil) path = '/teams' - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } + params = {} + + if !search.nil? + params[:search] = search + end + + if !limit.nil? + params[:limit] = limit + end + + if !offset.nil? + params[:offset] = offset + end + + if !order_type.nil? + params[:orderType] = order_type + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def create(name:, roles: ["owner"]) + def create(name:, roles: nil) + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + path = '/teams' - params = { - 'name': name, - 'roles': roles - } + params = {} + + if !name.nil? + params[:name] = name + end + + if !roles.nil? + params[:roles] = roles + end return @client.call('post', path, { 'content-type' => 'application/json', @@ -30,11 +50,14 @@ def create(name:, roles: ["owner"]) end def get(team_id:) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + path = '/teams/{teamId}' .gsub('{teamId}', team_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -42,12 +65,22 @@ def get(team_id:) end def update(team_id:, name:) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + path = '/teams/{teamId}' .gsub('{teamId}', team_id) - params = { - 'name': name - } + params = {} + + if !name.nil? + params[:name] = name + end return @client.call('put', path, { 'content-type' => 'application/json', @@ -55,43 +88,88 @@ def update(team_id:, name:) end def delete(team_id:) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + path = '/teams/{teamId}' .gsub('{teamId}', team_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', }, params); end - def get_memberships(team_id:, search: '', limit: 25, offset: 0, order_type: 'ASC') + def get_memberships(team_id:, search: nil, limit: nil, offset: nil, order_type: nil) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + path = '/teams/{teamId}/memberships' .gsub('{teamId}', team_id) - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } + params = {} + + if !search.nil? + params[:search] = search + end + + if !limit.nil? + params[:limit] = limit + end + + if !offset.nil? + params[:offset] = offset + end + + if !order_type.nil? + params[:orderType] = order_type + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def create_membership(team_id:, email:, roles:, url:, name: '') + def create_membership(team_id:, email:, roles:, url:, name: nil) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if email.nil? + raise Appwrite::Exception.new('Missing required parameter: "email"') + end + + if roles.nil? + raise Appwrite::Exception.new('Missing required parameter: "roles"') + end + + if url.nil? + raise Appwrite::Exception.new('Missing required parameter: "url"') + end + path = '/teams/{teamId}/memberships' .gsub('{teamId}', team_id) - params = { - 'email': email, - 'name': name, - 'roles': roles, - 'url': url - } + params = {} + + if !email.nil? + params[:email] = email + end + + if !name.nil? + params[:name] = name + end + + if !roles.nil? + params[:roles] = roles + end + + if !url.nil? + params[:url] = url + end return @client.call('post', path, { 'content-type' => 'application/json', @@ -99,13 +177,27 @@ def create_membership(team_id:, email:, roles:, url:, name: '') end def update_membership_roles(team_id:, membership_id:, roles:) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if membership_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "membershipId"') + end + + if roles.nil? + raise Appwrite::Exception.new('Missing required parameter: "roles"') + end + path = '/teams/{teamId}/memberships/{membershipId}' .gsub('{teamId}', team_id) .gsub('{membershipId}', membership_id) - params = { - 'roles': roles - } + params = {} + + if !roles.nil? + params[:roles] = roles + end return @client.call('patch', path, { 'content-type' => 'application/json', @@ -113,12 +205,19 @@ def update_membership_roles(team_id:, membership_id:, roles:) end def delete_membership(team_id:, membership_id:) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if membership_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "membershipId"') + end + path = '/teams/{teamId}/memberships/{membershipId}' .gsub('{teamId}', team_id) .gsub('{membershipId}', membership_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', @@ -126,14 +225,35 @@ def delete_membership(team_id:, membership_id:) end def update_membership_status(team_id:, membership_id:, user_id:, secret:) + if team_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "teamId"') + end + + if membership_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "membershipId"') + end + + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if secret.nil? + raise Appwrite::Exception.new('Missing required parameter: "secret"') + end + path = '/teams/{teamId}/memberships/{membershipId}/status' .gsub('{teamId}', team_id) .gsub('{membershipId}', membership_id) - params = { - 'userId': user_id, - 'secret': secret - } + params = {} + + if !user_id.nil? + params[:userId] = user_id + end + + if !secret.nil? + params[:secret] = secret + end return @client.call('patch', path, { 'content-type' => 'application/json', diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index a724e89..cd526c3 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -1,29 +1,56 @@ module Appwrite class Users < Service - def list(search: '', limit: 25, offset: 0, order_type: 'ASC') + def list(search: nil, limit: nil, offset: nil, order_type: nil) path = '/users' - params = { - 'search': search, - 'limit': limit, - 'offset': offset, - 'orderType': order_type - } + params = {} + + if !search.nil? + params[:search] = search + end + + if !limit.nil? + params[:limit] = limit + end + + if !offset.nil? + params[:offset] = offset + end + + if !order_type.nil? + params[:orderType] = order_type + end return @client.call('get', path, { 'content-type' => 'application/json', }, params); end - def create(email:, password:, name: '') + def create(email:, password:, name: nil) + if email.nil? + raise Appwrite::Exception.new('Missing required parameter: "email"') + end + + if password.nil? + raise Appwrite::Exception.new('Missing required parameter: "password"') + end + path = '/users' - params = { - 'email': email, - 'password': password, - 'name': name - } + params = {} + + if !email.nil? + params[:email] = email + end + + if !password.nil? + params[:password] = password + end + + if !name.nil? + params[:name] = name + end return @client.call('post', path, { 'content-type' => 'application/json', @@ -31,11 +58,14 @@ def create(email:, password:, name: '') end def get(user_id:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + path = '/users/{userId}' .gsub('{userId}', user_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -43,11 +73,14 @@ def get(user_id:) end def delete(user_id:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + path = '/users/{userId}' .gsub('{userId}', user_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', @@ -55,11 +88,14 @@ def delete(user_id:) end def get_logs(user_id:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + path = '/users/{userId}/logs' .gsub('{userId}', user_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -67,11 +103,14 @@ def get_logs(user_id:) end def get_prefs(user_id:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + path = '/users/{userId}/prefs' .gsub('{userId}', user_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -79,12 +118,22 @@ def get_prefs(user_id:) end def update_prefs(user_id:, prefs:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if prefs.nil? + raise Appwrite::Exception.new('Missing required parameter: "prefs"') + end + path = '/users/{userId}/prefs' .gsub('{userId}', user_id) - params = { - 'prefs': prefs - } + params = {} + + if !prefs.nil? + params[:prefs] = prefs + end return @client.call('patch', path, { 'content-type' => 'application/json', @@ -92,11 +141,14 @@ def update_prefs(user_id:, prefs:) end def get_sessions(user_id:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + path = '/users/{userId}/sessions' .gsub('{userId}', user_id) - params = { - } + params = {} return @client.call('get', path, { 'content-type' => 'application/json', @@ -104,11 +156,14 @@ def get_sessions(user_id:) end def delete_sessions(user_id:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + path = '/users/{userId}/sessions' .gsub('{userId}', user_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', @@ -116,12 +171,19 @@ def delete_sessions(user_id:) end def delete_session(user_id:, session_id:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if session_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "sessionId"') + end + path = '/users/{userId}/sessions/{sessionId}' .gsub('{userId}', user_id) .gsub('{sessionId}', session_id) - params = { - } + params = {} return @client.call('delete', path, { 'content-type' => 'application/json', @@ -129,12 +191,22 @@ def delete_session(user_id:, session_id:) end def update_status(user_id:, status:) + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if status.nil? + raise Appwrite::Exception.new('Missing required parameter: "status"') + end + path = '/users/{userId}/status' .gsub('{userId}', user_id) - params = { - 'status': status - } + params = {} + + if !status.nil? + params[:status] = status + end return @client.call('patch', path, { 'content-type' => 'application/json',