107 lines
3.0 KiB
TypeScript
107 lines
3.0 KiB
TypeScript
export namespace main {
|
|
|
|
export class CharacterInfo {
|
|
character_id: number;
|
|
character_name: string;
|
|
waypoint_enabled: boolean;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new CharacterInfo(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.character_id = source["character_id"];
|
|
this.character_name = source["character_name"];
|
|
this.waypoint_enabled = source["waypoint_enabled"];
|
|
}
|
|
}
|
|
export class CharacterLocation {
|
|
character_id: number;
|
|
character_name: string;
|
|
solar_system_id: number;
|
|
solar_system_name: string;
|
|
// Go type: time
|
|
retrieved_at: any;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new CharacterLocation(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.character_id = source["character_id"];
|
|
this.character_name = source["character_name"];
|
|
this.solar_system_id = source["solar_system_id"];
|
|
this.solar_system_name = source["solar_system_name"];
|
|
this.retrieved_at = this.convertValues(source["retrieved_at"], null);
|
|
}
|
|
|
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
if (!a) {
|
|
return a;
|
|
}
|
|
if (a.slice && a.map) {
|
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
|
} else if ("object" === typeof a) {
|
|
if (asMap) {
|
|
for (const key of Object.keys(a)) {
|
|
a[key] = new classs(a[key]);
|
|
}
|
|
return a;
|
|
}
|
|
return new classs(a);
|
|
}
|
|
return a;
|
|
}
|
|
}
|
|
export class SystemJumps {
|
|
system_id: number;
|
|
ship_jumps: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SystemJumps(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.system_id = source["system_id"];
|
|
this.ship_jumps = source["ship_jumps"];
|
|
}
|
|
}
|
|
export class SystemKills {
|
|
system_id: number;
|
|
ship_kills: number;
|
|
pod_kills: number;
|
|
npc_kills: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SystemKills(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.system_id = source["system_id"];
|
|
this.ship_kills = source["ship_kills"];
|
|
this.pod_kills = source["pod_kills"];
|
|
this.npc_kills = source["npc_kills"];
|
|
}
|
|
}
|
|
export class SystemRegion {
|
|
system: string;
|
|
region: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SystemRegion(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.system = source["system"];
|
|
this.region = source["region"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|