export type PaymentMethodType = 'card'; export type PaymentMethodSchema = {type: PaymentMethodType, provider_id: string}; export type UpdateApiApiV3TeamsTeamIdSubscriptionsSubscriptionIdDefaultPaymentMethodArgs = {subscription_id: string, team_id: string, body: PaymentMethodSchema}; export type UpdateApiApiV3TeamsTeamIdSubscriptionsSubscriptionIdDefaultPaymentMethodOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set subscription default payment method * * PUT /api/v3/teams/{team_id}/subscriptions/{subscription_id}/default-payment-method */ export const updateApiApiV3TeamsTeamIdSubscriptionsSubscriptionIdDefaultPaymentMethod = async (args: UpdateApiApiV3TeamsTeamIdSubscriptionsSubscriptionIdDefaultPaymentMethodArgs, options?: UpdateApiApiV3TeamsTeamIdSubscriptionsSubscriptionIdDefaultPaymentMethodOptions) => { 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))}/subscriptions/${encodeURIComponent(String(args.subscription_id))}/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 };