fromJson static method
Returns a new EsimProfile instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static EsimProfile? 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(() {
assert(json.containsKey(r'orderId'), 'Required key "EsimProfile[orderId]" is missing from JSON.');
assert(json[r'orderId'] != null, 'Required key "EsimProfile[orderId]" has a null value in JSON.');
assert(json.containsKey(r'orderItemId'), 'Required key "EsimProfile[orderItemId]" is missing from JSON.');
assert(json[r'orderItemId'] != null, 'Required key "EsimProfile[orderItemId]" has a null value in JSON.');
assert(json.containsKey(r'packageName'), 'Required key "EsimProfile[packageName]" is missing from JSON.');
assert(json[r'packageName'] != null, 'Required key "EsimProfile[packageName]" has a null value in JSON.');
assert(json.containsKey(r'status'), 'Required key "EsimProfile[status]" is missing from JSON.');
assert(json[r'status'] != null, 'Required key "EsimProfile[status]" has a null value in JSON.');
return true;
}());
return EsimProfile(
orderId: mapValueOfType<String>(json, r'orderId')!,
orderItemId: mapValueOfType<String>(json, r'orderItemId')!,
iccid: mapValueOfType<String>(json, r'iccid'),
packageName: mapValueOfType<String>(json, r'packageName')!,
countryImage: mapValueOfType<String>(json, r'countryImage'),
status: EsimProfileStatusEnum.fromJson(json[r'status'])!,
day: mapValueOfType<int>(json, r'day'),
isUnlimited: mapValueOfType<bool>(json, r'isUnlimited'),
isApnAutomatic: mapValueOfType<bool>(json, r'isApnAutomatic'),
withSMS: mapValueOfType<bool>(json, r'withSMS'),
withCall: mapValueOfType<bool>(json, r'withCall'),
properties: EsimFeatures.fromJson(json[r'properties']),
esim: SimCard.fromJson(json[r'esim']),
addon: EsimAddon.listFromJson(json[r'addon']),
data: EsimProfileData.fromJson(json[r'data']),
sms: EsimSmsAllowance.fromJson(json[r'sms']),
voice: EsimVoiceAllowance.fromJson(json[r'voice']),
apn: EsimApn.fromJson(json[r'apn']),
expiredAt: mapDateTime(json, r'expiredAt', r''),
);
}
return null;
}