@@ -7,7 +7,7 @@ class Account extends Service {
77 ///
88 /// Get currently logged in user data as JSON object.
99 ///
10- Future <Response > get () {
10+ Future <models. User > get () async {
1111 final String path = '/account' ;
1212
1313 final Map <String , dynamic > params = {
@@ -17,7 +17,8 @@ class Account extends Service {
1717 'content-type' : 'application/json' ,
1818 };
1919
20- return client.call (HttpMethod .get , path: path, params: params, headers: headers);
20+ final res = await client.call (HttpMethod .get , path: path, params: params, headers: headers);
21+ return models.User .fromMap (res.data);
2122 }
2223
2324 /// Delete Account
@@ -28,7 +29,7 @@ class Account extends Service {
2829 /// address. Any user-related resources like documents or storage files should
2930 /// be deleted separately.
3031 ///
31- Future < Response > delete () {
32+ Future delete () async {
3233 final String path = '/account' ;
3334
3435 final Map <String , dynamic > params = {
@@ -38,7 +39,8 @@ class Account extends Service {
3839 'content-type' : 'application/json' ,
3940 };
4041
41- return client.call (HttpMethod .delete, path: path, params: params, headers: headers);
42+ final res = await client.call (HttpMethod .delete, path: path, params: params, headers: headers);
43+ return res.data;
4244 }
4345
4446 /// Update Account Email
@@ -50,7 +52,7 @@ class Account extends Service {
5052 /// This endpoint can also be used to convert an anonymous account to a normal
5153 /// one, by passing an email address and a new password.
5254 ///
53- Future <Response > updateEmail ({required String email, required String password}) {
55+ Future <models. User > updateEmail ({required String email, required String password}) async {
5456 final String path = '/account/email' ;
5557
5658 final Map <String , dynamic > params = {
@@ -62,15 +64,16 @@ class Account extends Service {
6264 'content-type' : 'application/json' ,
6365 };
6466
65- return client.call (HttpMethod .patch, path: path, params: params, headers: headers);
67+ final res = await client.call (HttpMethod .patch, path: path, params: params, headers: headers);
68+ return models.User .fromMap (res.data);
6669 }
6770
6871 /// Get Account Logs
6972 ///
7073 /// Get currently logged in user list of latest security activity logs. Each
7174 /// log returns user IP address, location and date and time of log.
7275 ///
73- Future <Response > getLogs () {
76+ Future <models. LogList > getLogs () async {
7477 final String path = '/account/logs' ;
7578
7679 final Map <String , dynamic > params = {
@@ -80,14 +83,15 @@ class Account extends Service {
8083 'content-type' : 'application/json' ,
8184 };
8285
83- return client.call (HttpMethod .get , path: path, params: params, headers: headers);
86+ final res = await client.call (HttpMethod .get , path: path, params: params, headers: headers);
87+ return models.LogList .fromMap (res.data);
8488 }
8589
8690 /// Update Account Name
8791 ///
8892 /// Update currently logged in user account name.
8993 ///
90- Future <Response > updateName ({required String name}) {
94+ Future <models. User > updateName ({required String name}) async {
9195 final String path = '/account/name' ;
9296
9397 final Map <String , dynamic > params = {
@@ -98,7 +102,8 @@ class Account extends Service {
98102 'content-type' : 'application/json' ,
99103 };
100104
101- return client.call (HttpMethod .patch, path: path, params: params, headers: headers);
105+ final res = await client.call (HttpMethod .patch, path: path, params: params, headers: headers);
106+ return models.User .fromMap (res.data);
102107 }
103108
104109 /// Update Account Password
@@ -107,7 +112,7 @@ class Account extends Service {
107112 /// to pass in the new password, and the old password. For users created with
108113 /// OAuth and Team Invites, oldPassword is optional.
109114 ///
110- Future <Response > updatePassword ({required String password, String ? oldPassword}) {
115+ Future <models. User > updatePassword ({required String password, String ? oldPassword}) async {
111116 final String path = '/account/password' ;
112117
113118 final Map <String , dynamic > params = {
@@ -119,14 +124,15 @@ class Account extends Service {
119124 'content-type' : 'application/json' ,
120125 };
121126
122- return client.call (HttpMethod .patch, path: path, params: params, headers: headers);
127+ final res = await client.call (HttpMethod .patch, path: path, params: params, headers: headers);
128+ return models.User .fromMap (res.data);
123129 }
124130
125131 /// Get Account Preferences
126132 ///
127133 /// Get currently logged in user preferences as a key-value object.
128134 ///
129- Future <Response > getPrefs () {
135+ Future <models. Preferences > getPrefs () async {
130136 final String path = '/account/prefs' ;
131137
132138 final Map <String , dynamic > params = {
@@ -136,15 +142,16 @@ class Account extends Service {
136142 'content-type' : 'application/json' ,
137143 };
138144
139- return client.call (HttpMethod .get , path: path, params: params, headers: headers);
145+ final res = await client.call (HttpMethod .get , path: path, params: params, headers: headers);
146+ return models.Preferences .fromMap (res.data);
140147 }
141148
142149 /// Update Account Preferences
143150 ///
144151 /// Update currently logged in user account preferences. You can pass only the
145152 /// specific settings you wish to update.
146153 ///
147- Future <Response > updatePrefs ({required Map prefs}) {
154+ Future <models. User > updatePrefs ({required Map prefs}) async {
148155 final String path = '/account/prefs' ;
149156
150157 final Map <String , dynamic > params = {
@@ -155,7 +162,8 @@ class Account extends Service {
155162 'content-type' : 'application/json' ,
156163 };
157164
158- return client.call (HttpMethod .patch, path: path, params: params, headers: headers);
165+ final res = await client.call (HttpMethod .patch, path: path, params: params, headers: headers);
166+ return models.User .fromMap (res.data);
159167 }
160168
161169 /// Create Password Recovery
@@ -169,7 +177,7 @@ class Account extends Service {
169177 /// complete the process. The verification link sent to the user's email
170178 /// address is valid for 1 hour.
171179 ///
172- Future <Response > createRecovery ({required String email, required String url}) {
180+ Future <models. Token > createRecovery ({required String email, required String url}) async {
173181 final String path = '/account/recovery' ;
174182
175183 final Map <String , dynamic > params = {
@@ -181,7 +189,8 @@ class Account extends Service {
181189 'content-type' : 'application/json' ,
182190 };
183191
184- return client.call (HttpMethod .post, path: path, params: params, headers: headers);
192+ final res = await client.call (HttpMethod .post, path: path, params: params, headers: headers);
193+ return models.Token .fromMap (res.data);
185194 }
186195
187196 /// Create Password Recovery (confirmation)
@@ -196,7 +205,7 @@ class Account extends Service {
196205 /// the only valid redirect URLs are the ones from domains you have set when
197206 /// adding your platforms in the console interface.
198207 ///
199- Future <Response > updateRecovery ({required String userId, required String secret, required String password, required String passwordAgain}) {
208+ Future <models. Token > updateRecovery ({required String userId, required String secret, required String password, required String passwordAgain}) async {
200209 final String path = '/account/recovery' ;
201210
202211 final Map <String , dynamic > params = {
@@ -210,15 +219,16 @@ class Account extends Service {
210219 'content-type' : 'application/json' ,
211220 };
212221
213- return client.call (HttpMethod .put, path: path, params: params, headers: headers);
222+ final res = await client.call (HttpMethod .put, path: path, params: params, headers: headers);
223+ return models.Token .fromMap (res.data);
214224 }
215225
216226 /// Get Account Sessions
217227 ///
218228 /// Get currently logged in user list of active sessions across different
219229 /// devices.
220230 ///
221- Future <Response > getSessions () {
231+ Future <models. SessionList > getSessions () async {
222232 final String path = '/account/sessions' ;
223233
224234 final Map <String , dynamic > params = {
@@ -228,15 +238,16 @@ class Account extends Service {
228238 'content-type' : 'application/json' ,
229239 };
230240
231- return client.call (HttpMethod .get , path: path, params: params, headers: headers);
241+ final res = await client.call (HttpMethod .get , path: path, params: params, headers: headers);
242+ return models.SessionList .fromMap (res.data);
232243 }
233244
234245 /// Delete All Account Sessions
235246 ///
236247 /// Delete all sessions from the user account and remove any sessions cookies
237248 /// from the end client.
238249 ///
239- Future < Response > deleteSessions () {
250+ Future deleteSessions () async {
240251 final String path = '/account/sessions' ;
241252
242253 final Map <String , dynamic > params = {
@@ -246,15 +257,16 @@ class Account extends Service {
246257 'content-type' : 'application/json' ,
247258 };
248259
249- return client.call (HttpMethod .delete, path: path, params: params, headers: headers);
260+ final res = await client.call (HttpMethod .delete, path: path, params: params, headers: headers);
261+ return res.data;
250262 }
251263
252264 /// Get Session By ID
253265 ///
254266 /// Use this endpoint to get a logged in user's session using a Session ID.
255267 /// Inputting 'current' will return the current session being used.
256268 ///
257- Future <Response > getSession ({required String sessionId}) {
269+ Future <models. Session > getSession ({required String sessionId}) async {
258270 final String path = '/account/sessions/{sessionId}' .replaceAll (RegExp ('{sessionId}' ), sessionId);
259271
260272 final Map <String , dynamic > params = {
@@ -264,7 +276,8 @@ class Account extends Service {
264276 'content-type' : 'application/json' ,
265277 };
266278
267- return client.call (HttpMethod .get , path: path, params: params, headers: headers);
279+ final res = await client.call (HttpMethod .get , path: path, params: params, headers: headers);
280+ return models.Session .fromMap (res.data);
268281 }
269282
270283 /// Delete Account Session
@@ -273,7 +286,7 @@ class Account extends Service {
273286 /// account sessions across all of their different devices. When using the
274287 /// option id argument, only the session unique ID provider will be deleted.
275288 ///
276- Future < Response > deleteSession ({required String sessionId}) {
289+ Future deleteSession ({required String sessionId}) async {
277290 final String path = '/account/sessions/{sessionId}' .replaceAll (RegExp ('{sessionId}' ), sessionId);
278291
279292 final Map <String , dynamic > params = {
@@ -283,7 +296,8 @@ class Account extends Service {
283296 'content-type' : 'application/json' ,
284297 };
285298
286- return client.call (HttpMethod .delete, path: path, params: params, headers: headers);
299+ final res = await client.call (HttpMethod .delete, path: path, params: params, headers: headers);
300+ return res.data;
287301 }
288302
289303 /// Create Email Verification
@@ -304,7 +318,7 @@ class Account extends Service {
304318 /// adding your platforms in the console interface.
305319 ///
306320 ///
307- Future <Response > createVerification ({required String url}) {
321+ Future <models. Token > createVerification ({required String url}) async {
308322 final String path = '/account/verification' ;
309323
310324 final Map <String , dynamic > params = {
@@ -315,7 +329,8 @@ class Account extends Service {
315329 'content-type' : 'application/json' ,
316330 };
317331
318- return client.call (HttpMethod .post, path: path, params: params, headers: headers);
332+ final res = await client.call (HttpMethod .post, path: path, params: params, headers: headers);
333+ return models.Token .fromMap (res.data);
319334 }
320335
321336 /// Create Email Verification (confirmation)
@@ -325,7 +340,7 @@ class Account extends Service {
325340 /// to verify the user email ownership. If confirmed this route will return a
326341 /// 200 status code.
327342 ///
328- Future <Response > updateVerification ({required String userId, required String secret}) {
343+ Future <models. Token > updateVerification ({required String userId, required String secret}) async {
329344 final String path = '/account/verification' ;
330345
331346 final Map <String , dynamic > params = {
@@ -337,6 +352,7 @@ class Account extends Service {
337352 'content-type' : 'application/json' ,
338353 };
339354
340- return client.call (HttpMethod .put, path: path, params: params, headers: headers);
355+ final res = await client.call (HttpMethod .put, path: path, params: params, headers: headers);
356+ return models.Token .fromMap (res.data);
341357 }
342358}
0 commit comments