export type SupportedCarrier = {carrierId: string, displayName?: string | undefined}; export type ShippingRules = {supportedCarrierList?: Array | undefined}; export type UpdateApiV1ChannelShippingRulesArgs = {body: ShippingRules}; export type UpdateApiV1ChannelShippingRulesOptions = {baseUrl?: string | undefined, ChannelAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Shipping Rules * * PUT /v1/channel/shipping-rules */ export const updateApiV1ChannelShippingRules = async (args: UpdateApiV1ChannelShippingRulesArgs, options?: UpdateApiV1ChannelShippingRulesOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, ChannelAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ChannelAuth !== undefined) headers.set('authorization', `Bearer ${ChannelAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/channel/shipping-rules${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };