@bp1222/stats-api 0.0.4 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,1574 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __async = (__this, __arguments, generator) => {
21
+ return new Promise((resolve, reject) => {
22
+ var fulfilled = (value) => {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ };
29
+ var rejected = (value) => {
30
+ try {
31
+ step(generator.throw(value));
32
+ } catch (e) {
33
+ reject(e);
34
+ }
35
+ };
36
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
37
+ step((generator = generator.apply(__this, __arguments)).next());
38
+ });
39
+ };
40
+
41
+ // src/runtime.ts
42
+ var BASE_PATH = "https://statsapi.mlb.com/api".replace(/\/+$/, "");
43
+ var Configuration = class {
44
+ constructor(configuration = {}) {
45
+ this.configuration = configuration;
46
+ }
47
+ set config(configuration) {
48
+ this.configuration = configuration;
49
+ }
50
+ get basePath() {
51
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
52
+ }
53
+ get fetchApi() {
54
+ return this.configuration.fetchApi;
55
+ }
56
+ get middleware() {
57
+ return this.configuration.middleware || [];
58
+ }
59
+ get queryParamsStringify() {
60
+ return this.configuration.queryParamsStringify || querystring;
61
+ }
62
+ get username() {
63
+ return this.configuration.username;
64
+ }
65
+ get password() {
66
+ return this.configuration.password;
67
+ }
68
+ get apiKey() {
69
+ const apiKey = this.configuration.apiKey;
70
+ if (apiKey) {
71
+ return typeof apiKey === "function" ? apiKey : () => apiKey;
72
+ }
73
+ return void 0;
74
+ }
75
+ get accessToken() {
76
+ const accessToken = this.configuration.accessToken;
77
+ if (accessToken) {
78
+ return typeof accessToken === "function" ? accessToken : () => __async(this, null, function* () {
79
+ return accessToken;
80
+ });
81
+ }
82
+ return void 0;
83
+ }
84
+ get headers() {
85
+ return this.configuration.headers;
86
+ }
87
+ get credentials() {
88
+ return this.configuration.credentials;
89
+ }
90
+ };
91
+ var DefaultConfig = new Configuration();
92
+ var _BaseAPI = class _BaseAPI {
93
+ constructor(configuration = DefaultConfig) {
94
+ this.configuration = configuration;
95
+ this.fetchApi = (url, init) => __async(this, null, function* () {
96
+ let fetchParams = { url, init };
97
+ for (const middleware of this.middleware) {
98
+ if (middleware.pre) {
99
+ fetchParams = (yield middleware.pre(__spreadValues({
100
+ fetch: this.fetchApi
101
+ }, fetchParams))) || fetchParams;
102
+ }
103
+ }
104
+ let response = void 0;
105
+ try {
106
+ response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
107
+ } catch (e) {
108
+ for (const middleware of this.middleware) {
109
+ if (middleware.onError) {
110
+ response = (yield middleware.onError({
111
+ fetch: this.fetchApi,
112
+ url: fetchParams.url,
113
+ init: fetchParams.init,
114
+ error: e,
115
+ response: response ? response.clone() : void 0
116
+ })) || response;
117
+ }
118
+ }
119
+ if (response === void 0) {
120
+ if (e instanceof Error) {
121
+ throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
122
+ } else {
123
+ throw e;
124
+ }
125
+ }
126
+ }
127
+ for (const middleware of this.middleware) {
128
+ if (middleware.post) {
129
+ response = (yield middleware.post({
130
+ fetch: this.fetchApi,
131
+ url: fetchParams.url,
132
+ init: fetchParams.init,
133
+ response: response.clone()
134
+ })) || response;
135
+ }
136
+ }
137
+ return response;
138
+ });
139
+ this.middleware = configuration.middleware;
140
+ }
141
+ withMiddleware(...middlewares) {
142
+ const next = this.clone();
143
+ next.middleware = next.middleware.concat(...middlewares);
144
+ return next;
145
+ }
146
+ withPreMiddleware(...preMiddlewares) {
147
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
148
+ return this.withMiddleware(...middlewares);
149
+ }
150
+ withPostMiddleware(...postMiddlewares) {
151
+ const middlewares = postMiddlewares.map((post) => ({ post }));
152
+ return this.withMiddleware(...middlewares);
153
+ }
154
+ /**
155
+ * Check if the given MIME is a JSON MIME.
156
+ * JSON MIME examples:
157
+ * application/json
158
+ * application/json; charset=UTF8
159
+ * APPLICATION/JSON
160
+ * application/vnd.company+json
161
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
162
+ * @return True if the given MIME is JSON, false otherwise.
163
+ */
164
+ isJsonMime(mime) {
165
+ if (!mime) {
166
+ return false;
167
+ }
168
+ return _BaseAPI.jsonRegex.test(mime);
169
+ }
170
+ request(context, initOverrides) {
171
+ return __async(this, null, function* () {
172
+ const { url, init } = yield this.createFetchParams(context, initOverrides);
173
+ const response = yield this.fetchApi(url, init);
174
+ if (response && (response.status >= 200 && response.status < 300)) {
175
+ return response;
176
+ }
177
+ throw new ResponseError(response, "Response returned an error code");
178
+ });
179
+ }
180
+ createFetchParams(context, initOverrides) {
181
+ return __async(this, null, function* () {
182
+ let url = this.configuration.basePath + context.path;
183
+ if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
184
+ url += "?" + this.configuration.queryParamsStringify(context.query);
185
+ }
186
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
187
+ Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
188
+ const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __async(this, null, function* () {
189
+ return initOverrides;
190
+ });
191
+ const initParams = {
192
+ method: context.method,
193
+ headers,
194
+ body: context.body,
195
+ credentials: this.configuration.credentials
196
+ };
197
+ const overriddenInit = __spreadValues(__spreadValues({}, initParams), yield initOverrideFn({
198
+ init: initParams,
199
+ context
200
+ }));
201
+ let body;
202
+ if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
203
+ body = overriddenInit.body;
204
+ } else if (this.isJsonMime(headers["Content-Type"])) {
205
+ body = JSON.stringify(overriddenInit.body);
206
+ } else {
207
+ body = overriddenInit.body;
208
+ }
209
+ const init = __spreadProps(__spreadValues({}, overriddenInit), {
210
+ body
211
+ });
212
+ return { url, init };
213
+ });
214
+ }
215
+ /**
216
+ * Create a shallow clone of `this` by constructing a new instance
217
+ * and then shallow cloning data members.
218
+ */
219
+ clone() {
220
+ const constructor = this.constructor;
221
+ const next = new constructor(this.configuration);
222
+ next.middleware = this.middleware.slice();
223
+ return next;
224
+ }
225
+ };
226
+ _BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
227
+ var BaseAPI = _BaseAPI;
228
+ function isBlob(value) {
229
+ return typeof Blob !== "undefined" && value instanceof Blob;
230
+ }
231
+ function isFormData(value) {
232
+ return typeof FormData !== "undefined" && value instanceof FormData;
233
+ }
234
+ var ResponseError = class extends Error {
235
+ constructor(response, msg) {
236
+ super(msg);
237
+ this.response = response;
238
+ this.name = "ResponseError";
239
+ }
240
+ };
241
+ var FetchError = class extends Error {
242
+ constructor(cause, msg) {
243
+ super(msg);
244
+ this.cause = cause;
245
+ this.name = "FetchError";
246
+ }
247
+ };
248
+ var RequiredError = class extends Error {
249
+ constructor(field, msg) {
250
+ super(msg);
251
+ this.field = field;
252
+ this.name = "RequiredError";
253
+ }
254
+ };
255
+ var COLLECTION_FORMATS = {
256
+ csv: ",",
257
+ ssv: " ",
258
+ tsv: " ",
259
+ pipes: "|"
260
+ };
261
+ function querystring(params, prefix = "") {
262
+ return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
263
+ }
264
+ function querystringSingleKey(key, value, keyPrefix = "") {
265
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
266
+ if (value instanceof Array) {
267
+ const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
268
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
269
+ }
270
+ if (value instanceof Set) {
271
+ const valueAsArray = Array.from(value);
272
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
273
+ }
274
+ if (value instanceof Date) {
275
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
276
+ }
277
+ if (value instanceof Object) {
278
+ return querystring(value, fullKey);
279
+ }
280
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
281
+ }
282
+ function mapValues(data, fn) {
283
+ return Object.keys(data).reduce(
284
+ (acc, key) => __spreadProps(__spreadValues({}, acc), { [key]: fn(data[key]) }),
285
+ {}
286
+ );
287
+ }
288
+ function canConsumeForm(consumes) {
289
+ for (const consume of consumes) {
290
+ if ("multipart/form-data" === consume.contentType) {
291
+ return true;
292
+ }
293
+ }
294
+ return false;
295
+ }
296
+ var JSONApiResponse = class {
297
+ constructor(raw, transformer = (jsonValue) => jsonValue) {
298
+ this.raw = raw;
299
+ this.transformer = transformer;
300
+ }
301
+ value() {
302
+ return __async(this, null, function* () {
303
+ return this.transformer(yield this.raw.json());
304
+ });
305
+ }
306
+ };
307
+ var VoidApiResponse = class {
308
+ constructor(raw) {
309
+ this.raw = raw;
310
+ }
311
+ value() {
312
+ return __async(this, null, function* () {
313
+ return void 0;
314
+ });
315
+ }
316
+ };
317
+ var BlobApiResponse = class {
318
+ constructor(raw) {
319
+ this.raw = raw;
320
+ }
321
+ value() {
322
+ return __async(this, null, function* () {
323
+ return yield this.raw.blob();
324
+ });
325
+ }
326
+ };
327
+ var TextApiResponse = class {
328
+ constructor(raw) {
329
+ this.raw = raw;
330
+ }
331
+ value() {
332
+ return __async(this, null, function* () {
333
+ return yield this.raw.text();
334
+ });
335
+ }
336
+ };
337
+
338
+ // src/models/MLBLeagueDates.ts
339
+ function instanceOfMLBLeagueDates(value) {
340
+ return true;
341
+ }
342
+ function MLBLeagueDatesFromJSON(json) {
343
+ return MLBLeagueDatesFromJSONTyped(json, false);
344
+ }
345
+ function MLBLeagueDatesFromJSONTyped(json, ignoreDiscriminator) {
346
+ if (json == null) {
347
+ return json;
348
+ }
349
+ return {
350
+ "seasonId": json["seasonId"] == null ? void 0 : json["seasonId"],
351
+ "preSeasonStartDate": json["preSeasonStartDate"] == null ? void 0 : json["preSeasonStartDate"],
352
+ "preSeasonEndDate": json["preSeasonEndDate"] == null ? void 0 : json["preSeasonEndDate"],
353
+ "seasonStartDate": json["seasonStartDate"] == null ? void 0 : json["seasonStartDate"],
354
+ "springStartDate": json["springStartDate"] == null ? void 0 : json["springStartDate"],
355
+ "springEndDate": json["springEndDate"] == null ? void 0 : json["springEndDate"],
356
+ "offseasonStartDate": json["offseasonStartDate"] == null ? void 0 : json["offseasonStartDate"],
357
+ "offseasonEndDate": json["offseasonEndDate"] == null ? void 0 : json["offseasonEndDate"],
358
+ "seasonLevelGamedayType": json["seasonLevelGamedayType"] == null ? void 0 : json["seasonLevelGamedayType"],
359
+ "gameLevelGamedayType": json["gameLevelGamedayType"] == null ? void 0 : json["gameLevelGamedayType"]
360
+ };
361
+ }
362
+ function MLBLeagueDatesToJSON(value) {
363
+ if (value == null) {
364
+ return value;
365
+ }
366
+ return {
367
+ "seasonId": value["seasonId"],
368
+ "preSeasonStartDate": value["preSeasonStartDate"],
369
+ "preSeasonEndDate": value["preSeasonEndDate"],
370
+ "seasonStartDate": value["seasonStartDate"],
371
+ "springStartDate": value["springStartDate"],
372
+ "springEndDate": value["springEndDate"],
373
+ "offseasonStartDate": value["offseasonStartDate"],
374
+ "offseasonEndDate": value["offseasonEndDate"],
375
+ "seasonLevelGamedayType": value["seasonLevelGamedayType"],
376
+ "gameLevelGamedayType": value["gameLevelGamedayType"]
377
+ };
378
+ }
379
+
380
+ // src/models/MLBLeague.ts
381
+ function instanceOfMLBLeague(value) {
382
+ if (!("id" in value) || value["id"] === void 0) return false;
383
+ if (!("name" in value) || value["name"] === void 0) return false;
384
+ return true;
385
+ }
386
+ function MLBLeagueFromJSON(json) {
387
+ return MLBLeagueFromJSONTyped(json, false);
388
+ }
389
+ function MLBLeagueFromJSONTyped(json, ignoreDiscriminator) {
390
+ if (json == null) {
391
+ return json;
392
+ }
393
+ return {
394
+ "id": json["id"],
395
+ "name": json["name"],
396
+ "link": json["link"] == null ? void 0 : json["link"],
397
+ "abbreviation": json["abbreviation"] == null ? void 0 : json["abbreviation"],
398
+ "nameShort": json["nameShort"] == null ? void 0 : json["nameShort"],
399
+ "seasonState": json["seasonState"] == null ? void 0 : json["seasonState"],
400
+ "hasWildCard": json["hasWildCard"] == null ? void 0 : json["hasWildCard"],
401
+ "hasSplitSeason": json["hasSplitSeason"] == null ? void 0 : json["hasSplitSeason"],
402
+ "hasPlayoffPoints": json["hasPlayoffPoints"] == null ? void 0 : json["hasPlayoffPoints"],
403
+ "seasonDateInfo": json["seasonDateInfo"] == null ? void 0 : MLBLeagueDatesFromJSON(json["seasonDateInfo"]),
404
+ "season": json["season"] == null ? void 0 : json["season"],
405
+ "orgCode": json["orgCode"] == null ? void 0 : json["orgCode"],
406
+ "conferencesInUse": json["conferencesInUse"] == null ? void 0 : json["conferencesInUse"],
407
+ "divisionsInUse": json["divisionsInUse"] == null ? void 0 : json["divisionsInUse"],
408
+ "sortOrder": json["sortOrder"] == null ? void 0 : json["sortOrder"],
409
+ "active": json["active"] == null ? void 0 : json["active"]
410
+ };
411
+ }
412
+ function MLBLeagueToJSON(value) {
413
+ if (value == null) {
414
+ return value;
415
+ }
416
+ return {
417
+ "id": value["id"],
418
+ "name": value["name"],
419
+ "link": value["link"],
420
+ "abbreviation": value["abbreviation"],
421
+ "nameShort": value["nameShort"],
422
+ "seasonState": value["seasonState"],
423
+ "hasWildCard": value["hasWildCard"],
424
+ "hasSplitSeason": value["hasSplitSeason"],
425
+ "hasPlayoffPoints": value["hasPlayoffPoints"],
426
+ "seasonDateInfo": MLBLeagueDatesToJSON(value["seasonDateInfo"]),
427
+ "season": value["season"],
428
+ "orgCode": value["orgCode"],
429
+ "conferencesInUse": value["conferencesInUse"],
430
+ "divisionsInUse": value["divisionsInUse"],
431
+ "sortOrder": value["sortOrder"],
432
+ "active": value["active"]
433
+ };
434
+ }
435
+
436
+ // src/models/MLBSport.ts
437
+ function instanceOfMLBSport(value) {
438
+ if (!("id" in value) || value["id"] === void 0) return false;
439
+ return true;
440
+ }
441
+ function MLBSportFromJSON(json) {
442
+ return MLBSportFromJSONTyped(json, false);
443
+ }
444
+ function MLBSportFromJSONTyped(json, ignoreDiscriminator) {
445
+ if (json == null) {
446
+ return json;
447
+ }
448
+ return {
449
+ "id": json["id"],
450
+ "code": json["code"] == null ? void 0 : json["code"],
451
+ "link": json["link"] == null ? void 0 : json["link"],
452
+ "name": json["name"] == null ? void 0 : json["name"],
453
+ "abbreviation": json["abbreviation"] == null ? void 0 : json["abbreviation"],
454
+ "sortOrder": json["sortOrder"] == null ? void 0 : json["sortOrder"],
455
+ "activeStatus": json["activeStatus"] == null ? void 0 : json["activeStatus"]
456
+ };
457
+ }
458
+ function MLBSportToJSON(value) {
459
+ if (value == null) {
460
+ return value;
461
+ }
462
+ return {
463
+ "id": value["id"],
464
+ "code": value["code"],
465
+ "link": value["link"],
466
+ "name": value["name"],
467
+ "abbreviation": value["abbreviation"],
468
+ "sortOrder": value["sortOrder"],
469
+ "activeStatus": value["activeStatus"]
470
+ };
471
+ }
472
+
473
+ // src/models/MLBDivision.ts
474
+ function instanceOfMLBDivision(value) {
475
+ if (!("id" in value) || value["id"] === void 0) return false;
476
+ if (!("name" in value) || value["name"] === void 0) return false;
477
+ return true;
478
+ }
479
+ function MLBDivisionFromJSON(json) {
480
+ return MLBDivisionFromJSONTyped(json, false);
481
+ }
482
+ function MLBDivisionFromJSONTyped(json, ignoreDiscriminator) {
483
+ if (json == null) {
484
+ return json;
485
+ }
486
+ return {
487
+ "id": json["id"],
488
+ "name": json["name"],
489
+ "season": json["season"] == null ? void 0 : json["season"],
490
+ "nameShort": json["nameShort"] == null ? void 0 : json["nameShort"],
491
+ "link": json["link"] == null ? void 0 : json["link"],
492
+ "abbreviation": json["abbreviation"] == null ? void 0 : json["abbreviation"],
493
+ "league": json["league"] == null ? void 0 : MLBLeagueFromJSON(json["league"]),
494
+ "sport": json["sport"] == null ? void 0 : MLBSportFromJSON(json["sport"]),
495
+ "hasWildcard": json["hasWildcard"] == null ? void 0 : json["hasWildcard"],
496
+ "sortOrder": json["sortOrder"] == null ? void 0 : json["sortOrder"],
497
+ "numPlayoffTeams": json["numPlayoffTeams"] == null ? void 0 : json["numPlayoffTeams"],
498
+ "active": json["active"] == null ? void 0 : json["active"]
499
+ };
500
+ }
501
+ function MLBDivisionToJSON(value) {
502
+ if (value == null) {
503
+ return value;
504
+ }
505
+ return {
506
+ "id": value["id"],
507
+ "name": value["name"],
508
+ "season": value["season"],
509
+ "nameShort": value["nameShort"],
510
+ "link": value["link"],
511
+ "abbreviation": value["abbreviation"],
512
+ "league": MLBLeagueToJSON(value["league"]),
513
+ "sport": MLBSportToJSON(value["sport"]),
514
+ "hasWildcard": value["hasWildcard"],
515
+ "sortOrder": value["sortOrder"],
516
+ "numPlayoffTeams": value["numPlayoffTeams"],
517
+ "active": value["active"]
518
+ };
519
+ }
520
+
521
+ // src/models/MLBVenue.ts
522
+ function instanceOfMLBVenue(value) {
523
+ if (!("id" in value) || value["id"] === void 0) return false;
524
+ if (!("name" in value) || value["name"] === void 0) return false;
525
+ return true;
526
+ }
527
+ function MLBVenueFromJSON(json) {
528
+ return MLBVenueFromJSONTyped(json, false);
529
+ }
530
+ function MLBVenueFromJSONTyped(json, ignoreDiscriminator) {
531
+ if (json == null) {
532
+ return json;
533
+ }
534
+ return {
535
+ "id": json["id"],
536
+ "name": json["name"],
537
+ "link": json["link"] == null ? void 0 : json["link"],
538
+ "active": json["active"] == null ? void 0 : json["active"],
539
+ "season": json["season"] == null ? void 0 : json["season"]
540
+ };
541
+ }
542
+ function MLBVenueToJSON(value) {
543
+ if (value == null) {
544
+ return value;
545
+ }
546
+ return {
547
+ "id": value["id"],
548
+ "name": value["name"],
549
+ "link": value["link"],
550
+ "active": value["active"],
551
+ "season": value["season"]
552
+ };
553
+ }
554
+
555
+ // src/models/MLBGameStatus.ts
556
+ var MLBGameStatusCodedGameStateEnum = {
557
+ Final: "F",
558
+ Postponed: "D",
559
+ Scheduled: "S",
560
+ InProgress: "I",
561
+ Pregame: "P",
562
+ GameOver: "O"
563
+ };
564
+ function instanceOfMLBGameStatus(value) {
565
+ return true;
566
+ }
567
+ function MLBGameStatusFromJSON(json) {
568
+ return MLBGameStatusFromJSONTyped(json, false);
569
+ }
570
+ function MLBGameStatusFromJSONTyped(json, ignoreDiscriminator) {
571
+ if (json == null) {
572
+ return json;
573
+ }
574
+ return {
575
+ "abstractGameState": json["abstractGameState"] == null ? void 0 : json["abstractGameState"],
576
+ "codedGameState": json["codedGameState"] == null ? void 0 : json["codedGameState"],
577
+ "detailedState": json["detailedState"] == null ? void 0 : json["detailedState"],
578
+ "statusCode": json["statusCode"] == null ? void 0 : json["statusCode"],
579
+ "startTimeTBD": json["startTimeTBD"] == null ? void 0 : json["startTimeTBD"],
580
+ "abstractGameCode": json["abstractGameCode"] == null ? void 0 : json["abstractGameCode"]
581
+ };
582
+ }
583
+ function MLBGameStatusToJSON(value) {
584
+ if (value == null) {
585
+ return value;
586
+ }
587
+ return {
588
+ "abstractGameState": value["abstractGameState"],
589
+ "codedGameState": value["codedGameState"],
590
+ "detailedState": value["detailedState"],
591
+ "statusCode": value["statusCode"],
592
+ "startTimeTBD": value["startTimeTBD"],
593
+ "abstractGameCode": value["abstractGameCode"]
594
+ };
595
+ }
596
+
597
+ // src/models/MLBTeam.ts
598
+ function instanceOfMLBTeam(value) {
599
+ if (!("id" in value) || value["id"] === void 0) return false;
600
+ if (!("name" in value) || value["name"] === void 0) return false;
601
+ return true;
602
+ }
603
+ function MLBTeamFromJSON(json) {
604
+ return MLBTeamFromJSONTyped(json, false);
605
+ }
606
+ function MLBTeamFromJSONTyped(json, ignoreDiscriminator) {
607
+ if (json == null) {
608
+ return json;
609
+ }
610
+ return {
611
+ "id": json["id"],
612
+ "name": json["name"],
613
+ "link": json["link"] == null ? void 0 : json["link"],
614
+ "allStarStatus": json["allStarStatus"] == null ? void 0 : json["allStarStatus"],
615
+ "season": json["season"] == null ? void 0 : json["season"],
616
+ "venue": json["venue"] == null ? void 0 : MLBVenueFromJSON(json["venue"]),
617
+ "springVenue": json["springVenue"] == null ? void 0 : MLBVenueFromJSON(json["springVenue"]),
618
+ "teamCode": json["teamCode"] == null ? void 0 : json["teamCode"],
619
+ "fileCode": json["fileCode"] == null ? void 0 : json["fileCode"],
620
+ "abbreviation": json["abbreviation"] == null ? void 0 : json["abbreviation"],
621
+ "teamName": json["teamName"] == null ? void 0 : json["teamName"],
622
+ "locationName": json["locationName"] == null ? void 0 : json["locationName"],
623
+ "firstYearOfPlay": json["firstYearOfPlay"] == null ? void 0 : json["firstYearOfPlay"],
624
+ "league": json["league"] == null ? void 0 : MLBLeagueFromJSON(json["league"]),
625
+ "springLeague": json["springLeague"] == null ? void 0 : MLBLeagueFromJSON(json["springLeague"]),
626
+ "division": json["division"] == null ? void 0 : MLBDivisionFromJSON(json["division"]),
627
+ "sport": json["sport"] == null ? void 0 : MLBSportFromJSON(json["sport"]),
628
+ "shortName": json["shortName"] == null ? void 0 : json["shortName"],
629
+ "franchiseName": json["franchiseName"] == null ? void 0 : json["franchiseName"],
630
+ "clubName": json["clubName"] == null ? void 0 : json["clubName"],
631
+ "active": json["active"] == null ? void 0 : json["active"]
632
+ };
633
+ }
634
+ function MLBTeamToJSON(value) {
635
+ if (value == null) {
636
+ return value;
637
+ }
638
+ return {
639
+ "id": value["id"],
640
+ "name": value["name"],
641
+ "link": value["link"],
642
+ "allStarStatus": value["allStarStatus"],
643
+ "season": value["season"],
644
+ "venue": MLBVenueToJSON(value["venue"]),
645
+ "springVenue": MLBVenueToJSON(value["springVenue"]),
646
+ "teamCode": value["teamCode"],
647
+ "fileCode": value["fileCode"],
648
+ "abbreviation": value["abbreviation"],
649
+ "teamName": value["teamName"],
650
+ "locationName": value["locationName"],
651
+ "firstYearOfPlay": value["firstYearOfPlay"],
652
+ "league": MLBLeagueToJSON(value["league"]),
653
+ "springLeague": MLBLeagueToJSON(value["springLeague"]),
654
+ "division": MLBDivisionToJSON(value["division"]),
655
+ "sport": MLBSportToJSON(value["sport"]),
656
+ "shortName": value["shortName"],
657
+ "franchiseName": value["franchiseName"],
658
+ "clubName": value["clubName"],
659
+ "active": value["active"]
660
+ };
661
+ }
662
+
663
+ // src/models/MLBLeagueRecord.ts
664
+ function instanceOfMLBLeagueRecord(value) {
665
+ if (!("wins" in value) || value["wins"] === void 0) return false;
666
+ if (!("losses" in value) || value["losses"] === void 0) return false;
667
+ if (!("pct" in value) || value["pct"] === void 0) return false;
668
+ return true;
669
+ }
670
+ function MLBLeagueRecordFromJSON(json) {
671
+ return MLBLeagueRecordFromJSONTyped(json, false);
672
+ }
673
+ function MLBLeagueRecordFromJSONTyped(json, ignoreDiscriminator) {
674
+ if (json == null) {
675
+ return json;
676
+ }
677
+ return {
678
+ "wins": json["wins"],
679
+ "losses": json["losses"],
680
+ "ties": json["ties"] == null ? void 0 : json["ties"],
681
+ "pct": json["pct"]
682
+ };
683
+ }
684
+ function MLBLeagueRecordToJSON(value) {
685
+ if (value == null) {
686
+ return value;
687
+ }
688
+ return {
689
+ "wins": value["wins"],
690
+ "losses": value["losses"],
691
+ "ties": value["ties"],
692
+ "pct": value["pct"]
693
+ };
694
+ }
695
+
696
+ // src/models/MLBGameTeam.ts
697
+ function instanceOfMLBGameTeam(value) {
698
+ if (!("score" in value) || value["score"] === void 0) return false;
699
+ if (!("team" in value) || value["team"] === void 0) return false;
700
+ if (!("isWinner" in value) || value["isWinner"] === void 0) return false;
701
+ return true;
702
+ }
703
+ function MLBGameTeamFromJSON(json) {
704
+ return MLBGameTeamFromJSONTyped(json, false);
705
+ }
706
+ function MLBGameTeamFromJSONTyped(json, ignoreDiscriminator) {
707
+ if (json == null) {
708
+ return json;
709
+ }
710
+ return {
711
+ "leagueRecord": json["leagueRecord"] == null ? void 0 : MLBLeagueRecordFromJSON(json["leagueRecord"]),
712
+ "score": json["score"],
713
+ "team": MLBTeamFromJSON(json["team"]),
714
+ "isWinner": json["isWinner"],
715
+ "splitSquad": json["splitSquad"] == null ? void 0 : json["splitSquad"],
716
+ "seriesNumber": json["seriesNumber"] == null ? void 0 : json["seriesNumber"]
717
+ };
718
+ }
719
+ function MLBGameTeamToJSON(value) {
720
+ if (value == null) {
721
+ return value;
722
+ }
723
+ return {
724
+ "leagueRecord": MLBLeagueRecordToJSON(value["leagueRecord"]),
725
+ "score": value["score"],
726
+ "team": MLBTeamToJSON(value["team"]),
727
+ "isWinner": value["isWinner"],
728
+ "splitSquad": value["splitSquad"],
729
+ "seriesNumber": value["seriesNumber"]
730
+ };
731
+ }
732
+
733
+ // src/models/MLBGameTeams.ts
734
+ function instanceOfMLBGameTeams(value) {
735
+ if (!("away" in value) || value["away"] === void 0) return false;
736
+ if (!("home" in value) || value["home"] === void 0) return false;
737
+ return true;
738
+ }
739
+ function MLBGameTeamsFromJSON(json) {
740
+ return MLBGameTeamsFromJSONTyped(json, false);
741
+ }
742
+ function MLBGameTeamsFromJSONTyped(json, ignoreDiscriminator) {
743
+ if (json == null) {
744
+ return json;
745
+ }
746
+ return {
747
+ "away": MLBGameTeamFromJSON(json["away"]),
748
+ "home": MLBGameTeamFromJSON(json["home"])
749
+ };
750
+ }
751
+ function MLBGameTeamsToJSON(value) {
752
+ if (value == null) {
753
+ return value;
754
+ }
755
+ return {
756
+ "away": MLBGameTeamToJSON(value["away"]),
757
+ "home": MLBGameTeamToJSON(value["home"])
758
+ };
759
+ }
760
+
761
+ // src/models/MLBGame.ts
762
+ var MLBGameGameTypeEnum = {
763
+ Exhibition: "E",
764
+ SpringTraining: "S",
765
+ Regular: "R",
766
+ WildCardSeries: "F",
767
+ DivisionSeries: "D",
768
+ LeagueChampionshipSeries: "L",
769
+ WorldSeries: "W"
770
+ };
771
+ function instanceOfMLBGame(value) {
772
+ if (!("gamePk" in value) || value["gamePk"] === void 0) return false;
773
+ if (!("gameGuid" in value) || value["gameGuid"] === void 0) return false;
774
+ if (!("gameType" in value) || value["gameType"] === void 0) return false;
775
+ if (!("season" in value) || value["season"] === void 0) return false;
776
+ if (!("gameDate" in value) || value["gameDate"] === void 0) return false;
777
+ if (!("officialDate" in value) || value["officialDate"] === void 0) return false;
778
+ if (!("status" in value) || value["status"] === void 0) return false;
779
+ if (!("teams" in value) || value["teams"] === void 0) return false;
780
+ if (!("gameNumber" in value) || value["gameNumber"] === void 0) return false;
781
+ if (!("gamesInSeries" in value) || value["gamesInSeries"] === void 0) return false;
782
+ if (!("seriesGameNumber" in value) || value["seriesGameNumber"] === void 0) return false;
783
+ return true;
784
+ }
785
+ function MLBGameFromJSON(json) {
786
+ return MLBGameFromJSONTyped(json, false);
787
+ }
788
+ function MLBGameFromJSONTyped(json, ignoreDiscriminator) {
789
+ if (json == null) {
790
+ return json;
791
+ }
792
+ return {
793
+ "gamePk": json["gamePk"],
794
+ "gameGuid": json["gameGuid"],
795
+ "link": json["link"] == null ? void 0 : json["link"],
796
+ "gameType": json["gameType"],
797
+ "season": json["season"],
798
+ "gameDate": json["gameDate"],
799
+ "officialDate": json["officialDate"],
800
+ "rescheduledTo": json["rescheduledTo"] == null ? void 0 : json["rescheduledTo"],
801
+ "rescheduledToDate": json["rescheduledToDate"] == null ? void 0 : json["rescheduledToDate"],
802
+ "rescheduledFrom": json["rescheduledFrom"] == null ? void 0 : json["rescheduledFrom"],
803
+ "rescheduledFromDate": json["rescheduledFromDate"] == null ? void 0 : json["rescheduledFromDate"],
804
+ "status": MLBGameStatusFromJSON(json["status"]),
805
+ "teams": MLBGameTeamsFromJSON(json["teams"]),
806
+ "venue": json["venue"] == null ? void 0 : MLBVenueFromJSON(json["venue"]),
807
+ "isTie": json["isTie"] == null ? void 0 : json["isTie"],
808
+ "gameNumber": json["gameNumber"],
809
+ "publicFacing": json["publicFacing"] == null ? void 0 : json["publicFacing"],
810
+ "doubleHeader": json["doubleHeader"] == null ? void 0 : json["doubleHeader"],
811
+ "gamedayType": json["gamedayType"] == null ? void 0 : json["gamedayType"],
812
+ "tiebreaker": json["tiebreaker"] == null ? void 0 : json["tiebreaker"],
813
+ "calendarEventID": json["calendarEventID"] == null ? void 0 : json["calendarEventID"],
814
+ "seasonDisplay": json["seasonDisplay"] == null ? void 0 : json["seasonDisplay"],
815
+ "dayNight": json["dayNight"] == null ? void 0 : json["dayNight"],
816
+ "description": json["description"] == null ? void 0 : json["description"],
817
+ "scheduledInnings": json["scheduledInnings"] == null ? void 0 : json["scheduledInnings"],
818
+ "reverseHomeAwayStatus": json["reverseHomeAwayStatus"] == null ? void 0 : json["reverseHomeAwayStatus"],
819
+ "inningBreakLength": json["inningBreakLength"] == null ? void 0 : json["inningBreakLength"],
820
+ "gamesInSeries": json["gamesInSeries"],
821
+ "seriesGameNumber": json["seriesGameNumber"],
822
+ "seriesDescription": json["seriesDescription"] == null ? void 0 : json["seriesDescription"],
823
+ "recordSource": json["recordSource"] == null ? void 0 : json["recordSource"],
824
+ "ifNecessary": json["ifNecessary"] == null ? void 0 : json["ifNecessary"],
825
+ "ifNecessaryDescription": json["ifNecessaryDescription"] == null ? void 0 : json["ifNecessaryDescription"]
826
+ };
827
+ }
828
+ function MLBGameToJSON(value) {
829
+ if (value == null) {
830
+ return value;
831
+ }
832
+ return {
833
+ "gamePk": value["gamePk"],
834
+ "gameGuid": value["gameGuid"],
835
+ "link": value["link"],
836
+ "gameType": value["gameType"],
837
+ "season": value["season"],
838
+ "gameDate": value["gameDate"],
839
+ "officialDate": value["officialDate"],
840
+ "rescheduledTo": value["rescheduledTo"],
841
+ "rescheduledToDate": value["rescheduledToDate"],
842
+ "rescheduledFrom": value["rescheduledFrom"],
843
+ "rescheduledFromDate": value["rescheduledFromDate"],
844
+ "status": MLBGameStatusToJSON(value["status"]),
845
+ "teams": MLBGameTeamsToJSON(value["teams"]),
846
+ "venue": MLBVenueToJSON(value["venue"]),
847
+ "isTie": value["isTie"],
848
+ "gameNumber": value["gameNumber"],
849
+ "publicFacing": value["publicFacing"],
850
+ "doubleHeader": value["doubleHeader"],
851
+ "gamedayType": value["gamedayType"],
852
+ "tiebreaker": value["tiebreaker"],
853
+ "calendarEventID": value["calendarEventID"],
854
+ "seasonDisplay": value["seasonDisplay"],
855
+ "dayNight": value["dayNight"],
856
+ "description": value["description"],
857
+ "scheduledInnings": value["scheduledInnings"],
858
+ "reverseHomeAwayStatus": value["reverseHomeAwayStatus"],
859
+ "inningBreakLength": value["inningBreakLength"],
860
+ "gamesInSeries": value["gamesInSeries"],
861
+ "seriesGameNumber": value["seriesGameNumber"],
862
+ "seriesDescription": value["seriesDescription"],
863
+ "recordSource": value["recordSource"],
864
+ "ifNecessary": value["ifNecessary"],
865
+ "ifNecessaryDescription": value["ifNecessaryDescription"]
866
+ };
867
+ }
868
+
869
+ // src/models/MLBStreak.ts
870
+ var MLBStreakStreakTypeEnum = {
871
+ Losing: "losses",
872
+ Winning: "wins"
873
+ };
874
+ function instanceOfMLBStreak(value) {
875
+ return true;
876
+ }
877
+ function MLBStreakFromJSON(json) {
878
+ return MLBStreakFromJSONTyped(json, false);
879
+ }
880
+ function MLBStreakFromJSONTyped(json, ignoreDiscriminator) {
881
+ if (json == null) {
882
+ return json;
883
+ }
884
+ return {
885
+ "streakType": json["streakType"] == null ? void 0 : json["streakType"]
886
+ };
887
+ }
888
+ function MLBStreakToJSON(value) {
889
+ if (value == null) {
890
+ return value;
891
+ }
892
+ return {
893
+ "streakType": value["streakType"]
894
+ };
895
+ }
896
+
897
+ // src/models/MLBRecord.ts
898
+ function instanceOfMLBRecord(value) {
899
+ if (!("team" in value) || value["team"] === void 0) return false;
900
+ if (!("season" in value) || value["season"] === void 0) return false;
901
+ if (!("streak" in value) || value["streak"] === void 0) return false;
902
+ if (!("divisionRank" in value) || value["divisionRank"] === void 0) return false;
903
+ if (!("leagueRank" in value) || value["leagueRank"] === void 0) return false;
904
+ if (!("gamesBack" in value) || value["gamesBack"] === void 0) return false;
905
+ if (!("leagueRecord" in value) || value["leagueRecord"] === void 0) return false;
906
+ if (!("wins" in value) || value["wins"] === void 0) return false;
907
+ if (!("losses" in value) || value["losses"] === void 0) return false;
908
+ return true;
909
+ }
910
+ function MLBRecordFromJSON(json) {
911
+ return MLBRecordFromJSONTyped(json, false);
912
+ }
913
+ function MLBRecordFromJSONTyped(json, ignoreDiscriminator) {
914
+ if (json == null) {
915
+ return json;
916
+ }
917
+ return {
918
+ "team": MLBTeamFromJSON(json["team"]),
919
+ "season": json["season"],
920
+ "streak": MLBStreakFromJSON(json["streak"]),
921
+ "divisionRank": json["divisionRank"],
922
+ "leagueRank": json["leagueRank"],
923
+ "sportRank": json["sportRank"] == null ? void 0 : json["sportRank"],
924
+ "gamesPlayed": json["gamesPlayed"] == null ? void 0 : json["gamesPlayed"],
925
+ "gamesBack": json["gamesBack"],
926
+ "wildCardGamesBack": json["wildCardGamesBack"] == null ? void 0 : json["wildCardGamesBack"],
927
+ "leagueGamesBack": json["leagueGamesBack"] == null ? void 0 : json["leagueGamesBack"],
928
+ "sportGamesBack": json["sportGamesBack"] == null ? void 0 : json["sportGamesBack"],
929
+ "divisionGamesBack": json["divisionGamesBack"] == null ? void 0 : json["divisionGamesBack"],
930
+ "conferenceGamesBack": json["conferenceGamesBack"] == null ? void 0 : json["conferenceGamesBack"],
931
+ "leagueRecord": MLBLeagueRecordFromJSON(json["leagueRecord"]),
932
+ "lastUpdated": json["lastUpdated"] == null ? void 0 : json["lastUpdated"],
933
+ "runsAllowed": json["runsAllowed"] == null ? void 0 : json["runsAllowed"],
934
+ "runsScored": json["runsScored"] == null ? void 0 : json["runsScored"],
935
+ "divisionChamp": json["divisionChamp"] == null ? void 0 : json["divisionChamp"],
936
+ "divisionLeader": json["divisionLeader"] == null ? void 0 : json["divisionLeader"],
937
+ "hasWildcard": json["hasWildcard"] == null ? void 0 : json["hasWildcard"],
938
+ "clinched": json["clinched"] == null ? void 0 : json["clinched"],
939
+ "eliminationNumber": json["eliminationNumber"] == null ? void 0 : json["eliminationNumber"],
940
+ "eliminationNumberSport": json["eliminationNumberSport"] == null ? void 0 : json["eliminationNumberSport"],
941
+ "eliminationNumberLeague": json["eliminationNumberLeague"] == null ? void 0 : json["eliminationNumberLeague"],
942
+ "eliminationNumberDivision": json["eliminationNumberDivision"] == null ? void 0 : json["eliminationNumberDivision"],
943
+ "eliminationNumberConference": json["eliminationNumberConference"] == null ? void 0 : json["eliminationNumberConference"],
944
+ "wildCardEliminationNumber": json["wildCardEliminationNumber"] == null ? void 0 : json["wildCardEliminationNumber"],
945
+ "magicNumber": json["magicNumber"] == null ? void 0 : json["magicNumber"],
946
+ "wins": json["wins"],
947
+ "losses": json["losses"],
948
+ "runDifferential": json["runDifferential"] == null ? void 0 : json["runDifferential"],
949
+ "winningPercentage": json["winningPercentage"] == null ? void 0 : json["winningPercentage"]
950
+ };
951
+ }
952
+ function MLBRecordToJSON(value) {
953
+ if (value == null) {
954
+ return value;
955
+ }
956
+ return {
957
+ "team": MLBTeamToJSON(value["team"]),
958
+ "season": value["season"],
959
+ "streak": MLBStreakToJSON(value["streak"]),
960
+ "divisionRank": value["divisionRank"],
961
+ "leagueRank": value["leagueRank"],
962
+ "sportRank": value["sportRank"],
963
+ "gamesPlayed": value["gamesPlayed"],
964
+ "gamesBack": value["gamesBack"],
965
+ "wildCardGamesBack": value["wildCardGamesBack"],
966
+ "leagueGamesBack": value["leagueGamesBack"],
967
+ "sportGamesBack": value["sportGamesBack"],
968
+ "divisionGamesBack": value["divisionGamesBack"],
969
+ "conferenceGamesBack": value["conferenceGamesBack"],
970
+ "leagueRecord": MLBLeagueRecordToJSON(value["leagueRecord"]),
971
+ "lastUpdated": value["lastUpdated"],
972
+ "runsAllowed": value["runsAllowed"],
973
+ "runsScored": value["runsScored"],
974
+ "divisionChamp": value["divisionChamp"],
975
+ "divisionLeader": value["divisionLeader"],
976
+ "hasWildcard": value["hasWildcard"],
977
+ "clinched": value["clinched"],
978
+ "eliminationNumber": value["eliminationNumber"],
979
+ "eliminationNumberSport": value["eliminationNumberSport"],
980
+ "eliminationNumberLeague": value["eliminationNumberLeague"],
981
+ "eliminationNumberDivision": value["eliminationNumberDivision"],
982
+ "eliminationNumberConference": value["eliminationNumberConference"],
983
+ "wildCardEliminationNumber": value["wildCardEliminationNumber"],
984
+ "magicNumber": value["magicNumber"],
985
+ "wins": value["wins"],
986
+ "losses": value["losses"],
987
+ "runDifferential": value["runDifferential"],
988
+ "winningPercentage": value["winningPercentage"]
989
+ };
990
+ }
991
+
992
+ // src/models/MLBScheduleDay.ts
993
+ function instanceOfMLBScheduleDay(value) {
994
+ if (!("games" in value) || value["games"] === void 0) return false;
995
+ return true;
996
+ }
997
+ function MLBScheduleDayFromJSON(json) {
998
+ return MLBScheduleDayFromJSONTyped(json, false);
999
+ }
1000
+ function MLBScheduleDayFromJSONTyped(json, ignoreDiscriminator) {
1001
+ if (json == null) {
1002
+ return json;
1003
+ }
1004
+ return {
1005
+ "date": json["date"] == null ? void 0 : json["date"],
1006
+ "totalItems": json["totalItems"] == null ? void 0 : json["totalItems"],
1007
+ "totalEvents": json["totalEvents"] == null ? void 0 : json["totalEvents"],
1008
+ "totalGames": json["totalGames"] == null ? void 0 : json["totalGames"],
1009
+ "totalGamesInProgress": json["totalGamesInProgress"] == null ? void 0 : json["totalGamesInProgress"],
1010
+ "games": json["games"].map(MLBGameFromJSON)
1011
+ };
1012
+ }
1013
+ function MLBScheduleDayToJSON(value) {
1014
+ if (value == null) {
1015
+ return value;
1016
+ }
1017
+ return {
1018
+ "date": value["date"],
1019
+ "totalItems": value["totalItems"],
1020
+ "totalEvents": value["totalEvents"],
1021
+ "totalGames": value["totalGames"],
1022
+ "totalGamesInProgress": value["totalGamesInProgress"],
1023
+ "games": value["games"].map(MLBGameToJSON)
1024
+ };
1025
+ }
1026
+
1027
+ // src/models/MLBSchedule.ts
1028
+ function instanceOfMLBSchedule(value) {
1029
+ if (!("totalItems" in value) || value["totalItems"] === void 0) return false;
1030
+ if (!("totalEvents" in value) || value["totalEvents"] === void 0) return false;
1031
+ if (!("totalGames" in value) || value["totalGames"] === void 0) return false;
1032
+ if (!("totalGamesInProgress" in value) || value["totalGamesInProgress"] === void 0) return false;
1033
+ if (!("dates" in value) || value["dates"] === void 0) return false;
1034
+ return true;
1035
+ }
1036
+ function MLBScheduleFromJSON(json) {
1037
+ return MLBScheduleFromJSONTyped(json, false);
1038
+ }
1039
+ function MLBScheduleFromJSONTyped(json, ignoreDiscriminator) {
1040
+ if (json == null) {
1041
+ return json;
1042
+ }
1043
+ return {
1044
+ "totalItems": json["totalItems"],
1045
+ "totalEvents": json["totalEvents"],
1046
+ "totalGames": json["totalGames"],
1047
+ "totalGamesInProgress": json["totalGamesInProgress"],
1048
+ "dates": json["dates"].map(MLBScheduleDayFromJSON)
1049
+ };
1050
+ }
1051
+ function MLBScheduleToJSON(value) {
1052
+ if (value == null) {
1053
+ return value;
1054
+ }
1055
+ return {
1056
+ "totalItems": value["totalItems"],
1057
+ "totalEvents": value["totalEvents"],
1058
+ "totalGames": value["totalGames"],
1059
+ "totalGamesInProgress": value["totalGamesInProgress"],
1060
+ "dates": value["dates"].map(MLBScheduleDayToJSON)
1061
+ };
1062
+ }
1063
+
1064
+ // src/models/MLBSeason.ts
1065
+ function instanceOfMLBSeason(value) {
1066
+ if (!("seasonId" in value) || value["seasonId"] === void 0) return false;
1067
+ if (!("seasonStartDate" in value) || value["seasonStartDate"] === void 0) return false;
1068
+ if (!("seasonEndDate" in value) || value["seasonEndDate"] === void 0) return false;
1069
+ if (!("regularSeasonStartDate" in value) || value["regularSeasonStartDate"] === void 0) return false;
1070
+ if (!("regularSeasonEndDate" in value) || value["regularSeasonEndDate"] === void 0) return false;
1071
+ return true;
1072
+ }
1073
+ function MLBSeasonFromJSON(json) {
1074
+ return MLBSeasonFromJSONTyped(json, false);
1075
+ }
1076
+ function MLBSeasonFromJSONTyped(json, ignoreDiscriminator) {
1077
+ if (json == null) {
1078
+ return json;
1079
+ }
1080
+ return {
1081
+ "seasonId": json["seasonId"],
1082
+ "hasWildcard": json["hasWildcard"] == null ? void 0 : json["hasWildcard"],
1083
+ "preSeasonStartDate": json["preSeasonStartDate"] == null ? void 0 : json["preSeasonStartDate"],
1084
+ "preSeasonEndDate": json["preSeasonEndDate"] == null ? void 0 : json["preSeasonEndDate"],
1085
+ "seasonStartDate": json["seasonStartDate"],
1086
+ "seasonEndDate": json["seasonEndDate"],
1087
+ "springStartDate": json["springStartDate"] == null ? void 0 : json["springStartDate"],
1088
+ "springEndDate": json["springEndDate"] == null ? void 0 : json["springEndDate"],
1089
+ "regularSeasonStartDate": json["regularSeasonStartDate"],
1090
+ "lastDate1stHalf": json["lastDate1stHalf"] == null ? void 0 : json["lastDate1stHalf"],
1091
+ "allStartDate": json["allStartDate"] == null ? void 0 : json["allStartDate"],
1092
+ "firstDate2ndHalf": json["firstDate2ndHalf"] == null ? void 0 : json["firstDate2ndHalf"],
1093
+ "regularSeasonEndDate": json["regularSeasonEndDate"],
1094
+ "postSeasonStartDate": json["postSeasonStartDate"] == null ? void 0 : json["postSeasonStartDate"],
1095
+ "postSeasonEndDate": json["postSeasonEndDate"] == null ? void 0 : json["postSeasonEndDate"],
1096
+ "offSeasonStartDate": json["offSeasonStartDate"] == null ? void 0 : json["offSeasonStartDate"],
1097
+ "offSeasonEndDate": json["offSeasonEndDate"] == null ? void 0 : json["offSeasonEndDate"],
1098
+ "seasonLevelGamedayType": json["seasonLevelGamedayType"] == null ? void 0 : json["seasonLevelGamedayType"],
1099
+ "gameLevelGamedayType": json["gameLevelGamedayType"] == null ? void 0 : json["gameLevelGamedayType"],
1100
+ "qualifierPlateAppearances": json["qualifierPlateAppearances"] == null ? void 0 : json["qualifierPlateAppearances"],
1101
+ "qualifierOutsPitched": json["qualifierOutsPitched"] == null ? void 0 : json["qualifierOutsPitched"]
1102
+ };
1103
+ }
1104
+ function MLBSeasonToJSON(value) {
1105
+ if (value == null) {
1106
+ return value;
1107
+ }
1108
+ return {
1109
+ "seasonId": value["seasonId"],
1110
+ "hasWildcard": value["hasWildcard"],
1111
+ "preSeasonStartDate": value["preSeasonStartDate"],
1112
+ "preSeasonEndDate": value["preSeasonEndDate"],
1113
+ "seasonStartDate": value["seasonStartDate"],
1114
+ "seasonEndDate": value["seasonEndDate"],
1115
+ "springStartDate": value["springStartDate"],
1116
+ "springEndDate": value["springEndDate"],
1117
+ "regularSeasonStartDate": value["regularSeasonStartDate"],
1118
+ "lastDate1stHalf": value["lastDate1stHalf"],
1119
+ "allStartDate": value["allStartDate"],
1120
+ "firstDate2ndHalf": value["firstDate2ndHalf"],
1121
+ "regularSeasonEndDate": value["regularSeasonEndDate"],
1122
+ "postSeasonStartDate": value["postSeasonStartDate"],
1123
+ "postSeasonEndDate": value["postSeasonEndDate"],
1124
+ "offSeasonStartDate": value["offSeasonStartDate"],
1125
+ "offSeasonEndDate": value["offSeasonEndDate"],
1126
+ "seasonLevelGamedayType": value["seasonLevelGamedayType"],
1127
+ "gameLevelGamedayType": value["gameLevelGamedayType"],
1128
+ "qualifierPlateAppearances": value["qualifierPlateAppearances"],
1129
+ "qualifierOutsPitched": value["qualifierOutsPitched"]
1130
+ };
1131
+ }
1132
+
1133
+ // src/models/MLBSeasons.ts
1134
+ function instanceOfMLBSeasons(value) {
1135
+ return true;
1136
+ }
1137
+ function MLBSeasonsFromJSON(json) {
1138
+ return MLBSeasonsFromJSONTyped(json, false);
1139
+ }
1140
+ function MLBSeasonsFromJSONTyped(json, ignoreDiscriminator) {
1141
+ if (json == null) {
1142
+ return json;
1143
+ }
1144
+ return {
1145
+ "seasons": json["seasons"] == null ? void 0 : json["seasons"].map(MLBSeasonFromJSON)
1146
+ };
1147
+ }
1148
+ function MLBSeasonsToJSON(value) {
1149
+ if (value == null) {
1150
+ return value;
1151
+ }
1152
+ return {
1153
+ "seasons": value["seasons"] == null ? void 0 : value["seasons"].map(MLBSeasonToJSON)
1154
+ };
1155
+ }
1156
+
1157
+ // src/models/MLBStandings.ts
1158
+ function instanceOfMLBStandings(value) {
1159
+ if (!("league" in value) || value["league"] === void 0) return false;
1160
+ if (!("division" in value) || value["division"] === void 0) return false;
1161
+ if (!("sport" in value) || value["sport"] === void 0) return false;
1162
+ if (!("teamRecords" in value) || value["teamRecords"] === void 0) return false;
1163
+ return true;
1164
+ }
1165
+ function MLBStandingsFromJSON(json) {
1166
+ return MLBStandingsFromJSONTyped(json, false);
1167
+ }
1168
+ function MLBStandingsFromJSONTyped(json, ignoreDiscriminator) {
1169
+ if (json == null) {
1170
+ return json;
1171
+ }
1172
+ return {
1173
+ "standingsType": json["standingsType"] == null ? void 0 : json["standingsType"],
1174
+ "league": MLBLeagueFromJSON(json["league"]),
1175
+ "division": MLBDivisionFromJSON(json["division"]),
1176
+ "sport": MLBSportFromJSON(json["sport"]),
1177
+ "lastUpdated": json["lastUpdated"] == null ? void 0 : json["lastUpdated"],
1178
+ "teamRecords": json["teamRecords"].map(MLBRecordFromJSON)
1179
+ };
1180
+ }
1181
+ function MLBStandingsToJSON(value) {
1182
+ if (value == null) {
1183
+ return value;
1184
+ }
1185
+ return {
1186
+ "standingsType": value["standingsType"],
1187
+ "league": MLBLeagueToJSON(value["league"]),
1188
+ "division": MLBDivisionToJSON(value["division"]),
1189
+ "sport": MLBSportToJSON(value["sport"]),
1190
+ "lastUpdated": value["lastUpdated"],
1191
+ "teamRecords": value["teamRecords"].map(MLBRecordToJSON)
1192
+ };
1193
+ }
1194
+
1195
+ // src/models/MLBStandingsList.ts
1196
+ function instanceOfMLBStandingsList(value) {
1197
+ return true;
1198
+ }
1199
+ function MLBStandingsListFromJSON(json) {
1200
+ return MLBStandingsListFromJSONTyped(json, false);
1201
+ }
1202
+ function MLBStandingsListFromJSONTyped(json, ignoreDiscriminator) {
1203
+ if (json == null) {
1204
+ return json;
1205
+ }
1206
+ return {
1207
+ "records": json["records"] == null ? void 0 : json["records"].map(MLBStandingsFromJSON)
1208
+ };
1209
+ }
1210
+ function MLBStandingsListToJSON(value) {
1211
+ if (value == null) {
1212
+ return value;
1213
+ }
1214
+ return {
1215
+ "records": value["records"] == null ? void 0 : value["records"].map(MLBStandingsToJSON)
1216
+ };
1217
+ }
1218
+
1219
+ // src/models/MLBTeams.ts
1220
+ function instanceOfMLBTeams(value) {
1221
+ return true;
1222
+ }
1223
+ function MLBTeamsFromJSON(json) {
1224
+ return MLBTeamsFromJSONTyped(json, false);
1225
+ }
1226
+ function MLBTeamsFromJSONTyped(json, ignoreDiscriminator) {
1227
+ if (json == null) {
1228
+ return json;
1229
+ }
1230
+ return {
1231
+ "teams": json["teams"] == null ? void 0 : json["teams"].map(MLBTeamFromJSON)
1232
+ };
1233
+ }
1234
+ function MLBTeamsToJSON(value) {
1235
+ if (value == null) {
1236
+ return value;
1237
+ }
1238
+ return {
1239
+ "teams": value["teams"] == null ? void 0 : value["teams"].map(MLBTeamToJSON)
1240
+ };
1241
+ }
1242
+
1243
+ // src/apis/MlbApi.ts
1244
+ var MlbApi = class extends BaseAPI {
1245
+ /**
1246
+ * Returns All Seasons
1247
+ * Retrieves All Seasons over time
1248
+ */
1249
+ getAllSeasonsRaw(requestParameters, initOverrides) {
1250
+ return __async(this, null, function* () {
1251
+ if (requestParameters["sportId"] == null) {
1252
+ throw new RequiredError(
1253
+ "sportId",
1254
+ 'Required parameter "sportId" was null or undefined when calling getAllSeasons().'
1255
+ );
1256
+ }
1257
+ const queryParameters = {};
1258
+ if (requestParameters["sportId"] != null) {
1259
+ queryParameters["sportId"] = requestParameters["sportId"];
1260
+ }
1261
+ const headerParameters = {};
1262
+ const response = yield this.request({
1263
+ path: `/v1/seasons/all`,
1264
+ method: "GET",
1265
+ headers: headerParameters,
1266
+ query: queryParameters
1267
+ }, initOverrides);
1268
+ return new JSONApiResponse(response, (jsonValue) => MLBSeasonsFromJSON(jsonValue));
1269
+ });
1270
+ }
1271
+ /**
1272
+ * Returns All Seasons
1273
+ * Retrieves All Seasons over time
1274
+ */
1275
+ getAllSeasons(requestParameters, initOverrides) {
1276
+ return __async(this, null, function* () {
1277
+ const response = yield this.getAllSeasonsRaw(requestParameters, initOverrides);
1278
+ return yield response.value();
1279
+ });
1280
+ }
1281
+ /**
1282
+ * Returns Schedule
1283
+ * Retrieves schedule
1284
+ */
1285
+ getScheduleRaw(requestParameters, initOverrides) {
1286
+ return __async(this, null, function* () {
1287
+ if (requestParameters["sportId"] == null) {
1288
+ throw new RequiredError(
1289
+ "sportId",
1290
+ 'Required parameter "sportId" was null or undefined when calling getSchedule().'
1291
+ );
1292
+ }
1293
+ const queryParameters = {};
1294
+ if (requestParameters["sportId"] != null) {
1295
+ queryParameters["sportId"] = requestParameters["sportId"];
1296
+ }
1297
+ if (requestParameters["teamId"] != null) {
1298
+ queryParameters["teamId"] = requestParameters["teamId"];
1299
+ }
1300
+ if (requestParameters["startDate"] != null) {
1301
+ queryParameters["startDate"] = requestParameters["startDate"];
1302
+ }
1303
+ if (requestParameters["endDate"] != null) {
1304
+ queryParameters["endDate"] = requestParameters["endDate"];
1305
+ }
1306
+ const headerParameters = {};
1307
+ const response = yield this.request({
1308
+ path: `/v1/schedule`,
1309
+ method: "GET",
1310
+ headers: headerParameters,
1311
+ query: queryParameters
1312
+ }, initOverrides);
1313
+ return new JSONApiResponse(response, (jsonValue) => MLBScheduleFromJSON(jsonValue));
1314
+ });
1315
+ }
1316
+ /**
1317
+ * Returns Schedule
1318
+ * Retrieves schedule
1319
+ */
1320
+ getSchedule(requestParameters, initOverrides) {
1321
+ return __async(this, null, function* () {
1322
+ const response = yield this.getScheduleRaw(requestParameters, initOverrides);
1323
+ return yield response.value();
1324
+ });
1325
+ }
1326
+ /**
1327
+ * Returns Season
1328
+ * Retrieves season
1329
+ */
1330
+ getSeasonRaw(requestParameters, initOverrides) {
1331
+ return __async(this, null, function* () {
1332
+ if (requestParameters["sportId"] == null) {
1333
+ throw new RequiredError(
1334
+ "sportId",
1335
+ 'Required parameter "sportId" was null or undefined when calling getSeason().'
1336
+ );
1337
+ }
1338
+ if (requestParameters["season"] == null) {
1339
+ throw new RequiredError(
1340
+ "season",
1341
+ 'Required parameter "season" was null or undefined when calling getSeason().'
1342
+ );
1343
+ }
1344
+ const queryParameters = {};
1345
+ if (requestParameters["sportId"] != null) {
1346
+ queryParameters["sportId"] = requestParameters["sportId"];
1347
+ }
1348
+ if (requestParameters["season"] != null) {
1349
+ queryParameters["season"] = requestParameters["season"];
1350
+ }
1351
+ const headerParameters = {};
1352
+ const response = yield this.request({
1353
+ path: `/v1/seasons`,
1354
+ method: "GET",
1355
+ headers: headerParameters,
1356
+ query: queryParameters
1357
+ }, initOverrides);
1358
+ return new JSONApiResponse(response, (jsonValue) => MLBSeasonFromJSON(jsonValue));
1359
+ });
1360
+ }
1361
+ /**
1362
+ * Returns Season
1363
+ * Retrieves season
1364
+ */
1365
+ getSeason(requestParameters, initOverrides) {
1366
+ return __async(this, null, function* () {
1367
+ const response = yield this.getSeasonRaw(requestParameters, initOverrides);
1368
+ return yield response.value();
1369
+ });
1370
+ }
1371
+ /**
1372
+ * Returns Standing
1373
+ * Retrieves Standings
1374
+ */
1375
+ getStandingsRaw(requestParameters, initOverrides) {
1376
+ return __async(this, null, function* () {
1377
+ if (requestParameters["leagueId"] == null) {
1378
+ throw new RequiredError(
1379
+ "leagueId",
1380
+ 'Required parameter "leagueId" was null or undefined when calling getStandings().'
1381
+ );
1382
+ }
1383
+ if (requestParameters["season"] == null) {
1384
+ throw new RequiredError(
1385
+ "season",
1386
+ 'Required parameter "season" was null or undefined when calling getStandings().'
1387
+ );
1388
+ }
1389
+ const queryParameters = {};
1390
+ if (requestParameters["leagueId"] != null) {
1391
+ queryParameters["leagueId"] = requestParameters["leagueId"];
1392
+ }
1393
+ if (requestParameters["season"] != null) {
1394
+ queryParameters["season"] = requestParameters["season"];
1395
+ }
1396
+ if (requestParameters["date"] != null) {
1397
+ queryParameters["date"] = requestParameters["date"];
1398
+ }
1399
+ if (requestParameters["fields"] != null) {
1400
+ queryParameters["fields"] = requestParameters["fields"].join(COLLECTION_FORMATS["csv"]);
1401
+ }
1402
+ if (requestParameters["hydrate"] != null) {
1403
+ queryParameters["hydrate"] = requestParameters["hydrate"];
1404
+ }
1405
+ const headerParameters = {};
1406
+ const response = yield this.request({
1407
+ path: `/v1/standings`,
1408
+ method: "GET",
1409
+ headers: headerParameters,
1410
+ query: queryParameters
1411
+ }, initOverrides);
1412
+ return new JSONApiResponse(response, (jsonValue) => MLBStandingsListFromJSON(jsonValue));
1413
+ });
1414
+ }
1415
+ /**
1416
+ * Returns Standing
1417
+ * Retrieves Standings
1418
+ */
1419
+ getStandings(requestParameters, initOverrides) {
1420
+ return __async(this, null, function* () {
1421
+ const response = yield this.getStandingsRaw(requestParameters, initOverrides);
1422
+ return yield response.value();
1423
+ });
1424
+ }
1425
+ /**
1426
+ * Returns Teams
1427
+ * Retrieves Teams
1428
+ */
1429
+ getTeamsRaw(requestParameters, initOverrides) {
1430
+ return __async(this, null, function* () {
1431
+ if (requestParameters["sportId"] == null) {
1432
+ throw new RequiredError(
1433
+ "sportId",
1434
+ 'Required parameter "sportId" was null or undefined when calling getTeams().'
1435
+ );
1436
+ }
1437
+ if (requestParameters["season"] == null) {
1438
+ throw new RequiredError(
1439
+ "season",
1440
+ 'Required parameter "season" was null or undefined when calling getTeams().'
1441
+ );
1442
+ }
1443
+ const queryParameters = {};
1444
+ if (requestParameters["sportId"] != null) {
1445
+ queryParameters["sportId"] = requestParameters["sportId"];
1446
+ }
1447
+ if (requestParameters["season"] != null) {
1448
+ queryParameters["season"] = requestParameters["season"];
1449
+ }
1450
+ if (requestParameters["leagueIds"] != null) {
1451
+ queryParameters["leagueIds"] = requestParameters["leagueIds"];
1452
+ }
1453
+ const headerParameters = {};
1454
+ const response = yield this.request({
1455
+ path: `/v1/teams`,
1456
+ method: "GET",
1457
+ headers: headerParameters,
1458
+ query: queryParameters
1459
+ }, initOverrides);
1460
+ return new JSONApiResponse(response, (jsonValue) => MLBTeamsFromJSON(jsonValue));
1461
+ });
1462
+ }
1463
+ /**
1464
+ * Returns Teams
1465
+ * Retrieves Teams
1466
+ */
1467
+ getTeams(requestParameters, initOverrides) {
1468
+ return __async(this, null, function* () {
1469
+ const response = yield this.getTeamsRaw(requestParameters, initOverrides);
1470
+ return yield response.value();
1471
+ });
1472
+ }
1473
+ };
1474
+ export {
1475
+ BASE_PATH,
1476
+ BaseAPI,
1477
+ BlobApiResponse,
1478
+ COLLECTION_FORMATS,
1479
+ Configuration,
1480
+ DefaultConfig,
1481
+ FetchError,
1482
+ JSONApiResponse,
1483
+ MLBDivisionFromJSON,
1484
+ MLBDivisionFromJSONTyped,
1485
+ MLBDivisionToJSON,
1486
+ MLBGameFromJSON,
1487
+ MLBGameFromJSONTyped,
1488
+ MLBGameGameTypeEnum,
1489
+ MLBGameStatusCodedGameStateEnum,
1490
+ MLBGameStatusFromJSON,
1491
+ MLBGameStatusFromJSONTyped,
1492
+ MLBGameStatusToJSON,
1493
+ MLBGameTeamFromJSON,
1494
+ MLBGameTeamFromJSONTyped,
1495
+ MLBGameTeamToJSON,
1496
+ MLBGameTeamsFromJSON,
1497
+ MLBGameTeamsFromJSONTyped,
1498
+ MLBGameTeamsToJSON,
1499
+ MLBGameToJSON,
1500
+ MLBLeagueDatesFromJSON,
1501
+ MLBLeagueDatesFromJSONTyped,
1502
+ MLBLeagueDatesToJSON,
1503
+ MLBLeagueFromJSON,
1504
+ MLBLeagueFromJSONTyped,
1505
+ MLBLeagueRecordFromJSON,
1506
+ MLBLeagueRecordFromJSONTyped,
1507
+ MLBLeagueRecordToJSON,
1508
+ MLBLeagueToJSON,
1509
+ MLBRecordFromJSON,
1510
+ MLBRecordFromJSONTyped,
1511
+ MLBRecordToJSON,
1512
+ MLBScheduleDayFromJSON,
1513
+ MLBScheduleDayFromJSONTyped,
1514
+ MLBScheduleDayToJSON,
1515
+ MLBScheduleFromJSON,
1516
+ MLBScheduleFromJSONTyped,
1517
+ MLBScheduleToJSON,
1518
+ MLBSeasonFromJSON,
1519
+ MLBSeasonFromJSONTyped,
1520
+ MLBSeasonToJSON,
1521
+ MLBSeasonsFromJSON,
1522
+ MLBSeasonsFromJSONTyped,
1523
+ MLBSeasonsToJSON,
1524
+ MLBSportFromJSON,
1525
+ MLBSportFromJSONTyped,
1526
+ MLBSportToJSON,
1527
+ MLBStandingsFromJSON,
1528
+ MLBStandingsFromJSONTyped,
1529
+ MLBStandingsListFromJSON,
1530
+ MLBStandingsListFromJSONTyped,
1531
+ MLBStandingsListToJSON,
1532
+ MLBStandingsToJSON,
1533
+ MLBStreakFromJSON,
1534
+ MLBStreakFromJSONTyped,
1535
+ MLBStreakStreakTypeEnum,
1536
+ MLBStreakToJSON,
1537
+ MLBTeamFromJSON,
1538
+ MLBTeamFromJSONTyped,
1539
+ MLBTeamToJSON,
1540
+ MLBTeamsFromJSON,
1541
+ MLBTeamsFromJSONTyped,
1542
+ MLBTeamsToJSON,
1543
+ MLBVenueFromJSON,
1544
+ MLBVenueFromJSONTyped,
1545
+ MLBVenueToJSON,
1546
+ MlbApi,
1547
+ RequiredError,
1548
+ ResponseError,
1549
+ TextApiResponse,
1550
+ VoidApiResponse,
1551
+ canConsumeForm,
1552
+ instanceOfMLBDivision,
1553
+ instanceOfMLBGame,
1554
+ instanceOfMLBGameStatus,
1555
+ instanceOfMLBGameTeam,
1556
+ instanceOfMLBGameTeams,
1557
+ instanceOfMLBLeague,
1558
+ instanceOfMLBLeagueDates,
1559
+ instanceOfMLBLeagueRecord,
1560
+ instanceOfMLBRecord,
1561
+ instanceOfMLBSchedule,
1562
+ instanceOfMLBScheduleDay,
1563
+ instanceOfMLBSeason,
1564
+ instanceOfMLBSeasons,
1565
+ instanceOfMLBSport,
1566
+ instanceOfMLBStandings,
1567
+ instanceOfMLBStandingsList,
1568
+ instanceOfMLBStreak,
1569
+ instanceOfMLBTeam,
1570
+ instanceOfMLBTeams,
1571
+ instanceOfMLBVenue,
1572
+ mapValues,
1573
+ querystring
1574
+ };