fromJson static method

Lead? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static Lead? 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'leadProviderName'),
          'Required key "Lead[leadProviderName]" is missing from JSON.');
      assert(json[r'leadProviderName'] != null,
          'Required key "Lead[leadProviderName]" has a null value in JSON.');
      assert(json.containsKey(r'uuid'),
          'Required key "Lead[uuid]" is missing from JSON.');
      assert(json[r'uuid'] != null,
          'Required key "Lead[uuid]" has a null value in JSON.');
      assert(json.containsKey(r'companyUUID'),
          'Required key "Lead[companyUUID]" is missing from JSON.');
      assert(json[r'companyUUID'] != null,
          'Required key "Lead[companyUUID]" has a null value in JSON.');
      assert(json.containsKey(r'isTest'),
          'Required key "Lead[isTest]" is missing from JSON.');
      assert(json[r'isTest'] != null,
          'Required key "Lead[isTest]" has a null value in JSON.');
      assert(json.containsKey(r'status'),
          'Required key "Lead[status]" is missing from JSON.');
      assert(json[r'status'] != null,
          'Required key "Lead[status]" has a null value in JSON.');
      assert(json.containsKey(r'createdAt'),
          'Required key "Lead[createdAt]" is missing from JSON.');
      assert(json[r'createdAt'] != null,
          'Required key "Lead[createdAt]" has a null value in JSON.');
      assert(json.containsKey(r'updatedAt'),
          'Required key "Lead[updatedAt]" is missing from JSON.');
      assert(json[r'updatedAt'] != null,
          'Required key "Lead[updatedAt]" has a null value in JSON.');
      return true;
    }());

    return Lead(
      leadProviderName: mapValueOfType<String>(json, r'leadProviderName')!,
      personalInformation:
          LeadPersonalInformation.fromJson(json[r'personalInformation']),
      personalReferenceInformation:
          LeadPersonalReferenceInformationJson.fromJson(
              json[r'personalReferenceInformation']),
      loanInformation:
          LeadLoanInformationJson.fromJson(json[r'loanInformation']),
      mortgageInformation:
          LeadMortgageInformationJson.fromJson(json[r'mortgageInformation']),
      creditCardInformation: LeadCreditCardInformationJson.fromJson(
          json[r'creditCardInformation']),
      savingsInformation:
          LeadSavingsInformationJson.fromJson(json[r'savingsInformation']),
      creditInformation:
          LeadCreditInformationJson.fromJson(json[r'creditInformation']),
      financialInformation:
          LeadFinancialInformation.fromJson(json[r'financialInformation']),
      employmentInformation: LeadEmploymentInformationJson.fromJson(
          json[r'employmentInformation']),
      legalInformation:
          LeadLegalInformationJson.fromJson(json[r'legalInformation']),
      educationInformation: LeadEducationInformationJson.fromJson(
          json[r'educationInformation']),
      coApplicantInformation: LeadCoApplicantInformationJson.fromJson(
          json[r'coApplicantInformation']),
      healthInformation:
          LeadHealthInformationJson.fromJson(json[r'healthInformation']),
      identificationInformation: LeadIdentificationInformationJson.fromJson(
          json[r'identificationInformation']),
      autoInsuranceInformation: LeadAutoInsuranceInformationJson.fromJson(
          json[r'autoInsuranceInformation']),
      refinanceLoans: LeadRefinanceLoanInformationJson.listFromJson(
          json[r'refinanceLoans']),
      clientTags: json[r'clientTags'] == null
          ? const {}
          : (json[r'clientTags'] as Map<String, dynamic>).map((k, v) =>
              MapEntry(
                  k,
                  v == null
                      ? const <String>[]
                      : (v as List)
                          .map((value) => value as String)
                          .toList(growable: false))),
      sessionInformation:
          LeadSessionInformationJson.fromJson(json[r'sessionInformation']),
      leadActions: LeadAction.listFromJson(json[r'leadActions']),
      uuid: mapValueOfType<String>(json, r'uuid')!,
      companyUUID: mapValueOfType<String>(json, r'companyUUID')!,
      sessionUuid: mapValueOfType<String>(json, r'sessionUuid'),
      deviceId: mapValueOfType<String>(json, r'deviceId'),
      referralCompanyUuid:
          mapValueOfType<String>(json, r'referralCompanyUuid'),
      trackingUuid: mapValueOfType<String>(json, r'trackingUuid'),
      partnerUserId: mapValueOfType<String>(json, r'partnerUserId'),
      isTest: mapValueOfType<bool>(json, r'isTest')!,
      status: LeadActionType.fromJson(json[r'status'])!,
      createdAt: mapValueOfType<String>(json, r'createdAt')!,
      updatedAt: mapValueOfType<String>(json, r'updatedAt')!,
    );
  }
  return null;
}