export type OcapiV1LoyaltyMembersUpdateMemberPasswordUpdate = {password: string, currentPassword: string}; export type UpdateApiOcapiV1MembersCurrentCredentialsPasswordArgs = {loyaltySessionToken?: string | undefined, 'Connect-Region-Code'?: string | undefined, body: OcapiV1LoyaltyMembersUpdateMemberPasswordUpdate}; export type UpdateApiOcapiV1MembersCurrentCredentialsPasswordOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Updates the password of the currently authenticated member * * PUT /ocapi/v1/members/current/credentials/password */ export const updateApiOcapiV1MembersCurrentCredentialsPassword = async (args: UpdateApiOcapiV1MembersCurrentCredentialsPasswordArgs, options: UpdateApiOcapiV1MembersCurrentCredentialsPasswordOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.loyaltySessionToken != null) headers.set("loyaltySessionToken", String(args.loyaltySessionToken)) if (args['Connect-Region-Code'] != null) headers.set("Connect-Region-Code", String(args['Connect-Region-Code'])) const url = `${baseUrl.replace(/\/+$/, '')}/ocapi/v1/members/current/credentials/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 };