export type ChangePasswordModel = {OldPassword: string, NewPassword: string}; export type UpdateApiApiV10AccountsPasswordArgs = {body: ChangePasswordModel}; export type UpdateApiApiV10AccountsPasswordOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * PUT /api/v1.0/accounts/password */ export const updateApiApiV10AccountsPassword = async (args: UpdateApiApiV10AccountsPasswordArgs, options?: UpdateApiApiV10AccountsPasswordOptions) => { const {baseUrl = "https://api.flipdish.co", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1.0/accounts/password${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 };