export interface ListResponseDTO<T> {
  page: number;
  perpage: number;
  totalpages: number;
  totalitems: number;
  items: T[];
}

export const IsResponseAListDTO = <T>(response: any): response is ListResponseDTO<T> => {
  return (
    typeof response === "object" &&
    response !== null &&
    Object.prototype.hasOwnProperty.call(response, "totalitems")
  );
};

export const existsMoreReponsePages = <T>(response: any): response is ListResponseDTO<T> => {
  return IsResponseAListDTO(response) && response.page + 1 < response.totalpages;
};
