UNPKG

alise-api

Version:

A wrapper around Alise internal API.

88 lines (77 loc) 3.36 kB
declare class Account { establishment: string; firstName: string; lastName: string; email: string; phoneNumber: string; faxNumber: string; address: string; balance: number; estimatedAt: Date; constructor(establishment: string, firstName: string, lastName: string, email: string, phoneNumber: string, faxNumber: string, address: string, balance: number, estimatedAt: Date); } declare class BookingDay { private token; identifier: string | null; booked: boolean; canBook: boolean; date?: Date; constructor(token: string, identifier: string | null, booked: boolean, canBook: boolean, date?: Date); /** * Books or unbooks the current day. * @param quantity - The number of bookings to update (default is 1). * @returns {Promise<BookingDay>} - A new instance of BookingDay with updated booking state. */ book(quantity?: number): Promise<BookingDay>; } declare class DayMenu { date: Date; lunch: Array<string>; dinner: Array<string>; constructor(date: Date, lunch: Array<string>, dinner: Array<string>); } interface AuthCredentials { /** PHPSESSID */ token: string; /** Username used for authentication */ username: string | null; /** Password used for authentication */ password: string | null; } interface ConnectionHistoryEvent { label: string; date: Date; } interface FinancialHistoryEvent { label: string; date: Date; amount: number; } declare class Client { private credentials; account?: Account | undefined; constructor(credentials: AuthCredentials, account?: Account | undefined); bookDay(identifier: string, quantity?: number, cancel?: boolean): Promise<BookingDay>; getBarcode(): Promise<Blob>; getBookings(): Promise<Array<BookingDay>>; getConnectionsHistory(): Promise<Array<ConnectionHistoryEvent>>; getFinancialHistory(): Promise<Array<FinancialHistoryEvent>>; getInformations(): Promise<Account>; getWeeklyMenu(): Promise<Array<DayMenu>>; } declare const authenticateWithCredentials: (username: string, password: string, site: string, remember?: boolean, minimalist?: boolean) => Promise<Client>; declare function findBetween(input: string, start: string, end: string): Array<string>; interface RequestOptions { method?: "GET" | "POST" | "PUT" | "DELETE"; path?: string; body?: Record<string, string>; headers?: Record<string, string>; } declare const getAccountInformations: (token: string) => Promise<Account>; declare const getConnectionsHistory: (token: string) => Promise<Array<ConnectionHistoryEvent>>; declare const getFinancialHistory: (token: string) => Promise<Array<FinancialHistoryEvent>>; declare const getBookings: (token: string) => Promise<Array<BookingDay>>; declare const updateBook: (token: string, identifier: string, quantity?: number, cancel?: boolean) => Promise<boolean>; declare const getBarcode: (token: string) => Promise<Blob>; declare const getWeeklyMenu: (token: string) => Promise<Array<DayMenu>>; export { Account, type AuthCredentials, BookingDay, Client, type ConnectionHistoryEvent, type FinancialHistoryEvent, type RequestOptions, authenticateWithCredentials, findBetween, getAccountInformations, getBarcode, getBookings, getConnectionsHistory, getFinancialHistory, getWeeklyMenu, updateBook };