1
1
from ..service import Service
2
-
2
+ from .. exception import AppwriteException
3
3
4
4
class Account (Service ):
5
5
@@ -29,10 +29,20 @@ def delete(self):
29
29
def update_email (self , email , password ):
30
30
"""Update Account Email"""
31
31
32
+ if email is None :
33
+ raise AppwriteException ('Missing required parameter: "email"' )
34
+
35
+ if password is None :
36
+ raise AppwriteException ('Missing required parameter: "password"' )
37
+
32
38
params = {}
33
39
path = '/account/email'
34
- params ['email' ] = email
35
- params ['password' ] = password
40
+
41
+ if email is not None :
42
+ params ['email' ] = email
43
+
44
+ if password is not None :
45
+ params ['password' ] = password
36
46
37
47
return self .client .call ('patch' , path , {
38
48
'content-type' : 'application/json' ,
@@ -51,21 +61,33 @@ def get_logs(self):
51
61
def update_name (self , name ):
52
62
"""Update Account Name"""
53
63
64
+ if name is None :
65
+ raise AppwriteException ('Missing required parameter: "name"' )
66
+
54
67
params = {}
55
68
path = '/account/name'
56
- params ['name' ] = name
69
+
70
+ if name is not None :
71
+ params ['name' ] = name
57
72
58
73
return self .client .call ('patch' , path , {
59
74
'content-type' : 'application/json' ,
60
75
}, params )
61
76
62
- def update_password (self , password , old_password = '' ):
77
+ def update_password (self , password , old_password = None ):
63
78
"""Update Account Password"""
64
79
80
+ if password is None :
81
+ raise AppwriteException ('Missing required parameter: "password"' )
82
+
65
83
params = {}
66
84
path = '/account/password'
67
- params ['password' ] = password
68
- params ['oldPassword' ] = old_password
85
+
86
+ if password is not None :
87
+ params ['password' ] = password
88
+
89
+ if old_password is not None :
90
+ params ['oldPassword' ] = old_password
69
91
70
92
return self .client .call ('patch' , path , {
71
93
'content-type' : 'application/json' ,
@@ -84,9 +106,14 @@ def get_prefs(self):
84
106
def update_prefs (self , prefs ):
85
107
"""Update Account Preferences"""
86
108
109
+ if prefs is None :
110
+ raise AppwriteException ('Missing required parameter: "prefs"' )
111
+
87
112
params = {}
88
113
path = '/account/prefs'
89
- params ['prefs' ] = prefs
114
+
115
+ if prefs is not None :
116
+ params ['prefs' ] = prefs
90
117
91
118
return self .client .call ('patch' , path , {
92
119
'content-type' : 'application/json' ,
@@ -95,10 +122,20 @@ def update_prefs(self, prefs):
95
122
def create_recovery (self , email , url ):
96
123
"""Create Password Recovery"""
97
124
125
+ if email is None :
126
+ raise AppwriteException ('Missing required parameter: "email"' )
127
+
128
+ if url is None :
129
+ raise AppwriteException ('Missing required parameter: "url"' )
130
+
98
131
params = {}
99
132
path = '/account/recovery'
100
- params ['email' ] = email
101
- params ['url' ] = url
133
+
134
+ if email is not None :
135
+ params ['email' ] = email
136
+
137
+ if url is not None :
138
+ params ['url' ] = url
102
139
103
140
return self .client .call ('post' , path , {
104
141
'content-type' : 'application/json' ,
@@ -107,12 +144,32 @@ def create_recovery(self, email, url):
107
144
def update_recovery (self , user_id , secret , password , password_again ):
108
145
"""Complete Password Recovery"""
109
146
147
+ if user_id is None :
148
+ raise AppwriteException ('Missing required parameter: "user_id"' )
149
+
150
+ if secret is None :
151
+ raise AppwriteException ('Missing required parameter: "secret"' )
152
+
153
+ if password is None :
154
+ raise AppwriteException ('Missing required parameter: "password"' )
155
+
156
+ if password_again is None :
157
+ raise AppwriteException ('Missing required parameter: "password_again"' )
158
+
110
159
params = {}
111
160
path = '/account/recovery'
112
- params ['userId' ] = user_id
113
- params ['secret' ] = secret
114
- params ['password' ] = password
115
- params ['passwordAgain' ] = password_again
161
+
162
+ if user_id is not None :
163
+ params ['userId' ] = user_id
164
+
165
+ if secret is not None :
166
+ params ['secret' ] = secret
167
+
168
+ if password is not None :
169
+ params ['password' ] = password
170
+
171
+ if password_again is not None :
172
+ params ['passwordAgain' ] = password_again
116
173
117
174
return self .client .call ('put' , path , {
118
175
'content-type' : 'application/json' ,
@@ -141,6 +198,9 @@ def delete_sessions(self):
141
198
def delete_session (self , session_id ):
142
199
"""Delete Account Session"""
143
200
201
+ if session_id is None :
202
+ raise AppwriteException ('Missing required parameter: "session_id"' )
203
+
144
204
params = {}
145
205
path = '/account/sessions/{sessionId}'
146
206
path = path .replace ('{sessionId}' , session_id )
@@ -152,9 +212,14 @@ def delete_session(self, session_id):
152
212
def create_verification (self , url ):
153
213
"""Create Email Verification"""
154
214
215
+ if url is None :
216
+ raise AppwriteException ('Missing required parameter: "url"' )
217
+
155
218
params = {}
156
219
path = '/account/verification'
157
- params ['url' ] = url
220
+
221
+ if url is not None :
222
+ params ['url' ] = url
158
223
159
224
return self .client .call ('post' , path , {
160
225
'content-type' : 'application/json' ,
@@ -163,10 +228,20 @@ def create_verification(self, url):
163
228
def update_verification (self , user_id , secret ):
164
229
"""Complete Email Verification"""
165
230
231
+ if user_id is None :
232
+ raise AppwriteException ('Missing required parameter: "user_id"' )
233
+
234
+ if secret is None :
235
+ raise AppwriteException ('Missing required parameter: "secret"' )
236
+
166
237
params = {}
167
238
path = '/account/verification'
168
- params ['userId' ] = user_id
169
- params ['secret' ] = secret
239
+
240
+ if user_id is not None :
241
+ params ['userId' ] = user_id
242
+
243
+ if secret is not None :
244
+ params ['secret' ] = secret
170
245
171
246
return self .client .call ('put' , path , {
172
247
'content-type' : 'application/json' ,
0 commit comments