/// import { LibBookRecord, LibFuzzySearchResult, Library, LibraryFloor, LibrarySeat, LibrarySection, LibRoomBookRecord, LibRoomRes, SocketStatus } from "./models/home/library"; import { Course } from "./models/home/report"; import { Form } from "./models/home/assessment"; import { NewsSlice, NewsSubscription, ChannelTag } from "./models/news/news"; import { ValidReceiptTypes } from "./lib/sports"; import { Priority } from "./lib/cr"; import { CrTimetable, SearchCoursePriorityQuery, SearchParams } from "./models/cr/cr"; import { BankPaymentByMonth } from "./models/home/bank"; import { CalendarData } from "./models/schedule/calendar"; import { BookChapter } from "./models/home/reserves-lib"; import { Invoice } from "./models/home/invoice"; import { LoginError } from "./utils/error"; import { Classroom, ClassroomStateResult } from "./models/home/classroom"; import { CardTransactionType } from "./models/card/transaction"; import { CardRechargeType } from "./models/card/recharge"; export declare class InfoHelper { userId: string; password: string; /** * Mock account and password. * * Due to various reasons, consumers of this library might hope to get * some fake data, without literally making a request to the school * website. * * We make this possible by creating an internal mocking account. The * default userId and password of this account are both "8888", while you * can change this behavior by modifying `helper.MOCK`. * * After you have logged in with the mocking account, almost every * operation will respond with a fake value. * * You can easily get whether the user is using a mocking account by * invoking `helper.mocked()`. */ MOCK: string; /** * We consider an account to be mocked if its userId and password are both "8888". */ mocked: () => boolean; /** * Returns whether the user is graduate. * * We detect a user's graduation status through the fifth digit (index 4) of his/her student ID. * * That is, we think a user is graduate iff the fifth digit of his/her student ID is 2 or 3. */ graduate: () => boolean; /** * Invoked before logging in. * * Override this value to customize. */ clearCookieHandler: () => Promise; /** * Invoked when a login error occurs. * * Override this value to customize. */ loginErrorHook: ((e: LoginError) => any) | undefined; /** * Login with userId and password. */ login: (auth: { userId?: string; password?: string; }) => Promise; /** * Log out and clear fields `userId` and `password` of this `InfoHelper` instance */ logout: () => Promise; /** * THIS METHOD IS INTENDED FOR APP USE ONLY. * * ANY BREAKING CHANGES SHALL NOT BE DOCUMENTED. */ appStartUp: (platform: "ios" | "android") => Promise<{ bookingRecords: LibBookRecord[]; sportsReservationRecords: import("./models/home/sports").SportsReservationRecord[]; crTimetable: CrTimetable[]; balance: number; latestAnnounces: import("./models/app/announcement").Announcement[]; latestVersion: import("./models/app/version").Version; }>; appUsageStat: (usage: number) => Promise; getLatestAnnounces: () => Promise; getLatestVersion: (platform: "ios" | "android") => Promise; submitFeedback: (content: string, appversion: string, os: string, nickname: string, contact: string, phonemodel: string) => Promise; getFeedbackReplies: () => Promise; getWeChatGroupQRCodeContent: () => Promise; getPrivacyUrl: () => string; /** * Switch the language. * * This will affect the language of data returned from some APIs. * * @param lang either "zh" or "en" */ switchLang: (lang: "zh" | "en") => Promise; /** * Get the user's full name and email name (i.e. username for email * account) */ getUserInfo: () => Promise<{ fullName: string; emailName: string; }>; /** * A naive API that sends an email from the user's Tsinghua mail. * @param subject Subject of email * @param content Content of email * @param recipient Recipient of email. Sending an email to multiple * recipients is not supported yet. */ naiveSendMail: (subject: string, content: string, recipient: string) => Promise; /** * Get the school report of the user. * * @param bx a boolean indicating whether to contain only required and * restricted courses (and omit elective courses) * @param newGPA a boolean indicating whether to adopt the new GPA policy * @param flag switch between first degree (1), second degree (2) and * minor courses (3), defaults to 1 * * Note that `bx` takes effect only if `flag` equals to `1` */ getReport: (bx: boolean, newGPA: boolean, flag?: number) => Promise; /** * Get the assessment list of teaching evaluation. * * @return An array of courses. Each course is represented with a * three-element tuple, referring to name of course, whether * the course has been evaluated and the url of its evaluation * form (which can then be passed into `getAssessmentForm`. */ getAssessmentList: () => Promise<[string, boolean, string][]>; /** * Get the evaluation form of a course from its url. * @param url the corresponding form url to the course to evaluate */ getAssessmentForm: (url: string) => Promise
; /** * Submit the evaluation form. */ postAssessmentForm: (form: Form) => Promise; /** * Get the physical exam score of the user. * * @return Returns a [string, string][], where the first string refers to * the exam item, and the second refers to the exam score. */ getPhysicalExamResult: () => Promise<[string, string][]>; /** * Get all classroom buildings available for querying for classroom status. * * Note that you should use `searchName` from the returned struct for * future querying. */ getClassroomList: () => Promise; /** * Get the classroom state of specific classroom building and week number. * @param building a string representing the queried building * @param week a number representing the queried week number */ getClassroomState: (building: string, week: number) => Promise; /** * Get the list of invoices. * * This API is paginated. * * @param page page number, starting from 1 */ getInvoiceList: (page: number) => Promise<{ data: Invoice[]; count: number; }>; /** * Get the invoice PDF in base64 format. */ getInvoicePDF: (busNumber: string) => Promise; /** * Get the bank payment records of the user. * @param foundation whether to get bank payment result by 基金会 or not */ getBankPayment: (foundation?: boolean) => Promise; /** * Get the school calendar data. */ getCalendar: () => Promise; /** * Get the school calendar image url */ getCalendarImageUrl: (year: number, semester: "spring" | "autumn", lang: "zh" | "en") => Promise; /** * Get the current countdown notifications from INFO. */ getCountdown: () => Promise; /** * Get the dorm score image, in base64 format. * @param dormPassword password for myhome.tsinghua.edu.cn */ getDormScore: (dormPassword: string) => Promise; /** * Make an electricity recharge payment order, and get the pay-code of the * order. * * If you want to use the pay-code on mobile devices, the url link to the * Alipay payment page will be * `"alipayqr://platformapi/startapp?saId=10000007&qrcode=https%3A%2F%2Fqr.alipay.com%2F" + payCode` * * You can also call `genAlipayUrl(payCode)` in `dist/utils/alipay` to get * the Alipay url. * * @param money a number representing the amount of money to be paid * (in yuan, must be integer) */ getEleRechargePayCode: (money: number) => Promise; /** * Get the recent ele-recharge records. * * @return Returns `[string, string, string, string, string, string][]`, * where the six strings represent name, id, time, channel, value * and status respectively. */ getElePayRecord: () => Promise<[string, string, string, string, string, string][]>; /** * Get the current remainder of electricity. * * @return Returns a number. The return value can be NaN when the remainder * info cannot be parsed. */ getEleRemainder: () => Promise<{ remainder: number; updateTime: string; }>; /** * Reset dorm password. * * This method works on the basis that myhome.tsinghua.edu.cn can be logged * in with INFO account, and the dorm password can therefore be reset, * without the need of a original password. * * @param newPassword The new dorm password */ resetDormPassword: (newPassword: string) => Promise; getLibraryList: () => Promise; getLibrarySectionList: (libraryFloor: LibraryFloor, dateChoice: 0 | 1) => Promise; getLibraryFloorList: (library: Library, dateChoice: 0 | 1) => Promise; getLibrarySeatList: (librarySection: LibrarySection, dateChoice: 0 | 1) => Promise; toggleSocketState: (seatId: number, target: SocketStatus) => Promise; /** * Use this API to book library seats. */ bookLibrarySeat: (librarySeat: LibrarySeat, section: LibrarySection, dateChoice: 0 | 1) => Promise<{ status: number; msg: string; }>; /** * Use this API to get booking records. */ getBookingRecords: () => Promise; /** * Use this API to cancel booking. * @param id the `id` from `LibBookRecord` */ cancelBooking: (id: string) => Promise; /** * DEPRECATED. */ getLibraryRoomBookingCaptchaUrl: () => Promise; /** * Use this API to get the account number of current user. * * The account number is used to book rooms. */ getLibraryRoomAccNo: () => number; /** * Login cab.hs.lib.tsinghua.edu.cn */ loginLibraryRoomBooking: () => Promise; /** * Gets all available room information */ getLibraryRoomBookingInfoList: () => Promise; /** * Gets all available room resources * @param date yyyyMMdd * @param kindId * @return Returns a list of all available room resources of a specific * date, along with when and for whom each room is reserved. */ getLibraryRoomBookingResourceList: (date: string, kindId: number) => Promise; /** * Passes a student's name as keyword and returns the student's ID. * * FUZZY SEARCH IS NO LONGER SUPPORTED. Method name remains unchanged only * for compatability reasons. * * @param keyword a string that serves as the search keyword */ fuzzySearchLibraryId: (keyword: string) => Promise; /** * Performs a booking request of a library room. * * @param roomRes a `LibRoomRes` object referring to the room that is requested for booking * @param start the beginning time of booking, in format `yyyy-MM-dd HH:mm:SS` where `mm` should be a multiple of 5 and `SS` should be `00` * @param end the ending time of booking, in format `yyyy-MM-dd HH:mm:SS` where `mm` should be a multiple of 5 and `SS` should be `00` * @param memberList a list of strings */ bookLibraryRoom: (roomRes: LibRoomRes, start: string, end: string, memberList: number[]) => Promise; /** * Returns all active booking records. */ getLibraryRoomBookingRecord: () => Promise; /** * Cancels a specific library booking record. * @param uuid `uuid` of `LibRoomBookRecord` */ cancelLibraryRoomBooking: (uuid: string) => Promise; /** * Get the news list of all channels or a specific channel. * * This API is paginated. */ getNewsList: (page: number, length: number, channel?: ChannelTag) => Promise; /** * Search the news list with a keyword. * * This API is paginated. */ searchNewsList: (page: number, key: string, channel?: ChannelTag) => Promise; /** * Get all news subscription items. */ getNewsSubscriptionList: () => Promise; /** * Get all available news sources for subscription. */ getNewsSourceList: () => Promise<{ sourceId: string; sourceName: string; }[]>; /** * Get all available news channels for subscription. * @param needEnglish */ getNewsChannelList: (needEnglish: boolean) => Promise<{ id: ChannelTag; title: string; }[]>; /** * if channelId and sourceId is null or undefined at the same time, this function will terminate and return false. * @param channelId channel id * @param sourceId source id * @param keyword news keyword * @returns */ addNewsSubscription: (channelId?: ChannelTag, sourceId?: string, keyword?: string) => Promise; /** * Remove a news subscription. * @param subscriptionId */ removeNewsSubscription: (subscriptionId: string) => Promise; /** * Gets the news list by a specific subscription. * * This API is paginated. */ getNewsListBySubscription: (page?: number, subscriptionId?: string) => Promise; /** * Get the detailed news with the url provided. * @param url the url of the queried news * @return Returns `[string, string, string][]`, where the three `string`s * represent title, content and abstract respectively. */ getNewsDetail: (url: string) => Promise<[string, string, string]>; /** * Adds a specific piece of news to fav list. * @param news */ addNewsToFavor: (news: NewsSlice) => Promise; /** * Remove a specific piece of news from fav list. * @param news */ removeNewsFromFavor: (news: NewsSlice) => Promise; /** * if the page is out of range, the NewsSlice will be a 0 length array. * @param page page of favor list * @returns [array of NewsSlice,total pages] */ getFavorNewsList: (page: number) => Promise<[NewsSlice[], number]>; /** * Get the schedules of the user. * @return Returns `Schedule[]`, containing all the schedules(including * exams) of the user. */ getSchedule: () => Promise<{ schedule: import("./models/schedule/schedule").Schedule[]; calendar: CalendarData; }>; /** * Gets the timetable for course registration. */ getCrTimetable: () => Promise; /** * Gets the login captcha url for the course registration system. */ getCrCaptchaUrl: () => Promise; /** * Log in to the course registration system with the captcha. */ loginCr: (captcha: string) => Promise; /** * Get all semesters available for course registration. */ getCrAvailableSemesters: () => Promise; /** * Get the course plan of a given semester. * @param semester */ getCrCoursePlan: (semester: string) => Promise; /** * Search courses for registration remaining data * @param params */ searchCrRemaining: (params: SearchParams) => Promise; /** * Search primary courses * @param params */ searchCrPrimaryOpen: (params: SearchParams) => Promise; /** * Search courses for registration * @param params */ searchCrCourses: (params: SearchParams) => Promise; /** * Select a course. * @param semesterId semester id * @param priority "bx" | "xx" | "rx" | "ty" | "cx" * @param courseId course id * @param courseSeq course seq number * @param will 1 | 2 | 3 */ selectCourse: (semesterId: string, priority: Priority, courseId: string, courseSeq: string, will: 1 | 2 | 3) => Promise; /** * Delete a course * @param semesterId * @param courseId * @param courseSeq */ deleteCourse: (semesterId: string, courseId: string, courseSeq: string) => Promise; /** * Get all selected courses * @param semesterId */ getSelectedCourses: (semesterId: string) => Promise; /** * Change a will of a course * @param semesterId * @param courseId * @param courseSeq * @param will */ changeCourseWill: (semesterId: string, courseId: string, courseSeq: string, will: 1 | 2 | 3) => Promise; /** * Get current course registration stage * @param semesterId */ getCrCurrentStage: (semesterId: string) => Promise<{ stage: string; beginTime: string; endTime: string; }>; /** * Gets when is the latest course registration queue info released, and * when is the next time for release. * @param semesterId */ searchCoursePriorityMeta: (semesterId: string) => Promise<{ curr: string; next: string; }>; /** * Gets the course registration data for remaining position * @param semesterId * @param query */ searchCoursePriorityInformation: (semesterId: string, query: SearchCoursePriorityQuery) => Promise; /** * Gets course registration queue info * @param semesterId */ getQueueInfo: (semesterId: string) => Promise; /** * Cancel PF registration for a course * @param semesterId * @param courseId */ cancelCoursePF: (semesterId: string, courseId: string) => Promise; /** * Set PF mark for a course * @param semesterId * @param courseId */ setCoursePF: (semesterId: string, courseId: string) => Promise; /** * Gets all available sports resources. * * `gymId` and `itemId` can be found in `sportsIdInfoList` from `dist/lib/sports`. * * @param gymId * @param itemId * @param date yyyy-MM-dd */ getSportsResources: (gymId: string, itemId: string, date: string) => Promise; /** * Saves the phone number in the sports reservation system * @param phone */ updateSportsPhoneNumber: (phone: string) => Promise; /** * Gets the url to the captcha for sports reservation */ getSportsCaptchaUrl: () => string; /** * Makes a sports reservation and gets the alipay pay-code if payment is * required. * * If you want to use the pay-code on mobile devices, the url link to the * Alipay payment page will be * `"alipayqr://platformapi/startapp?saId=10000007&qrcode=https%3A%2F%2Fqr.alipay.com%2F" + payCode` * * You can also call `genAlipayUrl(payCode)` in `dist/utils/alipay` to get * the Alipay url. * * @param totalCost a number indicating the total cost of the reservation * @param phone a string representing the user's phone number * @param receiptTitle a string representing the title of the receipt, or `undefined` if a receipt is not needed * @param gymId a string representing the ID of the gym * @param itemId a string representing the ID of the item * @param date a string in the format of `yyyy-MM-dd` * @param captcha a string representing the captcha * @param resHashId a string representing the hash of the resource * @param skipPayment whether to skip payment (and pay later) * @return Returns a string representing the alipay payment code if payment is required, or `undefined` if no payment is needed. */ makeSportsReservation: (totalCost: number, phone: string, receiptTitle: ValidReceiptTypes | undefined, gymId: string, itemId: string, date: string, captcha: string, resHashId: string, skipPayment?: boolean) => Promise; /** * Gets all active sports reservation records. */ getSportsReservationRecords: () => Promise; /** * Make sports reservation payment with a payId. */ paySportsReservation: (payId: string, receiptTitle: ValidReceiptTypes | undefined) => Promise; /** * Cancel a sports reservation if payment has not been made * @param bookId a string representing the ID of the reservation */ unsubscribeSportsReservation: (bookId: string) => Promise; getGitNamespaces: (page: number) => Promise; getGitRecentProjects: (page: number) => Promise; getGitOwnedProjects: (name: string, page: number) => Promise; searchGitProjects: (search: string, page: number) => Promise; getGitStarredProjects: (page: number) => Promise; getGitProjectDetail: (id: number) => Promise; getGitProjectTree: (id: number, path: string, ref: string, page: number) => Promise; getGitProjectBranches: (id: number) => Promise; getGitProjectFileBlob: (id: number, sha: string) => Promise; renderGitMarkdown: (text: string) => Promise; searchReservesLib: (bookName: string, page?: number) => Promise; getReservesLibBookDetail: (bookId: string) => Promise; reservesLibDownloadChapters: (chapters: BookChapter[], setCompletion?: ((total: number, complete: number) => void) | undefined) => Promise; getDegreeProgramCompletion: () => Promise<{}>; getFullDegreeProgram: (degreeId?: number, skippedSet?: string[]) => Promise<{}>; getNetworkDetail: (year: number, month: number) => Promise; getOnlineDevices: () => Promise; getNetworkBalance: () => Promise; getScoreByCourseId: (courseId: string) => Promise; loginCampusCard: () => Promise; getCampusCardInfo: () => Promise; getCampusCardPhotoUrl: () => Promise; /** * Get the campus card transactions. * @param start YYYY-MM-DD * @param end YYYY-MM-DD * @param type -1 for all (1-3), 1 for consumption, 2 for recharge, 3 for subsidy, 0 for ALL (?) */ getCampusCardTransactions: (start: string, end: string, type: CardTransactionType) => Promise; changeCampusCardPassword: (oldPassword: string, newPassword: string) => Promise; modifyCampusCardMaxTransactionAmount: (transactionPassword: string, maxDailyAmount: number, maxOneTimeAmount: number) => Promise; reportCampusCardLoss: (transactionPassword: string) => Promise; cancelCampusCardLoss: (transactionPassword: string) => Promise; /** * Recharge the campus card. * @param amount in yuan * @param transactionPassword * @param type 0 for Bank Card, 1 for Alipay, 2 for Wechat Pay * @return Uri to request to complete the payment process, undefined for Bank */ rechargeCampusCard: (amount: number, transactionPassword: string, type: CardRechargeType) => Promise; } export declare class Water { id: string; num: string; num1: string; lid: string; address: string; phone: string; getUserInformation: (id: string) => Promise; getUserInformationAndStore: (id: string) => Promise; postWaterSubmission: (num: string, num1: string, lid: string) => Promise; }