fromJson static method

LeadEventResponse? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static LeadEventResponse? 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'nextUrl'),
          'Required key "LeadEventResponse[nextUrl]" is missing from JSON.');
      assert(json[r'nextUrl'] != null,
          'Required key "LeadEventResponse[nextUrl]" has a null value in JSON.');
      assert(json.containsKey(r'paginationToken'),
          'Required key "LeadEventResponse[paginationToken]" is missing from JSON.');
      assert(json[r'paginationToken'] != null,
          'Required key "LeadEventResponse[paginationToken]" has a null value in JSON.');
      assert(json.containsKey(r'shouldContinuePolling'),
          'Required key "LeadEventResponse[shouldContinuePolling]" is missing from JSON.');
      assert(json[r'shouldContinuePolling'] != null,
          'Required key "LeadEventResponse[shouldContinuePolling]" has a null value in JSON.');
      assert(json.containsKey(r'data'),
          'Required key "LeadEventResponse[data]" is missing from JSON.');
      assert(json[r'data'] != null,
          'Required key "LeadEventResponse[data]" has a null value in JSON.');
      return true;
    }());

    return LeadEventResponse(
      nextUrl: mapValueOfType<String>(json, r'nextUrl')!,
      paginationToken: mapValueOfType<String>(json, r'paginationToken')!,
      shouldContinuePolling:
          mapValueOfType<bool>(json, r'shouldContinuePolling')!,
      data: LeadEvent.listFromJson(json[r'data']),
    );
  }
  return null;
}