export type CreateApiOppsV1ApiCreateArgs = {Authorization: string, api_key: string, body: string}; export type CreateApiOppsV1ApiCreateOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create contract opportunity * * POST /opps/v1/api/create */ export const createApiOppsV1ApiCreate = async (args: CreateApiOppsV1ApiCreateArgs, options: CreateApiOppsV1ApiCreateOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/*") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.api_key != null) query.append("api_key", String(args.api_key)) const url = `${baseUrl.replace(/\/+$/, '')}/opps/v1/api/create${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 res.blob() };