From 0a51f5c2390c4ef87c7f4bad5ce3aa89d8e13011 Mon Sep 17 00:00:00 2001 From: MillenniumEarl Date: Wed, 3 Mar 2021 11:31:58 +0100 Subject: [PATCH] Add setID method and check for id validation in fetch() --- src/scripts/classes/mapping/platform-user.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/scripts/classes/mapping/platform-user.ts b/src/scripts/classes/mapping/platform-user.ts index 4d6b3fc..936f989 100644 --- a/src/scripts/classes/mapping/platform-user.ts +++ b/src/scripts/classes/mapping/platform-user.ts @@ -94,11 +94,18 @@ export default class PlatformUser { //#endregion Getters - constructor(id: number) { this._id = id; } + constructor() + constructor(id: number) + constructor(id: number = undefined) { this._id = id; } //#region Public methods + public setID(id: number) { this._id = id; } + public async fetch() { + // Check ID + if (!this.id && this.id < 1) throw new Error("Invalid user ID"); + // Prepare the URL const url = new URL(this.id.toString(), `${urls.F95_MEMBERS}/`).toString();