export type GetApiV2SubscriptionsIdArgs = {using_account_id?: number | undefined, 'x-customer-api-key'?: string | undefined}; export type GetApiV2SubscriptionsIdOptions = {baseUrl: string, defaultValue?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get a subscription by its ID * * GET /v2/subscriptions/{id} */ export const getApiV2SubscriptionsId = async (args: GetApiV2SubscriptionsIdArgs, options: GetApiV2SubscriptionsIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, defaultValue} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.using_account_id != null) query.append("using_account_id", String(args.using_account_id)) if (args['x-customer-api-key'] != null) headers.set("x-customer-api-key", String(args['x-customer-api-key'])) if (defaultValue !== undefined) headers.set("x-customer-api-key", defaultValue) const url = `${baseUrl.replace(/\/+$/, '')}/v2/subscriptions/${encodeURIComponent(String(args.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 };