export type GetApiPublicV1NetworkCollectionIdTreeGraphArgs = {collectionId: number, commodityIds?: Array | undefined, commodityTreeId?: number | undefined, fetchParents?: boolean | undefined, tierLevel?: number | undefined}; export type GetApiPublicV1NetworkCollectionIdTreeGraphOptions = {baseUrl?: string | undefined, TokenAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get tree graph for a collection * * GET /public/v1/network/{collectionId}/tree-graph */ export const getApiPublicV1NetworkCollectionIdTreeGraph = async (args: GetApiPublicV1NetworkCollectionIdTreeGraphArgs, options?: GetApiPublicV1NetworkCollectionIdTreeGraphOptions) => { const {baseUrl = "https://api.prewave.com", fetch: fetchFn = fetch, TokenAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") for (const item of args.commodityIds ?? []) query.append("commodityIds", String(item)) if (args.commodityTreeId != null) query.append("commodityTreeId", String(args.commodityTreeId)) if (args.fetchParents != null) query.append("fetchParents", String(args.fetchParents)) if (args.tierLevel != null) query.append("tierLevel", String(args.tierLevel)) if (TokenAuthentication !== undefined) headers.set("X-Auth-Token", TokenAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/network/${encodeURIComponent(String(args.collectionId))}/tree-graph${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 res.blob() };