export type CardNumber = string; export type CardVerificationCode = string; export type ExpirationMonth = number; export type ExpirationYear = number; export type CreditCardInfo = {cardNumber: CardNumber, cardVerificationCode: CardVerificationCode, expirationMonth: ExpirationMonth, expirationYear: ExpirationYear}; export type UpdateApiV2UserCustomerAccountCreditCardInfoArgs = {body: CreditCardInfo}; export type UpdateApiV2UserCustomerAccountCreditCardInfoOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Save user credit card info * * PUT /v2/user/customer/account/creditCardInfo */ export const updateApiV2UserCustomerAccountCreditCardInfo = async (args: UpdateApiV2UserCustomerAccountCreditCardInfoArgs, options?: UpdateApiV2UserCustomerAccountCreditCardInfoOptions) => { const {baseUrl = "https://api.beezup.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v2/user/customer/account/creditCardInfo${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 };