export type QPilotCoreModelsDtoRequestsVaultCardDetails = {number: string, cvv: string, expiryMonth: string, expiryYear: string, brand?: (string | null) | undefined, lastFourDigits?: (string | null) | undefined}; export type QPilotCoreModelsDtoRequestsVaultBillingAddress = {firstName?: (string | null) | undefined, lastName?: (string | null) | undefined, address1?: (string | null) | undefined, city?: (string | null) | undefined, province?: (string | null) | undefined, zip?: (string | null) | undefined, country?: (string | null) | undefined}; export type QPilotCoreModelsDtoRequestsVaultCardRequest = {card: QPilotCoreModelsDtoRequestsVaultCardDetails, billingAddress: QPilotCoreModelsDtoRequestsVaultBillingAddress}; export type CreateApiSitesSiteIdCustomersCustomerExternalIdPaymentMethodsVaultArgs = {siteId: number, customerExternalId: string, body: QPilotCoreModelsDtoRequestsVaultCardRequest}; export type CreateApiSitesSiteIdCustomersCustomerExternalIdPaymentMethodsVaultOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Vault encrypted card data and tokenize on the site's payment gateway * * POST /Sites/{siteId}/Customers/{customerExternalId}/PaymentMethods/vault */ export const createApiSitesSiteIdCustomersCustomerExternalIdPaymentMethodsVault = async (args: CreateApiSitesSiteIdCustomersCustomerExternalIdPaymentMethodsVaultArgs, options?: CreateApiSitesSiteIdCustomersCustomerExternalIdPaymentMethodsVaultOptions) => { const {baseUrl = "https://api.qpilot.cloud", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/Sites/${encodeURIComponent(String(args.siteId))}/Customers/${encodeURIComponent(String(args.customerExternalId))}/PaymentMethods/vault${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 undefined };