export type CreateApiPettyCashesAdjustAccountCounterIdArgs = {counter_id: number, body: {currency: 'MYR' | 'SGD', amount: number, remarks?: string | undefined}}; export type CreateApiPettyCashesAdjustAccountCounterIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Adjust petty cash account * * POST /petty_cashes/adjust_account/{counter_id} */ export const createApiPettyCashesAdjustAccountCounterId = async (args: CreateApiPettyCashesAdjustAccountCounterIdArgs, options?: CreateApiPettyCashesAdjustAccountCounterIdOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") const url = `${baseUrl.replace(/\/+$/, '')}/petty_cashes/adjust_account/${encodeURIComponent(String(args.counter_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };