fromJson static method
SignUp?
fromJson(
- dynamic value
)
Returns a new SignUp instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static SignUp? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key),
'Required key "SignUp[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "SignUp[$key]" has a null value in JSON.');
});
return true;
}());
return SignUp(
object: SignUpObjectEnum.fromJson(json[r'object'])!,
id: mapValueOfType<String>(json, r'id')!,
status: SignUpStatusEnum.fromJson(json[r'status'])!,
requiredFields: json[r'required_fields'] is Iterable
? (json[r'required_fields'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
optionalFields: json[r'optional_fields'] is Iterable
? (json[r'optional_fields'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
missingFields: json[r'missing_fields'] is Iterable
? (json[r'missing_fields'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
unverifiedFields: json[r'unverified_fields'] is Iterable
? (json[r'unverified_fields'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
verifications: SignUpVerifications.fromJson(json[r'verifications'])!,
username: mapValueOfType<String>(json, r'username'),
emailAddress: mapValueOfType<String>(json, r'email_address'),
phoneNumber: mapValueOfType<String>(json, r'phone_number'),
web3Wallet: mapValueOfType<String>(json, r'web3_wallet'),
passwordEnabled: mapValueOfType<bool>(json, r'password_enabled')!,
firstName: mapValueOfType<String>(json, r'first_name'),
lastName: mapValueOfType<String>(json, r'last_name'),
unsafeMetadata:
mapCastOfType<String, Object>(json, r'unsafe_metadata') ?? const {},
publicMetadata:
mapCastOfType<String, Object>(json, r'public_metadata') ?? const {},
customAction: mapValueOfType<bool>(json, r'custom_action')!,
externalId: mapValueOfType<String>(json, r'external_id'),
createdSessionId: mapValueOfType<String>(json, r'created_session_id'),
createdUserId: mapValueOfType<String>(json, r'created_user_id'),
abandonAt: mapValueOfType<int>(json, r'abandon_at')!,
legalAcceptedAt: mapValueOfType<int>(json, r'legal_accepted_at'),
externalAccount: mapValueOfType<Object>(json, r'external_account'),
);
}
return null;
}