export type CreateApiVideoOnDemandEligibilityArgs = {Authorization: string, UserProfileId?: number | undefined, SiteId: number}; export type CreateApiVideoOnDemandEligibilityOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Callback registered with the live_stream API to ensure that a user is eligible to view the video on demand content * * POST /video_on_demand/eligibility */ export const createApiVideoOnDemandEligibility = async (args: CreateApiVideoOnDemandEligibilityArgs, options?: CreateApiVideoOnDemandEligibilityOptions) => { const {baseUrl = "https://api.mindbodyonline.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.UserProfileId != null) headers.set("UserProfileId", String(args.UserProfileId)) if (args.SiteId != null) headers.set("SiteId", String(args.SiteId)) const url = `${baseUrl.replace(/\/+$/, '')}/video_on_demand/eligibility${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };