export type CreateApiMembershipUserIdPlanPlanIdArgs = {user_id: string, plan_id: number, body: {expiration_date: string, addons?: Array<{addon_id: number}> | undefined}}; export type CreateApiMembershipUserIdPlanPlanIdOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Extend user's plan expiration * * POST /membership/{user_id}/plan/{plan_id} */ export const createApiMembershipUserIdPlanPlanId = async (args: CreateApiMembershipUserIdPlanPlanIdArgs, options?: CreateApiMembershipUserIdPlanPlanIdOptions) => { const {baseUrl = "https://api.zumba.com", fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/membership/${encodeURIComponent(String(args.user_id))}/plan/${encodeURIComponent(String(args.plan_id))}${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 };