@@ -7,7 +7,7 @@ class Account extends Service {
7
7
///
8
8
/// Get currently logged in user data as JSON object.
9
9
///
10
- Future <Response > get () {
10
+ Future <models. User > get () async {
11
11
final String path = '/account' ;
12
12
13
13
final Map <String , dynamic > params = {
@@ -17,7 +17,8 @@ class Account extends Service {
17
17
'content-type' : 'application/json' ,
18
18
};
19
19
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);
21
22
}
22
23
23
24
/// Delete Account
@@ -28,7 +29,7 @@ class Account extends Service {
28
29
/// address. Any user-related resources like documents or storage files should
29
30
/// be deleted separately.
30
31
///
31
- Future < Response > delete () {
32
+ Future delete () async {
32
33
final String path = '/account' ;
33
34
34
35
final Map <String , dynamic > params = {
@@ -38,7 +39,8 @@ class Account extends Service {
38
39
'content-type' : 'application/json' ,
39
40
};
40
41
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;
42
44
}
43
45
44
46
/// Update Account Email
@@ -50,7 +52,7 @@ class Account extends Service {
50
52
/// This endpoint can also be used to convert an anonymous account to a normal
51
53
/// one, by passing an email address and a new password.
52
54
///
53
- Future <Response > updateEmail ({required String email, required String password}) {
55
+ Future <models. User > updateEmail ({required String email, required String password}) async {
54
56
final String path = '/account/email' ;
55
57
56
58
final Map <String , dynamic > params = {
@@ -62,15 +64,16 @@ class Account extends Service {
62
64
'content-type' : 'application/json' ,
63
65
};
64
66
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);
66
69
}
67
70
68
71
/// Get Account Logs
69
72
///
70
73
/// Get currently logged in user list of latest security activity logs. Each
71
74
/// log returns user IP address, location and date and time of log.
72
75
///
73
- Future <Response > getLogs () {
76
+ Future <models. LogList > getLogs () async {
74
77
final String path = '/account/logs' ;
75
78
76
79
final Map <String , dynamic > params = {
@@ -80,14 +83,15 @@ class Account extends Service {
80
83
'content-type' : 'application/json' ,
81
84
};
82
85
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);
84
88
}
85
89
86
90
/// Update Account Name
87
91
///
88
92
/// Update currently logged in user account name.
89
93
///
90
- Future <Response > updateName ({required String name}) {
94
+ Future <models. User > updateName ({required String name}) async {
91
95
final String path = '/account/name' ;
92
96
93
97
final Map <String , dynamic > params = {
@@ -98,7 +102,8 @@ class Account extends Service {
98
102
'content-type' : 'application/json' ,
99
103
};
100
104
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);
102
107
}
103
108
104
109
/// Update Account Password
@@ -107,7 +112,7 @@ class Account extends Service {
107
112
/// to pass in the new password, and the old password. For users created with
108
113
/// OAuth and Team Invites, oldPassword is optional.
109
114
///
110
- Future <Response > updatePassword ({required String password, String ? oldPassword}) {
115
+ Future <models. User > updatePassword ({required String password, String ? oldPassword}) async {
111
116
final String path = '/account/password' ;
112
117
113
118
final Map <String , dynamic > params = {
@@ -119,14 +124,15 @@ class Account extends Service {
119
124
'content-type' : 'application/json' ,
120
125
};
121
126
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);
123
129
}
124
130
125
131
/// Get Account Preferences
126
132
///
127
133
/// Get currently logged in user preferences as a key-value object.
128
134
///
129
- Future <Response > getPrefs () {
135
+ Future <models. Preferences > getPrefs () async {
130
136
final String path = '/account/prefs' ;
131
137
132
138
final Map <String , dynamic > params = {
@@ -136,15 +142,16 @@ class Account extends Service {
136
142
'content-type' : 'application/json' ,
137
143
};
138
144
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);
140
147
}
141
148
142
149
/// Update Account Preferences
143
150
///
144
151
/// Update currently logged in user account preferences. You can pass only the
145
152
/// specific settings you wish to update.
146
153
///
147
- Future <Response > updatePrefs ({required Map prefs}) {
154
+ Future <models. User > updatePrefs ({required Map prefs}) async {
148
155
final String path = '/account/prefs' ;
149
156
150
157
final Map <String , dynamic > params = {
@@ -155,7 +162,8 @@ class Account extends Service {
155
162
'content-type' : 'application/json' ,
156
163
};
157
164
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);
159
167
}
160
168
161
169
/// Create Password Recovery
@@ -169,7 +177,7 @@ class Account extends Service {
169
177
/// complete the process. The verification link sent to the user's email
170
178
/// address is valid for 1 hour.
171
179
///
172
- Future <Response > createRecovery ({required String email, required String url}) {
180
+ Future <models. Token > createRecovery ({required String email, required String url}) async {
173
181
final String path = '/account/recovery' ;
174
182
175
183
final Map <String , dynamic > params = {
@@ -181,7 +189,8 @@ class Account extends Service {
181
189
'content-type' : 'application/json' ,
182
190
};
183
191
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);
185
194
}
186
195
187
196
/// Create Password Recovery (confirmation)
@@ -196,7 +205,7 @@ class Account extends Service {
196
205
/// the only valid redirect URLs are the ones from domains you have set when
197
206
/// adding your platforms in the console interface.
198
207
///
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 {
200
209
final String path = '/account/recovery' ;
201
210
202
211
final Map <String , dynamic > params = {
@@ -210,15 +219,16 @@ class Account extends Service {
210
219
'content-type' : 'application/json' ,
211
220
};
212
221
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);
214
224
}
215
225
216
226
/// Get Account Sessions
217
227
///
218
228
/// Get currently logged in user list of active sessions across different
219
229
/// devices.
220
230
///
221
- Future <Response > getSessions () {
231
+ Future <models. SessionList > getSessions () async {
222
232
final String path = '/account/sessions' ;
223
233
224
234
final Map <String , dynamic > params = {
@@ -228,15 +238,16 @@ class Account extends Service {
228
238
'content-type' : 'application/json' ,
229
239
};
230
240
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);
232
243
}
233
244
234
245
/// Delete All Account Sessions
235
246
///
236
247
/// Delete all sessions from the user account and remove any sessions cookies
237
248
/// from the end client.
238
249
///
239
- Future < Response > deleteSessions () {
250
+ Future deleteSessions () async {
240
251
final String path = '/account/sessions' ;
241
252
242
253
final Map <String , dynamic > params = {
@@ -246,15 +257,16 @@ class Account extends Service {
246
257
'content-type' : 'application/json' ,
247
258
};
248
259
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;
250
262
}
251
263
252
264
/// Get Session By ID
253
265
///
254
266
/// Use this endpoint to get a logged in user's session using a Session ID.
255
267
/// Inputting 'current' will return the current session being used.
256
268
///
257
- Future <Response > getSession ({required String sessionId}) {
269
+ Future <models. Session > getSession ({required String sessionId}) async {
258
270
final String path = '/account/sessions/{sessionId}' .replaceAll (RegExp ('{sessionId}' ), sessionId);
259
271
260
272
final Map <String , dynamic > params = {
@@ -264,7 +276,8 @@ class Account extends Service {
264
276
'content-type' : 'application/json' ,
265
277
};
266
278
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);
268
281
}
269
282
270
283
/// Delete Account Session
@@ -273,7 +286,7 @@ class Account extends Service {
273
286
/// account sessions across all of their different devices. When using the
274
287
/// option id argument, only the session unique ID provider will be deleted.
275
288
///
276
- Future < Response > deleteSession ({required String sessionId}) {
289
+ Future deleteSession ({required String sessionId}) async {
277
290
final String path = '/account/sessions/{sessionId}' .replaceAll (RegExp ('{sessionId}' ), sessionId);
278
291
279
292
final Map <String , dynamic > params = {
@@ -283,7 +296,8 @@ class Account extends Service {
283
296
'content-type' : 'application/json' ,
284
297
};
285
298
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;
287
301
}
288
302
289
303
/// Create Email Verification
@@ -304,7 +318,7 @@ class Account extends Service {
304
318
/// adding your platforms in the console interface.
305
319
///
306
320
///
307
- Future <Response > createVerification ({required String url}) {
321
+ Future <models. Token > createVerification ({required String url}) async {
308
322
final String path = '/account/verification' ;
309
323
310
324
final Map <String , dynamic > params = {
@@ -315,7 +329,8 @@ class Account extends Service {
315
329
'content-type' : 'application/json' ,
316
330
};
317
331
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);
319
334
}
320
335
321
336
/// Create Email Verification (confirmation)
@@ -325,7 +340,7 @@ class Account extends Service {
325
340
/// to verify the user email ownership. If confirmed this route will return a
326
341
/// 200 status code.
327
342
///
328
- Future <Response > updateVerification ({required String userId, required String secret}) {
343
+ Future <models. Token > updateVerification ({required String userId, required String secret}) async {
329
344
final String path = '/account/verification' ;
330
345
331
346
final Map <String , dynamic > params = {
@@ -337,6 +352,7 @@ class Account extends Service {
337
352
'content-type' : 'application/json' ,
338
353
};
339
354
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);
341
357
}
342
358
}
0 commit comments