fromJson static method

LeadEvent? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static LeadEvent? 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'id'),
          'Required key "LeadEvent[id]" is missing from JSON.');
      assert(json[r'id'] != null,
          'Required key "LeadEvent[id]" has a null value in JSON.');
      assert(json.containsKey(r'leadUuid'),
          'Required key "LeadEvent[leadUuid]" is missing from JSON.');
      assert(json[r'leadUuid'] != null,
          'Required key "LeadEvent[leadUuid]" has a null value in JSON.');
      assert(json.containsKey(r'leadCreatedAt'),
          'Required key "LeadEvent[leadCreatedAt]" is missing from JSON.');
      assert(json[r'leadCreatedAt'] != null,
          'Required key "LeadEvent[leadCreatedAt]" has a null value in JSON.');
      assert(json.containsKey(r'eventType'),
          'Required key "LeadEvent[eventType]" is missing from JSON.');
      assert(json[r'eventType'] != null,
          'Required key "LeadEvent[eventType]" has a null value in JSON.');
      assert(json.containsKey(r'eventCreatedAt'),
          'Required key "LeadEvent[eventCreatedAt]" is missing from JSON.');
      assert(json[r'eventCreatedAt'] != null,
          'Required key "LeadEvent[eventCreatedAt]" has a null value in JSON.');
      assert(json.containsKey(r'supplySubAccountUuid'),
          'Required key "LeadEvent[supplySubAccountUuid]" is missing from JSON.');
      assert(json[r'supplySubAccountUuid'] != null,
          'Required key "LeadEvent[supplySubAccountUuid]" has a null value in JSON.');
      assert(json.containsKey(r'supplySubAccountName'),
          'Required key "LeadEvent[supplySubAccountName]" is missing from JSON.');
      assert(json[r'supplySubAccountName'] != null,
          'Required key "LeadEvent[supplySubAccountName]" has a null value in JSON.');
      assert(json.containsKey(r'isTest'),
          'Required key "LeadEvent[isTest]" is missing from JSON.');
      assert(json[r'isTest'] != null,
          'Required key "LeadEvent[isTest]" has a null value in JSON.');
      assert(json.containsKey(r'paginationTimestamp'),
          'Required key "LeadEvent[paginationTimestamp]" is missing from JSON.');
      assert(json[r'paginationTimestamp'] != null,
          'Required key "LeadEvent[paginationTimestamp]" has a null value in JSON.');
      return true;
    }());

    return LeadEvent(
      id: mapValueOfType<String>(json, r'id')!,
      leadUuid: mapValueOfType<String>(json, r'leadUuid')!,
      leadCreatedAt: mapDateTime(json, r'leadCreatedAt', r'')!,
      eventType: EventType.fromJson(json[r'eventType'])!,
      eventCreatedAt: mapDateTime(json, r'eventCreatedAt', r'')!,
      eventDeletedAt: mapDateTime(json, r'eventDeletedAt', r''),
      eventData: EventData.fromJson(json[r'eventData']),
      amountInCents: mapValueOfType<double>(json, r'amountInCents'),
      supplySubAccountUuid:
          mapValueOfType<String>(json, r'supplySubAccountUuid')!,
      supplySubAccountName:
          mapValueOfType<String>(json, r'supplySubAccountName')!,
      financialInstitutionUuid:
          mapValueOfType<String>(json, r'financialInstitutionUuid'),
      financialInstitutionName:
          mapValueOfType<String>(json, r'financialInstitutionName'),
      unifiedProductType: mapValueOfType<String>(json, r'unifiedProductType'),
      productType: ProductType.fromJson(json[r'productType']),
      productSubType: ProductSubType.fromJson(json[r'productSubType']),
      offerUuid: mapValueOfType<String>(json, r'offerUuid'),
      isTest: mapValueOfType<bool>(json, r'isTest')!,
      paginationTimestamp: mapDateTime(json, r'paginationTimestamp', r'')!,
    );
  }
  return null;
}