import 'server-only'; import Model, { ModelError } from './model'; import type { MarketingPreferences, PasswordResetUpdateParams as PasswordResetUpdateParams, RegisterResponse, SessionsResponse, UserCreateParams, UserUpdateSnakeParams } from './user.types'; import { SavedSearch } from '../../providers/search-context'; export * from './user.types'; export default class User extends Model { #private; static currentUser: User | undefined; sessionData: SessionsResponse | null; /** * This will return the currently signed in user if it is present. * * The Session object returned by getServerSession from next-auth must be passed. * * @example * ```ts * const session = await getServerSession(authOptions); * const user = await User.current(session); * ``` */ static current(session: { encryptedCookieToken: string | undefined; }): Promise; static allowedUserTypes: string[]; /** * Creates a new user session and instantiates and returns a new User. * * Returns `null` if sign in was unsuccessful. * * @example * ```ts * const user = await User.signIn({ email: 'myemail@example.com', password: 'abc123' }); * ``` */ static signIn({ email, password, }: { email: string; password: string; }): Promise; /** * Creates a new user and corresponding lead. Does not sign the user in. * * @example * ```ts * await User.register({ * email: 'myemail@example.com', * password: 'abc123', * passwordConfirmation: 'abc123', * firstName: 'Testuser', * lastName: 'Testuser', * agencyId: 12345, * optInMarketing: false, * optInTerms: true, * }); * ``` * * User registration requires a Bearer token (app verification) via production * users api, regardless of the environement. * This is handled in the `users-api-user-helper.ts`. */ static register({ email, password, passwordConfirmation, firstName, lastName, optInMarketing, optInTerms, optInUrl, telHome, streetAddress, address2, town, county, postcode, isSalesApplicant, isLettingsApplicant, isVendor, isLandlord, }: UserCreateParams): Promise; /** * Front end user session verification requires a Bearer token (app verification) * via staging users api if in a staging environment. This differs from other * flows that always require a Bearer token from production, regardless of * environment. * This is handled in the `users-api-session-helper.ts`. */ static verifySession(encryptedCookieToken: string): Promise; static passwordResetCreate(params: { email: string; }): Promise<{ message: string | null; errors: ModelError[] | null; }>; static passwordResetUpdate(params: PasswordResetUpdateParams): Promise<{ message: null; errors: { message: string; }[]; } | { message: null; errors: { status: number; message: string; }[]; } | { message: string; errors: null; }>; addSavedProperty(id: number | null): Promise; removeSavedProperty(id: number | null): Promise; update(params: UserUpdateSnakeParams): Promise<{ response: null; errors: string[]; } | { response: import("./user.types").UserUpdateResponse; errors: null; }>; updateMarketingPreferences(preferences: MarketingPreferences): Promise<{ response: null; errors: { status: number; }[]; } | { response: import("./user.types").MarketingPreferencesResponse; errors: null; }>; addSavedSearch({ channel, searchFragment, placeId, }: { /** Either 'sales' or 'lettings' */ channel: string; /** The search path, e.g. from-3-bed/up-to-5-bed/from-300000/up-to-500000 */ searchFragment: string; placeId?: string | null; }): Promise<{ message?: string; search?: { sales_search?: SavedSearch; lettings_search?: SavedSearch; }; error?: { status: number; }; }>; removeSavedSearch(id: number): Promise<{ message?: string; search?: { sales_search?: SavedSearch; lettings_search?: SavedSearch; }; error?: { status: number; }; }>; updateSavedSearch(id: number, updatedSearch: SavedSearch): Promise<{ message?: string; search?: { sales_search?: SavedSearch; lettings_search?: SavedSearch; }; error?: { status: number; }; }>; constructor({ sessionData }: { sessionData: SessionsResponse | null; }); get firstName(): string | null; get lastName(): string | null; get telHome(): string | null; get telMobile(): string | null; get email(): string | null; get streetAddress(): string | null; get address2(): string | null; get postcode(): string | null; get town(): string | null; get county(): string | null; get isLandlord(): boolean; get isSalesApplicant(): boolean; get isVendor(): boolean; get isLettingsApplicant(): boolean; get encryptedCookieToken(): string | null; get bearerToken(): string | null; get refreshToken(): string | null; get tokenExpiry(): string | null; get id(): number | null; get savedProperties(): any | null; get savedSearches(): any | null; get displayAddress(): string | null; get isOptedInForMarketing(): boolean; get optedInForMarketingAt(): string | null; } //# sourceMappingURL=user.d.ts.map