import { EResourceType } from '../../enums/Resource'; import { FetchArgs } from '../../models/args/FetchArgs'; import { PostArgs } from '../../models/args/PostArgs'; import { IRettiwtConfig } from '../../types/RettiwtConfig'; /** * The base service that handles all HTTP requests. * * @public */ export declare class FetcherService { /** The api key to use for authenticating against Twitter API as user. */ private readonly apiKey?; /** The service used to handle HTTP and API errors */ private readonly errorHandler; /** The guest key to use for authenticating against Twitter API as guest. */ private readonly guestKey?; /** The URL To the proxy server to use for all others. */ private readonly proxyUrl?; /** The max wait time for a response. */ private readonly timeout; /** The URL to the proxy server to use only for authentication. */ protected readonly authProxyUrl?: URL; /** The id of the authenticated user (if any). */ protected readonly userId?: string; private readonly useChromeExtension?; /** * @param config - The config object for configuring the Rettiwt instance. */ constructor(config?: IRettiwtConfig); /** * Checks the authorization status based on the requested resource. * * @param resource - The requested resource. * * @throws An error if not authorized to access the requested resource. */ private checkAuthorization; /** * Returns the AuthCredentials based on the type of key present. * * @returns The generated AuthCredential */ private getCredential; /** * Gets the https agent based on whether a proxy is used or not. * * @param proxyUrl - Optional URL with proxy configuration to use for requests to Twitter API. * * @returns The https agent to use. */ private getHttpsAgent; /** * Validates the given args against the given resource. * * @param resource - The resource against which validation is to be done. * @param args - The args to be validated. * * @returns The validated args. */ private validateArgs; /** * Makes an HTTP request according to the given parameters. * * @param resource - The requested resource. * @param config - The request configuration. * * @typeParam T - The type of the returned response data. * * @returns The raw data response received. * * @example * Fetching the raw details of a user with username 'user1' * ``` * import { FetcherService, EResourceType } from 'rettiwt-api'; * * // Creating a new FetcherService instance using the given 'API_KEY' * const fetcher = new FetcherService({ apiKey: API_KEY }); * * // Fetching the details of the User with username 'user1' * fetcher.request(EResourceType.USER_DETAILS_BY_USERNAME, { id: 'user1' }) * .then(res => { * console.log(res); * }) * .catch(err => { * console.log(err); * }) * ``` */ request(resource: EResourceType, args: FetchArgs | PostArgs): Promise; }