/** * 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 { Draft } from '../model/draft'; import { Pick } from '../model/pick'; import { TradedPick } from '../model/tradedPick'; import { Configuration } from '../configuration'; @Injectable() export class DraftsService { 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); } /** * Get a specific draft * This endpoint retrieves a specific draft. * @param draftId The ID of the draft to retrieve * @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 draftDraftIdGet(draftId: string, ): Observable>>; public draftDraftIdGet(draftId: string, ): Observable { if (draftId === null || draftId === undefined) { throw new Error('Required parameter draftId was null or undefined when calling draftDraftIdGet.'); } 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}/draft/${encodeURIComponent(String(draftId))}`, { withCredentials: this.configuration.withCredentials, headers: headers } ); } /** * Get a specific draft * This endpoint retrieves a specific draft. * @param draftId The ID of the draft to retrieve * @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 draftDraftIdPicksGet(draftId: string, ): Observable>>; public draftDraftIdPicksGet(draftId: string, ): Observable { if (draftId === null || draftId === undefined) { throw new Error('Required parameter draftId was null or undefined when calling draftDraftIdPicksGet.'); } 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}/draft/${encodeURIComponent(String(draftId))}/picks`, { withCredentials: this.configuration.withCredentials, headers: headers } ); } /** * Get a specific draft * This endpoint retrieves a specific draft. * @param draftId The ID of the draft to retrieve * @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 draftDraftIdTradedPicksGet(draftId: string, ): Observable>>; public draftDraftIdTradedPicksGet(draftId: string, ): Observable { if (draftId === null || draftId === undefined) { throw new Error('Required parameter draftId was null or undefined when calling draftDraftIdTradedPicksGet.'); } 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}/draft/${encodeURIComponent(String(draftId))}/traded_picks`, { withCredentials: this.configuration.withCredentials, headers: headers } ); } /** * Get all drafts for a league * This endpoint retrieves all drafts for a league. Keep in mind that a league can have multiple drafts, especially dynasty leagues. Drafts are sorted by most recent to earliest. Most leagues should only have one draft. * @param leagueId The ID of the league for which you are trying to retrieve drafts. * @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 leagueLeagueIdDraftsGet(leagueId: string, ): Observable>>; public leagueLeagueIdDraftsGet(leagueId: string, ): Observable { if (leagueId === null || leagueId === undefined) { throw new Error('Required parameter leagueId was null or undefined when calling leagueLeagueIdDraftsGet.'); } 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}/league/${encodeURIComponent(String(leagueId))}/drafts`, { withCredentials: this.configuration.withCredentials, headers: headers } ); } /** * Get all drafts for user * This endpoint retrieves all drafts by a user. * @param userId the user is to get * @param sport Only \"nfl\" is supported right now * @param season The NFL season to get * @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 userUserIdDraftsSportSeasonGet(userId: string, sport: string, season: number, ): Observable>>; public userUserIdDraftsSportSeasonGet(userId: string, sport: string, season: number, ): Observable { if (userId === null || userId === undefined) { throw new Error('Required parameter userId was null or undefined when calling userUserIdDraftsSportSeasonGet.'); } if (sport === null || sport === undefined) { throw new Error('Required parameter sport was null or undefined when calling userUserIdDraftsSportSeasonGet.'); } if (season === null || season === undefined) { throw new Error('Required parameter season was null or undefined when calling userUserIdDraftsSportSeasonGet.'); } 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}/user/${encodeURIComponent(String(userId))}/drafts/${encodeURIComponent(String(sport))}/${encodeURIComponent(String(season))}`, { withCredentials: this.configuration.withCredentials, headers: headers } ); } }