helldivers2-api
Advanced tools
Comparing version 1.0.7 to 1.0.9
@@ -14,3 +14,6 @@ { | ||
"no-unused-vars": "off" | ||
} | ||
}, | ||
"ignorePatterns": [ | ||
"src/repository/GameAssetMapper.js" | ||
] | ||
} |
@@ -7,5 +7,6 @@ import WarSeasonRepository from "./src/repository/WarSeasonRepository.js"; | ||
import WarTimeRepository from "./src/repository/WarTimeRepository.js"; | ||
import StatisticsRepository from "./src/repository/StatisticsRepository.js"; | ||
export default { | ||
getWarSeason: (warId) => WarSeasonRepository.getById(warId), | ||
getWar: (warId) => WarSeasonRepository.getById(warId), | ||
getWarInfo: (warId) => WarInfoRepository.getById(warId), | ||
@@ -16,2 +17,4 @@ getWarNewsFeed: (warId, timestamp = null) => WarNewsFeedRepository.getByWarId(warId, timestamp), | ||
getWarTime: (warId) => WarTimeRepository.getWarTime(warId), | ||
getWarTimeSinceStart: (warId) => WarTimeRepository.getWarTimeSinceStart(warId), | ||
getWarSummary: (warId) => StatisticsRepository.getWarSummary(warId), | ||
} |
{ | ||
"name": "helldivers2-api", | ||
"version": "1.0.7", | ||
"version": "1.0.9", | ||
"description": "An API wrapper for Helldivers 2", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,8 +13,31 @@ # Helldivers 2 API | ||
- [X] Get current war id | ||
- [X] Get war season | ||
- [X] Get war statistics | ||
- [X] Get war info | ||
- [X] Get war news feed | ||
- [X] Get war summary (galaxy & planet statistics) | ||
- [X] Get war main order | ||
- [ ] Player endpoints | ||
- [ ] Global statistics endpoints | ||
### Usage example | ||
Simply import the module and call the available methods. All of them return promises. | ||
```javascript | ||
import helldivers2 from "helldivers2-api"; | ||
const currentWarId = await helldivers2.getCurrentWarId(); | ||
const warInfo = await helldivers2.getWarInfo(currentWarId); | ||
console.log('War started on ' + warInfo.startDate); | ||
const newsFeed = await helldivers2.getWarNewsFeed(currentWarId); | ||
newsFeed.forEach((article) => { | ||
console.log(article.message); | ||
}); | ||
// ... | ||
``` | ||
### Contributing | ||
@@ -21,0 +44,0 @@ |
@@ -15,3 +15,3 @@ import WarInfo from "../model/WarInfo.js"; | ||
warInfo.warId = body['warId']; | ||
warInfo.id = body['warId']; | ||
warInfo.startDate = body['startDate']; | ||
@@ -18,0 +18,0 @@ warInfo.endDate = body['endDate']; |
@@ -7,7 +7,5 @@ import WarSeason from "../model/WarSeason.js"; | ||
import PlanetEvent from "../model/WarSeason/PlanetEvent.js"; | ||
import planetAttack from "../model/WarSeason/PlanetAttack.js"; | ||
import GlobalEvent from "../model/WarSeason/GlobalEvent.js"; | ||
import PlanetDenormaliser from "./Common/PlanetDenormaliser.js"; | ||
import RaceDenormaliser from "./Common/RaceDenormaliser.js"; | ||
import GameAssetMapper from "../repository/GameAssetMapper.js"; | ||
@@ -22,3 +20,3 @@ export default class WarSeasonDenormaliser { | ||
warSeason.warId = body['warId']; | ||
warSeason.id = body['warId']; | ||
warSeason.time = body['time']; | ||
@@ -25,0 +23,0 @@ warSeason.impactMultiplier = body['impactMultiplier']; |
@@ -10,3 +10,3 @@ import PlanetStatus from "./WarSeason/PlanetStatus.js"; | ||
/** @type number */ | ||
warId; | ||
id; | ||
/** @type number */ | ||
@@ -13,0 +13,0 @@ time; |
@@ -9,8 +9,8 @@ import HTTPClient from "../HTTPClient.js"; | ||
/** | ||
* @param warSeasonId | ||
* @param warId | ||
* @returns {Promise<WarInfo>} | ||
*/ | ||
static async getById(warSeasonId) { | ||
static async getById(warId) { | ||
try { | ||
const response = await HTTPClient.getInstance().get('/api/WarSeason/' + warSeasonId + '/WarInfo'); | ||
const response = await HTTPClient.getInstance().get('/api/WarSeason/' + warId + '/WarInfo'); | ||
@@ -20,3 +20,3 @@ return WarInfoDenormaliser.denormaliseWarInfo(response.data) | ||
if (error.response.status === 400 || error.response.status === 404) { | ||
throw new HttpNotFoundException(`WarSeason with ID ${warSeasonId} not found.`); | ||
throw new HttpNotFoundException(`War with ID ${warId} not found.`); | ||
} else { | ||
@@ -23,0 +23,0 @@ throw new HttpErrorException('An error occurred.', error.response.status, error.response); |
@@ -9,10 +9,10 @@ import HTTPClient from "../HTTPClient.js"; | ||
/** | ||
* @param {number} warSeasonId | ||
* @param {number} warId | ||
* @param {number|null} fromTimestamp | ||
* @returns {Promise<NewsFeedMessage[]>} | ||
*/ | ||
static async getByWarId(warSeasonId, fromTimestamp = null) { | ||
static async getByWarId(warId, fromTimestamp = null) { | ||
try { | ||
const params = fromTimestamp ? { fromTimestamp: fromTimestamp } : {}; | ||
const response = await HTTPClient.getInstance().get('/api/NewsFeed/' + warSeasonId, { | ||
const response = await HTTPClient.getInstance().get('/api/NewsFeed/' + warId, { | ||
params: params | ||
@@ -24,3 +24,3 @@ }); | ||
if (error.response.status === 400 || error.response.status === 404) { | ||
throw new HttpNotFoundException(`WarSeason with ID ${warSeasonId} not found.`); | ||
throw new HttpNotFoundException(`War with ID ${warId} not found.`); | ||
} else { | ||
@@ -27,0 +27,0 @@ throw new HttpErrorException('An error occurred.', error.response.status, error.response); |
@@ -9,8 +9,8 @@ import HTTPClient from "../HTTPClient.js"; | ||
/** | ||
* @param {number} warSeasonId | ||
* @param {number} warId | ||
* @returns {Promise<WarSeason>} | ||
*/ | ||
static async getById(warSeasonId) { | ||
static async getById(warId) { | ||
try { | ||
const response = await HTTPClient.getInstance().get('/api/WarSeason/' + warSeasonId + '/Status'); | ||
const response = await HTTPClient.getInstance().get('/api/WarSeason/' + warId + '/Status'); | ||
@@ -20,3 +20,3 @@ return WarSeasonDenormaliser.denormaliseWarSeason(response.data) | ||
if (error.response.status === 400 || error.response.status === 404) { | ||
throw new HttpNotFoundException(`WarSeason with ID ${warSeasonId} not found.`); | ||
throw new HttpNotFoundException(`War with ID ${warId} not found.`); | ||
} else { | ||
@@ -23,0 +23,0 @@ throw new HttpErrorException('An error occurred.', error.response.status, error.response); |
@@ -23,2 +23,20 @@ import HTTPClient from "../HTTPClient.js"; | ||
} | ||
/** | ||
* @param {number} warId | ||
* @returns {Promise<number>} | ||
*/ | ||
static async getWarTimeSinceStart(warId) { | ||
try { | ||
const response = await HTTPClient.getInstance().get('/api/WarSeason/' + warId + '/TimeSinceStart'); | ||
return response['data']['secondsSinceStart']; | ||
} catch (error) { | ||
if (error.response.status === 400 || error.response.status === 404) { | ||
throw new HttpNotFoundException(`War with ID ${warId} not found.`); | ||
} else { | ||
throw new HttpErrorException('An error occurred.', error.response.status, error.response); | ||
} | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
76978
59
3743
49
0