Skip to content

Commit 0331f0a

Browse files
committed
unify get account response types
1 parent 1803f34 commit 0331f0a

File tree

2 files changed

+18
-31
lines changed

2 files changed

+18
-31
lines changed

lib/src/web/static_interop/response/account_response.dart

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import '../models/profile.dart';
77
import '../models/validation_error.dart';
88
import 'response.dart';
99

10-
// TODO: preferences, subscriptions should be in `AccountResponse`
10+
// TODO: preferences, subscriptions should be in `GetAccountResponse`
1111

12-
/// The extension type for the account response.
12+
/// The extension type for the get account response.
1313
@JS()
1414
@anonymous
1515
@staticInterop
16-
extension type AccountResponse(Response baseResponse) {
16+
extension type GetAccountResponse(Response baseResponse) {
1717
/// The timestamp of the creation of the user.
1818
external String? get created;
1919

@@ -23,6 +23,11 @@ extension type AccountResponse(Response baseResponse) {
2323
/// The verified and unverified email addresses of the user.
2424
external Emails? get emails;
2525

26+
/// Whether this account is currently in transition.
27+
///
28+
/// An account that is in transition cannot be modified.
29+
external bool? get inTransition;
30+
2631
/// Whether the user is active.
2732
external bool? get isActive;
2833

@@ -80,12 +85,17 @@ extension type AccountResponse(Response baseResponse) {
8085
/// The timestamp when the user was verified.
8186
external String? get verified;
8287

88+
// TODO: add lockedUntil when DateTime static interop is fixed.
89+
// Currently it is not supported, so add a static interop type for the date class
90+
// See: https://github.com/dart-lang/sdk/issues/52021
91+
8392
/// Convert this response to a [Map].
8493
Map<String, dynamic> toMap() {
8594
return <String, dynamic>{
8695
'created': created,
8796
'data': data.dartify(),
8897
'emails': emails?.toMap(),
98+
'inTransition': inTransition,
8999
'isActive': isActive,
90100
'isRegistered': isRegistered,
91101
'isVerified': isVerified,
@@ -105,29 +115,6 @@ extension type AccountResponse(Response baseResponse) {
105115
'UIDSignature': UIDSignature,
106116
'verified': verified,
107117
};
108-
}
109-
}
110-
111-
/// The extension type for the get account response.
112-
@JS()
113-
@anonymous
114-
@staticInterop
115-
extension type GetAccountResponse(AccountResponse accountResponse) {
116-
/// Whether this account is currently in transition.
117-
///
118-
/// An account that is in transition cannot be modified.
119-
external bool? get inTransition;
120-
121-
// TODO: add lockedUntil when DateTime static interop is fixed.
122-
// Currently it is not supported, so add a static interop type for the date class
123-
// See: https://github.com/dart-lang/sdk/issues/52021
124-
125-
/// Convert this response to a [Map].
126-
Map<String, dynamic> toMap() {
127-
return <String, dynamic>{
128-
...accountResponse.toMap(),
129-
'inTransition': inTransition,
130-
};
131118
}
132119
}
133120

lib/src/web/web_account_delegate.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class WebAccountDelegate {
3030
return;
3131
}
3232

33-
if (response.accountResponse.baseResponse.errorCode == 0) {
33+
if (response.baseResponse.errorCode == 0) {
3434
completer.complete(response.toMap());
3535
} else {
3636
completer.completeError(
3737
GigyaError(
38-
apiVersion: response.accountResponse.baseResponse.apiVersion,
39-
callId: response.accountResponse.baseResponse.callId,
40-
details: response.accountResponse.baseResponse.details,
41-
errorCode: response.accountResponse.baseResponse.errorCode,
38+
apiVersion: response.baseResponse.apiVersion,
39+
callId: response.baseResponse.callId,
40+
details: response.baseResponse.details,
41+
errorCode: response.baseResponse.errorCode,
4242
),
4343
);
4444
}

0 commit comments

Comments
 (0)