fromJson static method
Returns a new CreateUserRequest instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static CreateUserRequest? 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 "CreateUserRequest[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "CreateUserRequest[$key]" has a null value in JSON.');
});
return true;
}());
return CreateUserRequest(
externalId: mapValueOfType<String>(json, r'external_id'),
firstName: mapValueOfType<String>(json, r'first_name'),
lastName: mapValueOfType<String>(json, r'last_name'),
emailAddress: json[r'email_address'] is Iterable
? (json[r'email_address'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
phoneNumber: json[r'phone_number'] is Iterable
? (json[r'phone_number'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
web3Wallet: json[r'web3_wallet'] is Iterable
? (json[r'web3_wallet'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
username: mapValueOfType<String>(json, r'username'),
password: mapValueOfType<String>(json, r'password'),
passwordDigest: mapValueOfType<String>(json, r'password_digest'),
passwordHasher: mapValueOfType<String>(json, r'password_hasher'),
skipPasswordChecks: mapValueOfType<bool>(json, r'skip_password_checks'),
skipPasswordRequirement:
mapValueOfType<bool>(json, r'skip_password_requirement'),
totpSecret: mapValueOfType<String>(json, r'totp_secret'),
backupCodes: json[r'backup_codes'] is Iterable
? (json[r'backup_codes'] as Iterable)
.cast<String>()
.toList(growable: false)
: const [],
publicMetadata:
mapCastOfType<String, Object>(json, r'public_metadata') ?? const {},
privateMetadata:
mapCastOfType<String, Object>(json, r'private_metadata') ??
const {},
unsafeMetadata:
mapCastOfType<String, Object>(json, r'unsafe_metadata') ?? const {},
deleteSelfEnabled: mapValueOfType<bool>(json, r'delete_self_enabled'),
legalAcceptedAt: mapValueOfType<String>(json, r'legal_accepted_at'),
skipLegalChecks: mapValueOfType<bool>(json, r'skip_legal_checks'),
createOrganizationEnabled:
mapValueOfType<bool>(json, r'create_organization_enabled'),
createOrganizationsLimit:
mapValueOfType<int>(json, r'create_organizations_limit'),
createdAt: mapValueOfType<String>(json, r'created_at'),
);
}
return null;
}