UNPKG

sleeper-api-tsclient

Version:

Typescript client for the sleeper api

380 lines 25.2 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DraftsApiResponseProcessor = exports.DraftsApiRequestFactory = void 0; var baseapi_1 = require("./baseapi"); var http_1 = require("../http/http"); var ObjectSerializer_1 = require("../models/ObjectSerializer"); var exception_1 = require("./exception"); var util_1 = require("../util"); var DraftsApiRequestFactory = (function (_super) { __extends(DraftsApiRequestFactory, _super); function DraftsApiRequestFactory() { return _super !== null && _super.apply(this, arguments) || this; } DraftsApiRequestFactory.prototype.draftDraftIdGet = function (draftId, options) { return __awaiter(this, void 0, void 0, function () { var config, localVarPath, requestContext; return __generator(this, function (_a) { config = options || this.configuration; if (draftId === null || draftId === undefined) { throw new baseapi_1.RequiredError('Required parameter draftId was null or undefined when calling draftDraftIdGet.'); } localVarPath = '/draft/{draft_id}' .replace('{' + 'draft_id' + '}', encodeURIComponent(String(draftId))); requestContext = config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); return [2, requestContext]; }); }); }; DraftsApiRequestFactory.prototype.draftDraftIdPicksGet = function (draftId, options) { return __awaiter(this, void 0, void 0, function () { var config, localVarPath, requestContext; return __generator(this, function (_a) { config = options || this.configuration; if (draftId === null || draftId === undefined) { throw new baseapi_1.RequiredError('Required parameter draftId was null or undefined when calling draftDraftIdPicksGet.'); } localVarPath = '/draft/{draft_id}/picks' .replace('{' + 'draft_id' + '}', encodeURIComponent(String(draftId))); requestContext = config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); return [2, requestContext]; }); }); }; DraftsApiRequestFactory.prototype.draftDraftIdTradedPicksGet = function (draftId, options) { return __awaiter(this, void 0, void 0, function () { var config, localVarPath, requestContext; return __generator(this, function (_a) { config = options || this.configuration; if (draftId === null || draftId === undefined) { throw new baseapi_1.RequiredError('Required parameter draftId was null or undefined when calling draftDraftIdTradedPicksGet.'); } localVarPath = '/draft/{draft_id}/traded_picks' .replace('{' + 'draft_id' + '}', encodeURIComponent(String(draftId))); requestContext = config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); return [2, requestContext]; }); }); }; DraftsApiRequestFactory.prototype.leagueLeagueIdDraftsGet = function (leagueId, options) { return __awaiter(this, void 0, void 0, function () { var config, localVarPath, requestContext; return __generator(this, function (_a) { config = options || this.configuration; if (leagueId === null || leagueId === undefined) { throw new baseapi_1.RequiredError('Required parameter leagueId was null or undefined when calling leagueLeagueIdDraftsGet.'); } localVarPath = '/league/{league_id}/drafts' .replace('{' + 'league_id' + '}', encodeURIComponent(String(leagueId))); requestContext = config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); return [2, requestContext]; }); }); }; DraftsApiRequestFactory.prototype.userUserIdDraftsSportSeasonGet = function (userId, sport, season, options) { return __awaiter(this, void 0, void 0, function () { var config, localVarPath, requestContext; return __generator(this, function (_a) { config = options || this.configuration; if (userId === null || userId === undefined) { throw new baseapi_1.RequiredError('Required parameter userId was null or undefined when calling userUserIdDraftsSportSeasonGet.'); } if (sport === null || sport === undefined) { throw new baseapi_1.RequiredError('Required parameter sport was null or undefined when calling userUserIdDraftsSportSeasonGet.'); } if (season === null || season === undefined) { throw new baseapi_1.RequiredError('Required parameter season was null or undefined when calling userUserIdDraftsSportSeasonGet.'); } localVarPath = '/user/{user_id}/drafts/{sport}/{season}' .replace('{' + 'user_id' + '}', encodeURIComponent(String(userId))) .replace('{' + 'sport' + '}', encodeURIComponent(String(sport))) .replace('{' + 'season' + '}', encodeURIComponent(String(season))); requestContext = config.baseServer.makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); return [2, requestContext]; }); }); }; return DraftsApiRequestFactory; }(baseapi_1.BaseAPIRequestFactory)); exports.DraftsApiRequestFactory = DraftsApiRequestFactory; var DraftsApiResponseProcessor = (function () { function DraftsApiResponseProcessor() { } DraftsApiResponseProcessor.prototype.draftDraftIdGet = function (response) { return __awaiter(this, void 0, void 0, function () { var contentType, body_1, _a, _b, _c, _d, body_2, _e, _f, _g, _h, body; return __generator(this, function (_j) { switch (_j.label) { case 0: contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (!util_1.isCodeInRange("200", response.httpStatusCode)) return [3, 2]; _b = (_a = ObjectSerializer_1.ObjectSerializer).deserialize; _d = (_c = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 1: body_1 = _b.apply(_a, [_d.apply(_c, [_j.sent(), contentType]), "Array<Draft>", ""]); return [2, body_1]; case 2: if (util_1.isCodeInRange("400", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Bad Request -- Your request is invalid."); } if (util_1.isCodeInRange("404", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Not Found -- The specified kitten could not be found."); } if (util_1.isCodeInRange("429", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Too Many Requests -- You&#39;re requesting too many kittens! Slow down!"); } if (util_1.isCodeInRange("500", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Internal Server Error -- We had a problem with our server. Try again later."); } if (util_1.isCodeInRange("503", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Service Unavailable -- We&#39;re temporarily offline for maintenance. Please try again later."); } if (!(response.httpStatusCode >= 200 && response.httpStatusCode <= 299)) return [3, 4]; _f = (_e = ObjectSerializer_1.ObjectSerializer).deserialize; _h = (_g = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 3: body_2 = _f.apply(_e, [_h.apply(_g, [_j.sent(), contentType]), "Array<Draft>", ""]); return [2, body_2]; case 4: body = response.body || ""; throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } }); }); }; DraftsApiResponseProcessor.prototype.draftDraftIdPicksGet = function (response) { return __awaiter(this, void 0, void 0, function () { var contentType, body_3, _a, _b, _c, _d, body_4, _e, _f, _g, _h, body; return __generator(this, function (_j) { switch (_j.label) { case 0: contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (!util_1.isCodeInRange("200", response.httpStatusCode)) return [3, 2]; _b = (_a = ObjectSerializer_1.ObjectSerializer).deserialize; _d = (_c = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 1: body_3 = _b.apply(_a, [_d.apply(_c, [_j.sent(), contentType]), "Array<Pick>", ""]); return [2, body_3]; case 2: if (util_1.isCodeInRange("400", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Bad Request -- Your request is invalid."); } if (util_1.isCodeInRange("404", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Not Found -- The specified kitten could not be found."); } if (util_1.isCodeInRange("429", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Too Many Requests -- You&#39;re requesting too many kittens! Slow down!"); } if (util_1.isCodeInRange("500", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Internal Server Error -- We had a problem with our server. Try again later."); } if (util_1.isCodeInRange("503", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Service Unavailable -- We&#39;re temporarily offline for maintenance. Please try again later."); } if (!(response.httpStatusCode >= 200 && response.httpStatusCode <= 299)) return [3, 4]; _f = (_e = ObjectSerializer_1.ObjectSerializer).deserialize; _h = (_g = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 3: body_4 = _f.apply(_e, [_h.apply(_g, [_j.sent(), contentType]), "Array<Pick>", ""]); return [2, body_4]; case 4: body = response.body || ""; throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } }); }); }; DraftsApiResponseProcessor.prototype.draftDraftIdTradedPicksGet = function (response) { return __awaiter(this, void 0, void 0, function () { var contentType, body_5, _a, _b, _c, _d, body_6, _e, _f, _g, _h, body; return __generator(this, function (_j) { switch (_j.label) { case 0: contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (!util_1.isCodeInRange("200", response.httpStatusCode)) return [3, 2]; _b = (_a = ObjectSerializer_1.ObjectSerializer).deserialize; _d = (_c = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 1: body_5 = _b.apply(_a, [_d.apply(_c, [_j.sent(), contentType]), "Array<TradedPick>", ""]); return [2, body_5]; case 2: if (util_1.isCodeInRange("400", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Bad Request -- Your request is invalid."); } if (util_1.isCodeInRange("404", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Not Found -- The specified kitten could not be found."); } if (util_1.isCodeInRange("429", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Too Many Requests -- You&#39;re requesting too many kittens! Slow down!"); } if (util_1.isCodeInRange("500", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Internal Server Error -- We had a problem with our server. Try again later."); } if (util_1.isCodeInRange("503", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Service Unavailable -- We&#39;re temporarily offline for maintenance. Please try again later."); } if (!(response.httpStatusCode >= 200 && response.httpStatusCode <= 299)) return [3, 4]; _f = (_e = ObjectSerializer_1.ObjectSerializer).deserialize; _h = (_g = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 3: body_6 = _f.apply(_e, [_h.apply(_g, [_j.sent(), contentType]), "Array<TradedPick>", ""]); return [2, body_6]; case 4: body = response.body || ""; throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } }); }); }; DraftsApiResponseProcessor.prototype.leagueLeagueIdDraftsGet = function (response) { return __awaiter(this, void 0, void 0, function () { var contentType, body_7, _a, _b, _c, _d, body_8, _e, _f, _g, _h, body; return __generator(this, function (_j) { switch (_j.label) { case 0: contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (!util_1.isCodeInRange("200", response.httpStatusCode)) return [3, 2]; _b = (_a = ObjectSerializer_1.ObjectSerializer).deserialize; _d = (_c = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 1: body_7 = _b.apply(_a, [_d.apply(_c, [_j.sent(), contentType]), "Array<Draft>", ""]); return [2, body_7]; case 2: if (util_1.isCodeInRange("400", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Bad Request -- Your request is invalid."); } if (util_1.isCodeInRange("404", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Not Found -- The specified kitten could not be found."); } if (util_1.isCodeInRange("429", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Too Many Requests -- You&#39;re requesting too many kittens! Slow down!"); } if (util_1.isCodeInRange("500", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Internal Server Error -- We had a problem with our server. Try again later."); } if (util_1.isCodeInRange("503", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Service Unavailable -- We&#39;re temporarily offline for maintenance. Please try again later."); } if (!(response.httpStatusCode >= 200 && response.httpStatusCode <= 299)) return [3, 4]; _f = (_e = ObjectSerializer_1.ObjectSerializer).deserialize; _h = (_g = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 3: body_8 = _f.apply(_e, [_h.apply(_g, [_j.sent(), contentType]), "Array<Draft>", ""]); return [2, body_8]; case 4: body = response.body || ""; throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } }); }); }; DraftsApiResponseProcessor.prototype.userUserIdDraftsSportSeasonGet = function (response) { return __awaiter(this, void 0, void 0, function () { var contentType, body_9, _a, _b, _c, _d, body_10, _e, _f, _g, _h, body; return __generator(this, function (_j) { switch (_j.label) { case 0: contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]); if (!util_1.isCodeInRange("200", response.httpStatusCode)) return [3, 2]; _b = (_a = ObjectSerializer_1.ObjectSerializer).deserialize; _d = (_c = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 1: body_9 = _b.apply(_a, [_d.apply(_c, [_j.sent(), contentType]), "Array<Draft>", ""]); return [2, body_9]; case 2: if (util_1.isCodeInRange("400", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Bad Request -- Your request is invalid."); } if (util_1.isCodeInRange("404", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Not Found -- The specified kitten could not be found."); } if (util_1.isCodeInRange("429", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Too Many Requests -- You&#39;re requesting too many kittens! Slow down!"); } if (util_1.isCodeInRange("500", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Internal Server Error -- We had a problem with our server. Try again later."); } if (util_1.isCodeInRange("503", response.httpStatusCode)) { throw new exception_1.ApiException(response.httpStatusCode, "Service Unavailable -- We&#39;re temporarily offline for maintenance. Please try again later."); } if (!(response.httpStatusCode >= 200 && response.httpStatusCode <= 299)) return [3, 4]; _f = (_e = ObjectSerializer_1.ObjectSerializer).deserialize; _h = (_g = ObjectSerializer_1.ObjectSerializer).parse; return [4, response.body.text()]; case 3: body_10 = _f.apply(_e, [_h.apply(_g, [_j.sent(), contentType]), "Array<Draft>", ""]); return [2, body_10]; case 4: body = response.body || ""; throw new exception_1.ApiException(response.httpStatusCode, "Unknown API Status Code!\nBody: \"" + body + "\""); } }); }); }; return DraftsApiResponseProcessor; }()); exports.DraftsApiResponseProcessor = DraftsApiResponseProcessor; //# sourceMappingURL=DraftsApi.js.map