Skip to content

Commit a38e1ab

Browse files
add param checking and removed default values
1 parent 6fda7b4 commit a38e1ab

File tree

11 files changed

+1094
-355
lines changed

11 files changed

+1094
-355
lines changed

appwrite.gemspec

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

33
s.name = 'appwrite'
4-
s.version = '2.1.1'
4+
s.version = '2.1.2'
55
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"
66
s.author = 'Appwrite Team'
77
s.homepage = 'https://appwrite.io/support'

lib/appwrite/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def initialize()
2020
@headers = {
2121
'content-type' => '',
2222
'user-agent' => RUBY_PLATFORM + ':ruby-' + RUBY_VERSION,
23-
'x-sdk-version' => 'appwrite:ruby:2.1.1',
23+
'x-sdk-version' => 'appwrite:ruby:2.1.2',
2424
'X-Appwrite-Response-Format' => '0.8.0'
2525
}
2626
@endpoint = 'https://appwrite.io/v1';

lib/appwrite/services/account.rb

Lines changed: 136 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ class Account < Service
44
def get()
55
path = '/account'
66

7-
params = {
8-
}
7+
params = {}
98

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

18-
params = {
19-
}
17+
params = {}
2018

2119
return @client.call('delete', path, {
2220
'content-type' => 'application/json',
2321
}, params);
2422
end
2523

2624
def update_email(email:, password:)
25+
if email.nil?
26+
raise Appwrite::Exception.new('Missing required parameter: "email"')
27+
end
28+
29+
if password.nil?
30+
raise Appwrite::Exception.new('Missing required parameter: "password"')
31+
end
32+
2733
path = '/account/email'
2834

29-
params = {
30-
'email': email,
31-
'password': password
32-
}
35+
params = {}
36+
37+
if !email.nil?
38+
params[:email] = email
39+
end
40+
41+
if !password.nil?
42+
params[:password] = password
43+
end
3344

3445
return @client.call('patch', path, {
3546
'content-type' => 'application/json',
@@ -39,33 +50,47 @@ def update_email(email:, password:)
3950
def get_logs()
4051
path = '/account/logs'
4152

42-
params = {
43-
}
53+
params = {}
4454

4555
return @client.call('get', path, {
4656
'content-type' => 'application/json',
4757
}, params);
4858
end
4959

5060
def update_name(name:)
61+
if name.nil?
62+
raise Appwrite::Exception.new('Missing required parameter: "name"')
63+
end
64+
5165
path = '/account/name'
5266

53-
params = {
54-
'name': name
55-
}
67+
params = {}
68+
69+
if !name.nil?
70+
params[:name] = name
71+
end
5672

5773
return @client.call('patch', path, {
5874
'content-type' => 'application/json',
5975
}, params);
6076
end
6177

62-
def update_password(password:, old_password: '')
78+
def update_password(password:, old_password: nil)
79+
if password.nil?
80+
raise Appwrite::Exception.new('Missing required parameter: "password"')
81+
end
82+
6383
path = '/account/password'
6484

65-
params = {
66-
'password': password,
67-
'oldPassword': old_password
68-
}
85+
params = {}
86+
87+
if !password.nil?
88+
params[:password] = password
89+
end
90+
91+
if !old_password.nil?
92+
params[:oldPassword] = old_password
93+
end
6994

7095
return @client.call('patch', path, {
7196
'content-type' => 'application/json',
@@ -75,48 +100,93 @@ def update_password(password:, old_password: '')
75100
def get_prefs()
76101
path = '/account/prefs'
77102

78-
params = {
79-
}
103+
params = {}
80104

81105
return @client.call('get', path, {
82106
'content-type' => 'application/json',
83107
}, params);
84108
end
85109

86110
def update_prefs(prefs:)
111+
if prefs.nil?
112+
raise Appwrite::Exception.new('Missing required parameter: "prefs"')
113+
end
114+
87115
path = '/account/prefs'
88116

89-
params = {
90-
'prefs': prefs
91-
}
117+
params = {}
118+
119+
if !prefs.nil?
120+
params[:prefs] = prefs
121+
end
92122

93123
return @client.call('patch', path, {
94124
'content-type' => 'application/json',
95125
}, params);
96126
end
97127

98128
def create_recovery(email:, url:)
129+
if email.nil?
130+
raise Appwrite::Exception.new('Missing required parameter: "email"')
131+
end
132+
133+
if url.nil?
134+
raise Appwrite::Exception.new('Missing required parameter: "url"')
135+
end
136+
99137
path = '/account/recovery'
100138

101-
params = {
102-
'email': email,
103-
'url': url
104-
}
139+
params = {}
140+
141+
if !email.nil?
142+
params[:email] = email
143+
end
144+
145+
if !url.nil?
146+
params[:url] = url
147+
end
105148

106149
return @client.call('post', path, {
107150
'content-type' => 'application/json',
108151
}, params);
109152
end
110153

111154
def update_recovery(user_id:, secret:, password:, password_again:)
155+
if user_id.nil?
156+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
157+
end
158+
159+
if secret.nil?
160+
raise Appwrite::Exception.new('Missing required parameter: "secret"')
161+
end
162+
163+
if password.nil?
164+
raise Appwrite::Exception.new('Missing required parameter: "password"')
165+
end
166+
167+
if password_again.nil?
168+
raise Appwrite::Exception.new('Missing required parameter: "passwordAgain"')
169+
end
170+
112171
path = '/account/recovery'
113172

114-
params = {
115-
'userId': user_id,
116-
'secret': secret,
117-
'password': password,
118-
'passwordAgain': password_again
119-
}
173+
params = {}
174+
175+
if !user_id.nil?
176+
params[:userId] = user_id
177+
end
178+
179+
if !secret.nil?
180+
params[:secret] = secret
181+
end
182+
183+
if !password.nil?
184+
params[:password] = password
185+
end
186+
187+
if !password_again.nil?
188+
params[:passwordAgain] = password_again
189+
end
120190

121191
return @client.call('put', path, {
122192
'content-type' => 'application/json',
@@ -126,8 +196,7 @@ def update_recovery(user_id:, secret:, password:, password_again:)
126196
def get_sessions()
127197
path = '/account/sessions'
128198

129-
params = {
130-
}
199+
params = {}
131200

132201
return @client.call('get', path, {
133202
'content-type' => 'application/json',
@@ -137,45 +206,66 @@ def get_sessions()
137206
def delete_sessions()
138207
path = '/account/sessions'
139208

140-
params = {
141-
}
209+
params = {}
142210

143211
return @client.call('delete', path, {
144212
'content-type' => 'application/json',
145213
}, params);
146214
end
147215

148216
def delete_session(session_id:)
217+
if session_id.nil?
218+
raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
219+
end
220+
149221
path = '/account/sessions/{sessionId}'
150222
.gsub('{sessionId}', session_id)
151223

152-
params = {
153-
}
224+
params = {}
154225

155226
return @client.call('delete', path, {
156227
'content-type' => 'application/json',
157228
}, params);
158229
end
159230

160231
def create_verification(url:)
232+
if url.nil?
233+
raise Appwrite::Exception.new('Missing required parameter: "url"')
234+
end
235+
161236
path = '/account/verification'
162237

163-
params = {
164-
'url': url
165-
}
238+
params = {}
239+
240+
if !url.nil?
241+
params[:url] = url
242+
end
166243

167244
return @client.call('post', path, {
168245
'content-type' => 'application/json',
169246
}, params);
170247
end
171248

172249
def update_verification(user_id:, secret:)
250+
if user_id.nil?
251+
raise Appwrite::Exception.new('Missing required parameter: "userId"')
252+
end
253+
254+
if secret.nil?
255+
raise Appwrite::Exception.new('Missing required parameter: "secret"')
256+
end
257+
173258
path = '/account/verification'
174259

175-
params = {
176-
'userId': user_id,
177-
'secret': secret
178-
}
260+
params = {}
261+
262+
if !user_id.nil?
263+
params[:userId] = user_id
264+
end
265+
266+
if !secret.nil?
267+
params[:secret] = secret
268+
end
179269

180270
return @client.call('put', path, {
181271
'content-type' => 'application/json',

0 commit comments

Comments
 (0)