UNPKG

@chez14/mal-api-lite

Version:
92 lines (89 loc) 2.98 kB
import { Options as Options$1, Got } from 'got'; import { BaseRequester, TokenResponse, RequestParam, PaginatableRequestParam } from './types.js'; interface Options { clientId?: string; clientSecret?: string; accessToken?: string; refreshToken?: string; gotOptions?: Options$1; gotOAuthOptions?: Options$1; autoRefreshAccessToken?: boolean; } declare class MALClient implements BaseRequester { clientId?: string; clientSecret?: string; accessToken?: string; refreshToken?: string; got: Got; gotOAuth: Got; PKCEChallangeGenerateSize: number; userAgent: string; malApiBaseUrl: string; malOAuthUrl: string; /** * Create MAL API Client * * @param param0 Your trusty configuration */ constructor({ clientId, clientSecret, accessToken, refreshToken, gotOptions, gotOAuthOptions }: Options); /** * Get Access Token & Refresh Token from given Authorization Code. * * @param authCode Authorization code * @param codeVerifier PKCE Code Challenge * @param redirectUri Redirect url, specified on on previous step */ resolveAuthCode(authCode: string, codeVerifier: string, redirectUri?: string): Promise<TokenResponse>; /** * Generate OAuth URL to gain access to user account on MyAnimeList platform. * Will require clientId and clientSecret from custructor. * * @param codeChallenge PKCE Code Challenge * @param redirectUri If you have more than one Redirect URL, please specify * the url you use. * @param state Your app state * @param codeChallengeMethod Only accept "plain". Don't change unless you * know what you're doing! */ getOAuthURL(redirectUri?: string, codeChallenge?: string, state?: string): { url: string; codeChallenge: string; state?: string; }; /** * Refresh your access token with refresh token. * * @param refreshToken Custom refresh token */ resolveRefreshToken(refreshToken?: string): Promise<TokenResponse>; protected preprocessParam(param?: RequestParam): RequestParam | undefined; /** * Do HTTP GET stuffs. * * @param resource Url to call * @param param Parameter body */ get<T = any>(resource: string, param?: RequestParam | PaginatableRequestParam): Promise<T>; /** * Do HTTP POST stuffs. * * @param resource Url to call * @param param Parameter body */ post<T = any>(resource: string, param?: RequestParam): Promise<T>; /** * Do HTTP PATCH stuffs. * * @param resource Url to call * @param param Parameter body */ patch<T = any>(resource: string, param?: RequestParam): Promise<T>; /** * Do HTTP DELETE stuffs. * * @param resource Url to call * @param param Parameter body (discouraged) */ delete<T = any>(resource: string): Promise<T>; } export { MALClient, type Options };