/** * Sleeper API * The Sleeper API is a read-only HTTP API that is free to use and allows access to a users leagues, drafts, and rosters. No API Token is necessary, as you cannot modify contents via this API. Be mindful of the frequency of calls. A general rule is to stay under 1000 API calls per minute, otherwise, you risk being IP-blocked. * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ /* tslint:disable:no-unused-variable member-ordering */ import { HttpService, Inject, Injectable, Optional } from '@nestjs/common'; import { AxiosResponse } from 'axios'; import { Observable } from 'rxjs'; import { Player } from '../model/player'; import { TrendingPlayer } from '../model/trendingPlayer'; import { Configuration } from '../configuration'; @Injectable() export class PlayersService { protected basePath = 'https://api.sleeper.app/v1'; public defaultHeaders = new Map() public configuration = new Configuration(); constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) { this.configuration = configuration || this.configuration; this.basePath = configuration?.basePath || this.basePath; } /** * @param consumes string[] mime-types * @return true: consumes contains 'multipart/form-data', false: otherwise */ private canConsumeForm(consumes: string[]): boolean { const form = 'multipart/form-data'; return consumes.includes(form); } /** * Fetch all players * Please use this call sparingly, as it is intended only to be used once per day at most to keep your player IDs updated. The average size of this query is 5MB. <br/> Since rosters and draft picks contain Player IDs which look like \"1042\", \"2403\", \"CAR\", etc, you will need to know what those IDs map to. The /players call provides you the map necessary to look up any player. <br/> You should save this information on your own servers as this is not intended to be called every time you need to look up players due to the filesize being close to 5MB in size. You do not need to call this endpoint more than once per day. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public playersNflGet(): Observable>; public playersNflGet(): Observable { let headers = this.defaultHeaders; // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/json' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers['Accept'] = httpHeaderAcceptSelected; } // to determine the Content-Type header const consumes: string[] = [ ]; return this.httpClient.get<{ [key: string]: Player; }>(`${this.basePath}/players/nfl`, { withCredentials: this.configuration.withCredentials, headers: headers } ); } /** * Trending Players * Please give attribution to Sleeper you are using our trending data. If you\'d like to embed our trending list on your website or blog, please use the embed code on the right. <br/> You can use this endpoint to get a list of trending players based on adds or drops in the past 24 hours. <br/> You should save this information on your own servers as this is not intended to be called every time you need to look up players due to the filesize being close to 5MB in size. You do not need to call this endpoint more than once per day. * @param sport nfl, nba, lcs, etc * @param type Either add or drop * @param lookbackHours Number of hours to look back (default is 24) - optional * @param limit Number of results you want, (default is 25) - optional * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public playersSportTrendingTypeGet(sport: 'nfl' | 'nba' | 'lcs', type: 'add' | 'drop', lookbackHours?: string, limit?: string, ): Observable>>; public playersSportTrendingTypeGet(sport: 'nfl' | 'nba' | 'lcs', type: 'add' | 'drop', lookbackHours?: string, limit?: string, ): Observable { if (sport === null || sport === undefined) { throw new Error('Required parameter sport was null or undefined when calling playersSportTrendingTypeGet.'); } if (type === null || type === undefined) { throw new Error('Required parameter type was null or undefined when calling playersSportTrendingTypeGet.'); } let queryParameters = {}; if (lookbackHours !== undefined && lookbackHours !== null) { queryParameters['lookback_hours'] = lookbackHours; } if (limit !== undefined && limit !== null) { queryParameters['limit'] = limit; } let headers = this.defaultHeaders; // to determine the Accept header let httpHeaderAccepts: string[] = [ 'application/json' ]; const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); if (httpHeaderAcceptSelected != undefined) { headers['Accept'] = httpHeaderAcceptSelected; } // to determine the Content-Type header const consumes: string[] = [ ]; return this.httpClient.get>(`${this.basePath}/players/${encodeURIComponent(String(sport))}/trending/${encodeURIComponent(String(type))}`, { params: queryParameters, withCredentials: this.configuration.withCredentials, headers: headers } ); } }