import routes from "@/routes"; import { getAuthHeaders } from "../utils"; interface Payload { token: string; } export interface PayloadGet extends Payload { placementKey: EPlacementKeys; } export enum EPlacementKeys { "aura.placement.main" = "aura.placement.main", "aura.placement.redesign.main" = "aura.placement.redesign.main", "aura.placement.email.marketing" = "aura.placement.email.marketing", "aura.placement.secret.discount" = "aura.placement.secret.discount", "aura.placement.palmistry.main" = "aura.placement.palmistry.main" } interface ResponseGetSuccess { paywall: IPaywall; } interface ResponseGetError { status: string; message: string; } export interface IPaywall { _id: string; key: string; name: string; products: IPaywallProduct[]; properties: IPaywallProperties[]; } export interface IPaywallProduct { _id: string; key: string; productId: string; name: string; priceId: string; type: string; description: string; discountPrice: null; discountPriceId: null; isDiscount: boolean; isFreeTrial: boolean; isTrial: boolean; price: number; trialDuration: number; trialPrice: number; trialPriceId: string; } interface IPaywallProperties { _id: string; key: string; value: string; } export type ResponseGet = ResponseGetSuccess | ResponseGetError; export const createRequestGet = ({ token, placementKey }: PayloadGet): Request => { const url = new URL(routes.server.getPaywallByPlacementKey(placementKey)); return new Request(url, { method: "GET", headers: getAuthHeaders(token) }); };