Skip to content

Commit

Permalink
add param checking and removed default values
Browse files Browse the repository at this point in the history
  • Loading branch information
TorstenDittmann committed Jun 2, 2021
1 parent 6fda7b4 commit a38e1ab
Show file tree
Hide file tree
Showing 11 changed files with 1,094 additions and 355 deletions.
2 changes: 1 addition & 1 deletion appwrite.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |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'
Expand Down
2 changes: 1 addition & 1 deletion lib/appwrite/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
182 changes: 136 additions & 46 deletions lib/appwrite/services/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class Account < Service
def get()
path = '/account'

params = {
}
params = {}

return @client.call('get', path, {
'content-type' => 'application/json',
Expand All @@ -15,21 +14,33 @@ def get()
def delete()
path = '/account'

params = {
}
params = {}

return @client.call('delete', path, {
'content-type' => 'application/json',
}, params);
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',
Expand All @@ -39,33 +50,47 @@ def update_email(email:, password:)
def get_logs()
path = '/account/logs'

params = {
}
params = {}

return @client.call('get', path, {
'content-type' => 'application/json',
}, params);
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',
Expand All @@ -75,48 +100,93 @@ def update_password(password:, old_password: '')
def get_prefs()
path = '/account/prefs'

params = {
}
params = {}

return @client.call('get', path, {
'content-type' => 'application/json',
}, params);
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',
}, params);
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',
}, params);
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',
Expand All @@ -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',
Expand All @@ -137,45 +206,66 @@ def get_sessions()
def delete_sessions()
path = '/account/sessions'

params = {
}
params = {}

return @client.call('delete', path, {
'content-type' => 'application/json',
}, params);
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',
}, params);
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',
}, params);
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',
Expand Down
Loading

0 comments on commit a38e1ab

Please sign in to comment.