-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathindex.js
More file actions
22 lines (19 loc) · 784 Bytes
/
Copy pathindex.js
File metadata and controls
22 lines (19 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';
const resources = require('./src/resources');
class MLBStatsAPI {
constructor(host = 'https://statsapi.mlb.com/api/') {
this.host = host;
this.apiHost = host + 'v1/';
/* All functions assume first argument are the query parameters named params, and the second argument is an object containing
* named path parameters, pathParams (ie {pathParams: {teamId: 111, leagueId: 103}})
*/
for (const resource in resources) {
for (const func of Object.getOwnPropertyNames(resources[resource].prototype)) {
if (func !== 'constructor') {
this[func] = resources[resource].prototype[func].bind(this);
}
}
}
}
}
module.exports = MLBStatsAPI;