Skip to content

Commit

Permalink
Update id-lookup APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tfedor committed Mar 16, 2024
1 parent c6ab376 commit c03a7b6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/js/Background/Modules/IsThereAnyDeal/ITADApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,21 @@ class ITADApi extends Api {
return true;
}

static async _fetchSteamIds(gids) {
let response = await fetch(new URL("unstable/id-lookup/steam/v1", Config.ITADApiServerHost), {
static async _fetchSteamIds(gids: string[]) {
let response = await fetch(new URL("unstable/id-lookup/shop/61/v2", Config.ITADApiServerHost), {
method: "POST",
headers: {"content-type": "application/json"},
body: JSON.stringify(gids)
});

if (response.ok) {
let obj = await response.json();
let map = new Map();
for (let [itad, steam] of Object.entries(obj)) {
if (steam !== null) {
map.set(steam, itad);
let map: Map<string, string> = new Map();
for (let [itad, steamIds] of <[string, string[]|null][]>Object.entries(obj)) {
if (steamIds !== null) {
for (let steamId of steamIds) {
map.set(steamId, itad);
}
}
}
return map;
Expand All @@ -168,8 +170,8 @@ class ITADApi extends Api {
throw new Errors.HTTPError(response.status, response.statusText);
}

static async _fetchGameIds(steamIds) {
let response = await fetch(new URL("unstable/id-lookup/game/v1", Config.ITADApiServerHost), {
static async _fetchGameIds(steamIds: string[]) {
let response = await fetch(new URL("unstable/id-lookup/itad/61/v2", Config.ITADApiServerHost), {
method: "POST",
headers: {"content-type": "application/json"},
body: JSON.stringify(steamIds)
Expand All @@ -178,7 +180,7 @@ class ITADApi extends Api {
if (response.ok) {
let obj = await response.json();
let map = new Map();
for (let [steam, itad] of Object.entries(obj)) {
for (let [steam, itad] of <[string, string|null][]>Object.entries(obj)) {
if (itad !== null) {
map.set(steam, itad);
}
Expand Down

0 comments on commit c03a7b6

Please sign in to comment.