export type CreateApiCollectionsCollectionIdLinkedRegistrationsRelationshipsArgs = {collection_id: string, body: Record}; export type CreateApiCollectionsCollectionIdLinkedRegistrationsRelationshipsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Link Registrations to Collection * * POST /collections/{collection_id}/linked_registrations/relationships/ */ export const createApiCollectionsCollectionIdLinkedRegistrationsRelationships = async (args: CreateApiCollectionsCollectionIdLinkedRegistrationsRelationshipsArgs, options?: CreateApiCollectionsCollectionIdLinkedRegistrationsRelationshipsOptions) => { const {baseUrl = "https://api.test.osf.io/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/collections/${encodeURIComponent(String(args.collection_id))}/linked_registrations/relationships/${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 (await res.json()) as unknown };