export type GetApiProposalsApprovalReasonsArgs = {Trade?: string | undefined, TradeId?: number | undefined, Category?: string | undefined, CategoryId?: number | undefined}; export type GetApiProposalsApprovalReasonsOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve proposal approval reasons * * GET /proposals/ApprovalReasons */ export const getApiProposalsApprovalReasons = async (args: GetApiProposalsApprovalReasonsArgs, options?: GetApiProposalsApprovalReasonsOptions) => { const {baseUrl = "https://sb2api.servicechannel.com/v3", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.Trade != null) query.append("Trade", String(args.Trade)) if (args.TradeId != null) query.append("TradeId", String(args.TradeId)) if (args.Category != null) query.append("Category", String(args.Category)) if (args.CategoryId != null) query.append("CategoryId", String(args.CategoryId)) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/proposals/ApprovalReasons${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 undefined };