export type BillingCycle = 'monthly' | 'yearly'; export type UpgradeSubscriptionRequest = {billingCycle: BillingCycle, successUrl: string, cancelUrl: string}; export type CreateApiApiUserSubscriptionUpgradeArgs = {body: UpgradeSubscriptionRequest}; export type CreateApiApiUserSubscriptionUpgradeOptions = {baseUrl?: string | undefined, ApiKeyAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upgrade subscription * * POST /api/user/subscription/upgrade * * Also accepts auth: JWTAuthentication, JWTHttpHeaderAuthentication, OAuth2 */ export const createApiApiUserSubscriptionUpgrade = async (args: CreateApiApiUserSubscriptionUpgradeArgs, options?: CreateApiApiUserSubscriptionUpgradeOptions) => { const {baseUrl = "https://studio.edgeimpulse.com/v1", fetch: fetchFn = fetch, ApiKeyAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyAuthentication !== undefined) headers.set("x-api-key", ApiKeyAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/api/user/subscription/upgrade${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };