export type GetApiApiV1RelationshipsArgs = {contentTypeId?: string | undefined, page?: number | undefined, per_page?: number | undefined}; export type GetApiApiV1RelationshipsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * GET /api/v1/relationships */ export const getApiApiV1Relationships = async (args: GetApiApiV1RelationshipsArgs, options: GetApiApiV1RelationshipsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.contentTypeId != null) query.append("contentTypeId", String(args.contentTypeId)) if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/relationships${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 (await res.json()) as unknown };