export type ApiTheme = {primaryColor: string, secondaryColor: string, hyperlinkColor: string, buttonColor: string}; export type UpdateApiV2AccountsAccountIdThemeArgs = {accountId: number, body: ApiTheme}; export type UpdateApiV2AccountsAccountIdThemeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Changes a theme for an account. * * PUT /v2/accounts/{accountId}/theme */ export const updateApiV2AccountsAccountIdTheme = async (args: UpdateApiV2AccountsAccountIdThemeArgs, options?: UpdateApiV2AccountsAccountIdThemeOptions) => { const {baseUrl = "https://api.dotdigital.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v2/accounts/${encodeURIComponent(String(args.accountId))}/theme${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 };