fromJson static method
Returns a new DecryptedMessageDto instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static DecryptedMessageDto? fromJson(dynamic value) {
if (value is DecryptedMessageDto) {
return 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 "DecryptedMessageDto[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "DecryptedMessageDto[$key]" has a null value in JSON.');
});
return true;
}());
return DecryptedMessageDto(
id: mapValueOfType<String>(json, r'id')!,
rev: mapValueOfType<String>(json, r'rev'),
created: mapValueOfType<int>(json, r'created'),
modified: mapValueOfType<int>(json, r'modified'),
author: mapValueOfType<String>(json, r'author'),
responsible: mapValueOfType<String>(json, r'responsible'),
medicalLocationId: mapValueOfType<String>(json, r'medicalLocationId'),
tags: CodeStubDto.listFromJson(json[r'tags'])!.toSet(),
codes: CodeStubDto.listFromJson(json[r'codes'])!.toSet(),
endOfLife: mapValueOfType<int>(json, r'endOfLife'),
deletionDate: mapValueOfType<int>(json, r'deletionDate'),
fromAddress: mapValueOfType<String>(json, r'fromAddress'),
fromHealthcarePartyId: mapValueOfType<String>(json, r'fromHealthcarePartyId'),
formId: mapValueOfType<String>(json, r'formId'),
status: mapValueOfType<int>(json, r'status'),
recipientsType: mapValueOfType<String>(json, r'recipientsType'),
recipients: json[r'recipients'] is Set
? (json[r'recipients'] as Set).cast<String>()
: json[r'recipients'] is List
? ((json[r'recipients'] as List).toSet()).cast<String>()
: const {},
toAddresses: json[r'toAddresses'] is Set
? (json[r'toAddresses'] as Set).cast<String>()
: json[r'toAddresses'] is List
? ((json[r'toAddresses'] as List).toSet()).cast<String>()
: const {},
received: mapValueOfType<int>(json, r'received'),
sent: mapValueOfType<int>(json, r'sent'),
metas: mapCastOfType<String, String>(json, r'metas')!,
readStatus: mapValueOfType<Map<String, MessageReadStatusDto>>(json, r'readStatus')!,
transportGuid: mapValueOfType<String>(json, r'transportGuid'),
remark: mapValueOfType<String>(json, r'remark'),
conversationGuid: mapValueOfType<String>(json, r'conversationGuid'),
subject: mapValueOfType<String>(json, r'subject'),
invoiceIds: json[r'invoiceIds'] is Set
? (json[r'invoiceIds'] as Set).cast<String>()
: json[r'invoiceIds'] is List
? ((json[r'invoiceIds'] as List).toSet()).cast<String>()
: const {},
parentId: mapValueOfType<String>(json, r'parentId'),
externalRef: mapValueOfType<String>(json, r'externalRef'),
unassignedResults: json[r'unassignedResults'] is Set
? (json[r'unassignedResults'] as Set).cast<String>()
: json[r'unassignedResults'] is List
? ((json[r'unassignedResults'] as List).toSet()).cast<String>()
: const {},
assignedResults: mapCastOfType<String, String>(json, r'assignedResults')!,
senderReferences: mapCastOfType<String, String>(json, r'senderReferences')!,
secretForeignKeys: json[r'secretForeignKeys'] is Set
? (json[r'secretForeignKeys'] as Set).cast<String>()
: json[r'secretForeignKeys'] is List
? ((json[r'secretForeignKeys'] as List).toSet()).cast<String>()
: const {},
cryptedForeignKeys: json[r'cryptedForeignKeys'] == null ? const {} : DelegationDto.mapListFromJson(json[r'cryptedForeignKeys']),
delegations: json[r'delegations'] == null ? const {} : DelegationDto.mapListFromJson(json[r'delegations']),
encryptionKeys: json[r'encryptionKeys'] == null ? const {} : DelegationDto.mapListFromJson(json[r'encryptionKeys']),
encryptedSelf: mapValueOfType<String>(json, r'encryptedSelf'),
);
}
return null;
}