export type CustomRevenue = {timeframe: string, total: number}; export type CreateApiV3ContractsIdObligationObligationIdCustomRevenueArgs = {id: string, obligationId: string, body: Array}; export type CreateApiV3ContractsIdObligationObligationIdCustomRevenueOptions = {baseUrl?: string | undefined, customHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upsert obligation custom revenue * * POST /v3/contracts/{id}/obligation/{obligationId}/custom-revenue */ export const createApiV3ContractsIdObligationObligationIdCustomRevenue = async (args: CreateApiV3ContractsIdObligationObligationIdCustomRevenueArgs, options?: CreateApiV3ContractsIdObligationObligationIdCustomRevenueOptions) => { const {baseUrl = "https://integrators.prod.api.tabsplatform.com", fetch: fetchFn = fetch, customHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (customHeader !== undefined) headers.set("Authorization", customHeader) const url = `${baseUrl.replace(/\/+$/, '')}/v3/contracts/${encodeURIComponent(String(args.id))}/obligation/${encodeURIComponent(String(args.obligationId))}/custom-revenue${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 undefined };