UNPKG

@re621/zestyapi

Version:

Comprehensive JS wrapper for e621.net API

49 lines (48 loc) 1.73 kB
import Endpoint, { SearchParams } from "../components/Endpoint"; import { FormattedResponse } from "../components/RequestQueue"; import APIUser, { APIUserLevel } from "../responses/APIUser"; export default class UsersEndpoint extends Endpoint<APIUser> { Level: typeof APIUserLevel; SearchOrder: typeof UserSearchOrder; protected searchParams: string[]; protected searchParamAliases: { name: string; email: string; }; /** * Fetches user data based on provided parameters * @param {UserSearchParams} params Search parameters * @returns {FormattedResponse<APIUser[]>} User data */ find(search?: UserSearchParams): Promise<FormattedResponse<APIUser>>; /** * Fetch user data based on the exact ID or name * @param {number | string} id User ID or name * @returns {FormattedResponse<APIUser>} User data */ get(id: string | number): Promise<FormattedResponse<APIUser>>; /** * Checks if the saved login credentials are correct or not. * Does not work with the AuthToken, since there is no username provided. * @returns {boolean} `true` if the user is logged in, `false` otherwise. */ isAuthenticated(): Promise<boolean>; } interface UserSearchParams extends SearchParams { level?: APIUserLevel | APIUserLevel[]; min_level?: APIUserLevel; max_level?: APIUserLevel; can_upload_free?: boolean; can_approve_posts?: boolean; order?: UserSearchOrder; name?: string; email?: string; } export declare enum UserSearchOrder { Date = "date", Name = "name", PostUploadCount = "post_upload_count", NoteCount = "note_count", PostUpdateCount = "post_update_count" } export {};