export type GetApiV1StripePreviewPlanIdArgs = {plan_id: number, country?: string | undefined, vat?: string | undefined, product?: string | undefined, period?: boolean | undefined, credits?: number | undefined, 'x-api-key': string}; export type GetApiV1StripePreviewPlanIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get invoice total preview * * GET /v1/stripe/preview/{plan_id} */ export const getApiV1StripePreviewPlanId = async (args: GetApiV1StripePreviewPlanIdArgs, options?: GetApiV1StripePreviewPlanIdOptions) => { const {baseUrl = "https://api.mailreach.co/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.country != null) query.append("country", String(args.country)) if (args.vat != null) query.append("vat", String(args.vat)) if (args.product != null) query.append("product", String(args.product)) if (args.period != null) query.append("period", String(args.period)) if (args.credits != null) query.append("credits", String(args.credits)) if (args['x-api-key'] != null) headers.set("x-api-key", String(args['x-api-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/stripe/preview/${encodeURIComponent(String(args.plan_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };