export type PaymentMethodType = 'card'; export type SetDefaultPaymentMethodSchema = {type: PaymentMethodType, provider_id: string}; export type UpdateApiApiV3TeamsTeamIdCustomerDefaultPaymentMethodArgs = {team_id: string, body: SetDefaultPaymentMethodSchema}; export type UpdateApiApiV3TeamsTeamIdCustomerDefaultPaymentMethodOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set customer default payment method * * PUT /api/v3/teams/{team_id}/customer/default-payment-method */ export const updateApiApiV3TeamsTeamIdCustomerDefaultPaymentMethod = async (args: UpdateApiApiV3TeamsTeamIdCustomerDefaultPaymentMethodArgs, options?: UpdateApiApiV3TeamsTeamIdCustomerDefaultPaymentMethodOptions) => { const {baseUrl = "https://codemagic.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("x-auth-token", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/teams/${encodeURIComponent(String(args.team_id))}/customer/default-payment-method${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 };