fromJson static method

EmailTemplateRenderErrorResponse? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static EmailTemplateRenderErrorResponse? 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 "EmailTemplateRenderErrorResponse[id]" is missing from JSON.');
      assert(json[r'id'] != null, 'Required key "EmailTemplateRenderErrorResponse[id]" has a null value in JSON.');
      assert(json.containsKey(r'tenantId'), 'Required key "EmailTemplateRenderErrorResponse[tenantId]" is missing from JSON.');
      assert(json[r'tenantId'] != null, 'Required key "EmailTemplateRenderErrorResponse[tenantId]" has a null value in JSON.');
      assert(json.containsKey(r'customTemplateId'), 'Required key "EmailTemplateRenderErrorResponse[customTemplateId]" is missing from JSON.');
      assert(json[r'customTemplateId'] != null, 'Required key "EmailTemplateRenderErrorResponse[customTemplateId]" has a null value in JSON.');
      assert(json.containsKey(r'error'), 'Required key "EmailTemplateRenderErrorResponse[error]" is missing from JSON.');
      assert(json[r'error'] != null, 'Required key "EmailTemplateRenderErrorResponse[error]" has a null value in JSON.');
      assert(json.containsKey(r'count'), 'Required key "EmailTemplateRenderErrorResponse[count]" is missing from JSON.');
      assert(json[r'count'] != null, 'Required key "EmailTemplateRenderErrorResponse[count]" has a null value in JSON.');
      assert(json.containsKey(r'createdAt'), 'Required key "EmailTemplateRenderErrorResponse[createdAt]" is missing from JSON.');
      assert(json[r'createdAt'] != null, 'Required key "EmailTemplateRenderErrorResponse[createdAt]" has a null value in JSON.');
      assert(json.containsKey(r'lastOccurredAt'), 'Required key "EmailTemplateRenderErrorResponse[lastOccurredAt]" is missing from JSON.');
      assert(json[r'lastOccurredAt'] != null, 'Required key "EmailTemplateRenderErrorResponse[lastOccurredAt]" has a null value in JSON.');
      return true;
    }());

    return EmailTemplateRenderErrorResponse(
      id: mapValueOfType<String>(json, r'id')!,
      tenantId: mapValueOfType<String>(json, r'tenantId')!,
      customTemplateId: mapValueOfType<String>(json, r'customTemplateId')!,
      error: mapValueOfType<String>(json, r'error')!,
      count: mapValueOfType<double>(json, r'count')!,
      createdAt: mapDateTime(json, r'createdAt', r'')!,
      lastOccurredAt: mapDateTime(json, r'lastOccurredAt', r'')!,
    );
  }
  return null;
}