export type TaxObject = {id?: string | undefined, country?: string | undefined, taxCode1?: number | undefined, taxCode2?: number | undefined, taxCode3?: number | undefined, taxCode4?: number | undefined, taxCode5?: number | undefined, updatedAt?: string | undefined, createdAt?: string | undefined}; export type CreateApiTaxesArgs = {body: TaxObject}; export type CreateApiTaxesOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add new Tax * * POST /taxes */ export const createApiTaxes = async (args: CreateApiTaxesArgs, options?: CreateApiTaxesOptions) => { const {baseUrl = "https://api.test.bictorys.com/pay/v1", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyAuth !== undefined) headers.set("X-API-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/taxes${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 };