fromJson static method

InvoiceDto? fromJson(
  1. dynamic value
)

Returns a new InvoiceDto instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static InvoiceDto? fromJson(dynamic value) {
  if (value is InvoiceDto) {
    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 "InvoiceDto[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "InvoiceDto[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return InvoiceDto(
      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'),
      invoiceDate: mapValueOfType<int>(json, r'invoiceDate'),
      sentDate: mapValueOfType<int>(json, r'sentDate'),
      printedDate: mapValueOfType<int>(json, r'printedDate'),
      invoicingCodes: InvoicingCodeDto.listFromJson(json[r'invoicingCodes'])!,
      receipts: mapCastOfType<String, String>(json, r'receipts')!,
      recipientType: mapValueOfType<String>(json, r'recipientType'),
      recipientId: mapValueOfType<String>(json, r'recipientId'),
      invoiceReference: mapValueOfType<String>(json, r'invoiceReference'),
      thirdPartyReference: mapValueOfType<String>(json, r'thirdPartyReference'),
      thirdPartyPaymentJustification: mapValueOfType<String>(json, r'thirdPartyPaymentJustification'),
      thirdPartyPaymentReason: mapValueOfType<String>(json, r'thirdPartyPaymentReason'),
      reason: mapValueOfType<String>(json, r'reason'),
      invoiceType: InvoiceDtoInvoiceTypeEnum.fromJson(json[r'invoiceType']),
      sentMediumType: InvoiceDtoSentMediumTypeEnum.fromJson(json[r'sentMediumType']),
      interventionType: InvoiceDtoInterventionTypeEnum.fromJson(json[r'interventionType']),
      groupId: mapValueOfType<String>(json, r'groupId'),
      paymentType: InvoiceDtoPaymentTypeEnum.fromJson(json[r'paymentType']),
      paid: mapValueOfType<double>(json, r'paid'),
      payments: PaymentDto.listFromJson(json[r'payments']) ?? const [],
      gnotionNihii: mapValueOfType<String>(json, r'gnotionNihii'),
      gnotionSsin: mapValueOfType<String>(json, r'gnotionSsin'),
      gnotionLastName: mapValueOfType<String>(json, r'gnotionLastName'),
      gnotionFirstName: mapValueOfType<String>(json, r'gnotionFirstName'),
      gnotionCdHcParty: mapValueOfType<String>(json, r'gnotionCdHcParty'),
      invoicePeriod: mapValueOfType<int>(json, r'invoicePeriod'),
      careProviderType: mapValueOfType<String>(json, r'careProviderType'),
      internshipNihii: mapValueOfType<String>(json, r'internshipNihii'),
      internshipSsin: mapValueOfType<String>(json, r'internshipSsin'),
      internshipLastName: mapValueOfType<String>(json, r'internshipLastName'),
      internshipFirstName: mapValueOfType<String>(json, r'internshipFirstName'),
      internshipCdHcParty: mapValueOfType<String>(json, r'internshipCdHcParty'),
      internshipCbe: mapValueOfType<String>(json, r'internshipCbe'),
      supervisorNihii: mapValueOfType<String>(json, r'supervisorNihii'),
      supervisorSsin: mapValueOfType<String>(json, r'supervisorSsin'),
      supervisorLastName: mapValueOfType<String>(json, r'supervisorLastName'),
      supervisorFirstName: mapValueOfType<String>(json, r'supervisorFirstName'),
      supervisorCdHcParty: mapValueOfType<String>(json, r'supervisorCdHcParty'),
      supervisorCbe: mapValueOfType<String>(json, r'supervisorCbe'),
      error: mapValueOfType<String>(json, r'error'),
      encounterLocationName: mapValueOfType<String>(json, r'encounterLocationName'),
      encounterLocationNihii: mapValueOfType<String>(json, r'encounterLocationNihii'),
      encounterLocationNorm: mapValueOfType<int>(json, r'encounterLocationNorm'),
      longDelayJustification: mapValueOfType<int>(json, r'longDelayJustification'),
      correctiveInvoiceId: mapValueOfType<String>(json, r'correctiveInvoiceId'),
      correctedInvoiceId: mapValueOfType<String>(json, r'correctedInvoiceId'),
      creditNote: mapValueOfType<bool>(json, r'creditNote'),
      creditNoteRelatedInvoiceId: mapValueOfType<String>(json, r'creditNoteRelatedInvoiceId'),
      idDocument: IdentityDocumentReaderDto.fromJson(json[r'idDocument']),
      cancelReason: mapValueOfType<String>(json, r'cancelReason'),
      cancelDate: mapValueOfType<int>(json, r'cancelDate'),
      options: mapCastOfType<String, String>(json, r'options')!,
      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;
}