diff --git a/integration-tests/2018-season/__snapshots__/integration.test.js.snap b/integration-tests/2018-season/__snapshots__/integration.test.js.snap index 79f1eea..8ca1e50 100644 --- a/integration-tests/2018-season/__snapshots__/integration.test.js.snap +++ b/integration-tests/2018-season/__snapshots__/integration.test.js.snap @@ -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, diff --git a/integration-tests/2022-season/__snapshots__/integration.test.js.snap b/integration-tests/2022-season/__snapshots__/integration.test.js.snap index 84b5e5a..e76d798 100644 --- a/integration-tests/2022-season/__snapshots__/integration.test.js.snap +++ b/integration-tests/2022-season/__snapshots__/integration.test.js.snap @@ -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, diff --git a/package-lock.json b/package-lock.json index 988ae40..ebe1bea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "espn-fantasy-football-api", - "version": "1.2.0", + "version": "1.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "espn-fantasy-football-api", - "version": "1.2.0", + "version": "1.3.0", "license": "LGPL-3.0-only", "dependencies": { "axios": "^1.5.0", diff --git a/package.json b/package.json index f406e31..9c585db 100644 --- a/package.json +++ b/package.json @@ -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": [ diff --git a/src/client/client.js b/src/client/client.js index fc1f04a..1c30fb3 100644 --- a/src/client/client.js +++ b/src/client/client.js @@ -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 }); }); } diff --git a/src/client/client.test.js b/src/client/client.test.js index 0886459..1e01436 100644 --- a/src/client/client.test.js +++ b/src/client/client.test.js @@ -719,6 +719,10 @@ describe('Client', () => { draftSettings: {}, rosterSettings: {}, scheduleSettings: {} + }, + status: { + currentMatchupPeriod: 7, + latestScoringPeriod: 7 } } }; diff --git a/src/league/league.js b/src/league/league.js index c3362dc..1291152 100644 --- a/src/league/league.js +++ b/src/league/league.js @@ -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) */ /** @@ -65,6 +69,9 @@ class League extends BaseObject { size: 'size', isPublic: 'isPublic', + currentMatchupPeriodId: 'currentMatchupPeriodId', + currentScoringPeriodId: 'currentScoringPeriodId', + draftSettings: { key: 'draftSettings', manualParse: (responseData) => ({