export type Card = {card_id?: string | undefined, customer_id?: string | undefined, card_type_id: string, card_number: string, secondary_card_number?: string | undefined, valid_from?: string | undefined, valid_to?: string | undefined, store_id?: string | undefined, last_change?: string | undefined, state: 0 | 1}; export type UpdateApiCardsCardIdArgs = {'Accept-Language'?: string | undefined, card_id: string, body: {card: Card}}; export type UpdateApiCardsCardIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a card * * PUT /cards/{card_id} * * Also accepts auth: basicAuth */ export const updateApiCardsCardId = async (args: UpdateApiCardsCardIdArgs, options?: UpdateApiCardsCardIdOptions) => { const {baseUrl = "https://sandbox.crmcarecloud.com/webservice/rest-api/enterprise-interface/v1.0", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/cards/${encodeURIComponent(String(args.card_id))}${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 };