Skip to content

Commit

Permalink
Update League object with current matchup and scoring period IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
mkreiser committed Oct 22, 2023
1 parent f8d037b commit a384690
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44858,6 +44858,8 @@ exports[`2018 season client integration tests getFreeAgents returns a populated

exports[`2018 season client integration tests getLeagueInfo returns a populated League instance 1`] = `
League {
"currentMatchupPeriodId": 15,
"currentScoringPeriodId": 18,
"draftSettings": {
"canTradeDraftPicks": false,
"date": 2018-08-28T17:15:00.000Z,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49605,6 +49605,8 @@ exports[`2022 season client integration tests getFreeAgents returns a populated

exports[`2022 season client integration tests getLeagueInfo returns a populated League instance 1`] = `
League {
"currentMatchupPeriodId": 17,
"currentScoringPeriodId": 19,
"draftSettings": {
"canTradeDraftPicks": true,
"date": 2022-08-27T01:00:00.000Z,
Expand Down
9 changes: 8 additions & 1 deletion src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,14 @@ class Client {
});

return axios.get(route, this._buildAxiosConfig()).then((response) => {
const data = _.get(response.data, 'settings');
const settingsData = _.get(response.data, 'settings');
const statusData = _.get(response.data, 'status');
const data = {
currentMatchupPeriodId: statusData.currentMatchupPeriod,
currentScoringPeriodId: statusData.latestScoringPeriod,
...settingsData
};

return League.buildFromServer(data, { leagueId: this.leagueId, seasonId });
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/client/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,10 @@ describe('Client', () => {
draftSettings: {},
rosterSettings: {},
scheduleSettings: {}
},
status: {
currentMatchupPeriod: 7,
latestScoringPeriod: 7
}
}
};
Expand Down
7 changes: 7 additions & 0 deletions src/league/league.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class League extends BaseObject {
* @property {DRAFT_TYPE} type The type of draft.
* @property {number} timePerPick The amount of time to make a selection.
* @property {boolean} canTradeDraftPicks Whether or not draft picks can be traded.
* @property {number} currentMatchupPeriodId The current matchup period id (see README.md for
* matchupPeriod v. scoringPeriod)
* @property {number} currentScoringPeriodId The current scoring period id (see README.md for
* matchupPeriod v. scoringPeriod)
*/

/**
Expand Down Expand Up @@ -65,6 +69,9 @@ class League extends BaseObject {
size: 'size',
isPublic: 'isPublic',

currentMatchupPeriodId: 'currentMatchupPeriodId',
currentScoringPeriodId: 'currentScoringPeriodId',

draftSettings: {
key: 'draftSettings',
manualParse: (responseData) => ({
Expand Down

0 comments on commit a384690

Please sign in to comment.