fromJson static method

LeadPayout? fromJson(
  1. dynamic value
)

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

Implementation

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

    return LeadPayout(
      leadUuid: mapValueOfType<String>(json, r'leadUuid')!,
      bookedAt: mapDateTime(json, r'bookedAt', r'')!,
      payoutInCents: mapValueOfType<double>(json, r'payoutInCents'),
      uuid: mapValueOfType<String>(json, r'uuid'),
      deletedAt: mapDateTime(json, r'deletedAt', r''),
      supplySubAccountUuid:
          mapValueOfType<String>(json, r'supplySubAccountUuid')!,
      supplySubAccountName:
          mapValueOfType<String>(json, r'supplySubAccountName')!,
      financialInstitutionName:
          mapValueOfType<String>(json, r'financialInstitutionName'),
      financialInstitutionUuid:
          mapValueOfType<String>(json, r'financialInstitutionUuid'),
      unifiedProductType: mapValueOfType<String>(json, r'unifiedProductType'),
      productType: ProductType.fromJson(json[r'productType']),
      paginationTimestamp: mapDateTime(json, r'paginationTimestamp', r'')!,
    );
  }
  return null;
}