espn-ff
Version:
ESPN Fantasy Football Scraper
82 lines (81 loc) • 2.4 kB
TypeScript
import * as types from './types';
/**
*Constructor options for the EspnFantasyFootball class
*
* @export
* @interface ConstructorOptions
*/
export interface ConstructorOptions {
/**
* Required. ESPN league id.
*
* @type {number}
* @memberOf ConstructorOptions
*/
leagueId: number;
/**
* Optional. Cookie used to send requests, you will need this for non public leagues.
*
* @type {string}
* @memberOf ConstructorOptions
*/
cookie?: string;
}
/**
* Callback raised with fetch result from ESPN fantasy football.
*
* @export
* @interface FetchParseCallback
* @template T
*/
export interface FetchParseCallback<T> {
(error?: Error, parseResult?: T): any;
}
/**
* ESPN fantasy football root class
*
* @class EspnFantasyFootball
*/
export default class EspnFantasyFootball {
private options;
private parserService;
/**
* Creates an instance of EspnFantasyFootball.
*
* @param {ConstructorOptions} options
*
* @memberOf EspnFantasyFootball
*/
constructor(options: ConstructorOptions);
/**
* Fetches all fantasy football teams within the fantasy league.
*
* @param {FetchParseCallback<types.IFantasyTeam[]>} callback
* @returns {void}
*
* @memberOf EspnFantasyFootball
*/
getFantasyTeams(callback: FetchParseCallback<types.IFantasyTeam[]>): void;
/**
* Gets the active roster for the specified fantasy team.
*
* @param {number} teamId - Can be null for the default team identity
* @param {FetchParseCallback<types.IRoster>} callback
* @returns {void}
*
* @memberOf EspnFantasyFootball
*/
getRoster(teamId: number, callback: FetchParseCallback<types.IRoster>): void;
/**
* Gets the fantasy matchups for the specified week within the league.
*
* @param {number} week - Week id (1 thru N), can be null for current week.
* @param {FetchParseCallback<types.IFantasyMatchup[]>} callback
* @returns {void}
*
* @memberOf EspnFantasyFootball
*/
getMatchups(week: number, callback: FetchParseCallback<types.IFantasyMatchup[]>): void;
private espnGetAndParse<T>(parser, fragment, urlQuery, callback);
private espnGetRequest(fragment, urlQuery, callback);
}