import { SearchCategory, SearchParams } from './Request/SearchParams'; import { TorrentCollection } from './Torrent/Torrent'; export default class TorrentSearch { private _appName; private _userAgent; private _token; private _queue; private _endpoint; /** * The search object * @param {string} appName needed TorrentApi to identify the client * @param {string} userAgent in case the one we set stop workin (chrome vers. 60) * @param {string} endpoint if the end point change and we didn't update fast enough, you can change it here */ constructor(appName: string, userAgent?: string, endpoint?: string); /** * Change delay between each request * * Only change this if you know what you're doing * @param {number} value */ delayBetweenRequests: number; /** * Advanced search with possibility to set all the different parameters * @param {SearchParams} search * @returns {Promise} */ searchAdvanced(search: SearchParams): Promise; /** * Search and in which category * @param {string} search * @param {SearchCategory} category * @returns {Promise} */ search(search: string, category: SearchCategory): Promise; /** * Ensure we have a valid token to do requests on their API * @returns {Promise} */ private ensureToken(); /** * Do request on the api * @param {RequestParams} params * @returns {Promise} * @private */ private _request(params); /** * The API is rate limited, be sure to only do the request in the right time to avoid hitting the rate limiting * @param {RequestParams} params * @returns {Promise} * @private */ private _delayedRequest(params); /** * Set all the query parameters for the request * * Check also for token expired * @param {RequestParams} params * @returns {Promise} * @private */ private _processRequest(params); }