Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update League object with current matchup and scoring period IDs #231

Merged
merged 2 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "espn-fantasy-football-api",
"version": "1.2.0",
"version": "1.3.0",
"description": "A Javascript API to connect to ESPN's fantasy football API",
"main": "web.js",
"files": [
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