import routes from "@/routes";
import { getAuthHeaders } from "../utils";

interface Payload {
  token: string;
}

export interface PayloadGet extends Payload {
  productKey: string;
}

interface ResponseGetSuccess {
  status: string;
  type: string;
  active: boolean;
}

interface ResponseGetError {
  status: string;
  message: string;
}

export type ResponseGet = ResponseGetSuccess | ResponseGetError;

export const createRequest = ({ token, productKey }: PayloadGet): Request => {
  const url = new URL(routes.server.dApiCheckProductPurchased(productKey));
  return new Request(url, { method: "GET", headers: getAuthHeaders(token) });
};
