export type CreateApiApiV1ShippingMethodsArgs = {body: {isActive?: boolean | undefined, name?: string | undefined, project?: ({id: string} | null) | undefined, carrier?: ({credentials?: ({basic: {username: string, password: string}} | {bearer: {token: string}} | {oauthClientCredentials: {tokenUrl: string, username: string, password: string, audience?: string | undefined}}) | undefined, serviceUrl?: string | undefined, id?: string | undefined, product?: ({id?: string | undefined}) | undefined, shipmentType?: ('outbound' | 'return') | undefined}) | undefined, printers?: ({label?: {id: string} | undefined, document?: {id: string} | undefined}) | undefined, parcel?: ({defaultDimensions?: ({length?: ({value?: number | undefined, unit?: 'cm' | undefined}) | undefined, width?: ({value?: number | undefined, unit?: 'cm' | undefined}) | undefined, height?: ({value?: number | undefined, unit?: 'cm' | undefined}) | undefined}) | undefined, minimumWeight?: ({value?: number | undefined, unit?: 'kg' | undefined}) | undefined}) | undefined, sender?: ({name?: string | undefined, address?: string | undefined, city?: string | undefined, state?: string | undefined, zip?: string | undefined, country?: string | undefined, email?: string | undefined, phone?: string | undefined, contactPerson?: string | undefined}) | undefined}}; export type CreateApiApiV1ShippingMethodsOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create shipping method * * POST /api/v1/shippingMethods */ export const createApiApiV1ShippingMethods = async (args: CreateApiApiV1ShippingMethodsArgs, options?: CreateApiApiV1ShippingMethodsOptions) => { const {baseUrl = "https://xentral.xentral.biz", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/html") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/shippingMethods${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.text() };