export type SupportedPaymentMethod = {paymentMethodId: string, displayName?: string | undefined}; export type PaymentRules = {supportedPaymentMethodList: Array}; export type UpdateApiV1ChannelPaymentRulesArgs = {body: PaymentRules}; export type UpdateApiV1ChannelPaymentRulesOptions = {baseUrl?: string | undefined, ChannelAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Payment Rules * * PUT /v1/channel/payment-rules */ export const updateApiV1ChannelPaymentRules = async (args: UpdateApiV1ChannelPaymentRulesArgs, options?: UpdateApiV1ChannelPaymentRulesOptions) => { 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/payment-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 };