create<T, E> static method

ApiParserResponse<T, E> create<T, E>(
  1. ParserResponse<T, E> response
)

Implementation

static ApiParserResponse<T, E> create<T, E>(ParserResponse<T, E> response) {
  if (response.errors.isNotEmpty) {
    return ApiParserErrorResponse(response.errors);
  } else if (response.data != null) {
    if (response is ParserResponseWithPaginationEntity) {
      return ApiParserSuccessResponse(
        response.data as T,
        pagination: (response as ParserResponseWithPaginationEntity).pagination,
      );
    } else {
      return ApiParserSuccessResponse(response.data as T);
    }
  }
  return ApiParserEmptyResponse();
}