diff --git a/src/api/apis/BoardGameGeekAPI.ts b/src/api/apis/BoardGameGeekAPI.ts index 25385db..174bbff 100644 --- a/src/api/apis/BoardGameGeekAPI.ts +++ b/src/api/apis/BoardGameGeekAPI.ts @@ -39,8 +39,8 @@ export class BoardGameGeekAPI extends APIModel { let ret: MediaTypeModel[] = []; for (const boardgame of Array.from(response.querySelectorAll("boardgame"))) { - const id = boardgame.attributes.getNamedItem("objectid").value; - const title = boardgame.querySelector("name").textContent; + const id = boardgame.attributes.getNamedItem("objectid")!.value; + const title = boardgame.querySelector("name")!.textContent!; const year = boardgame.querySelector("yearpublished")?.textContent ?? ""; ret.push(new BoardGameModel({ @@ -71,12 +71,12 @@ export class BoardGameGeekAPI extends APIModel { const response = new window.DOMParser().parseFromString(data, "text/xml") debugLog(response); - const boardgame = response.querySelector("boardgame"); - const title = boardgame.querySelector("name").textContent; - const year = boardgame.querySelector("yearpublished").textContent; - const image = boardgame.querySelector("image").textContent; - const onlineRating = Number.parseFloat(boardgame.querySelector("statistics ratings average").textContent); - const genres = Array.from(boardgame.querySelectorAll("boardgamecategory")).map(n => n.textContent); + const boardgame = response.querySelector("boardgame")!; + const title = boardgame.querySelector("name")!.textContent!; + const year = boardgame.querySelector("yearpublished")?.textContent ?? ""; + const image = boardgame.querySelector("image")?.textContent ?? undefined; + const onlineRating = Number.parseFloat(boardgame.querySelector("statistics ratings average")?.textContent ?? ""); + const genres = Array.from(boardgame.querySelectorAll("boardgamecategory")).map(n => n!.textContent!); const model = new BoardGameModel({ type: MediaType.BoardGame, diff --git a/src/models/BoardGameModel.ts b/src/models/BoardGameModel.ts index 3f5c1e4..8406cea 100644 --- a/src/models/BoardGameModel.ts +++ b/src/models/BoardGameModel.ts @@ -4,17 +4,9 @@ import {MediaType} from '../utils/MediaType'; export class BoardGameModel extends MediaTypeModel { - type: string; - title: string; - englishTitle: string; - year: string; - dataSource: string; - url: string; - id: string; - genres: string[]; onlineRating: number; - image: string; + image?: string; released: boolean;