2025-02-10 13:00:00 +01:00
|
|
|
export namespace model {
|
2025-02-03 19:07:21 +01:00
|
|
|
|
2025-02-10 13:00:00 +01:00
|
|
|
export class SubThing {
|
|
|
|
ID: number;
|
|
|
|
ThingID: number;
|
|
|
|
Name: string;
|
|
|
|
|
|
|
|
static createFrom(source: any = {}) {
|
|
|
|
return new SubThing(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(source: any = {}) {
|
|
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
|
|
this.ID = source["ID"];
|
|
|
|
this.ThingID = source["ThingID"];
|
|
|
|
this.Name = source["Name"];
|
|
|
|
}
|
|
|
|
}
|
2025-02-03 19:07:21 +01:00
|
|
|
export class Thing {
|
|
|
|
ID: number;
|
|
|
|
Name: string;
|
2025-02-10 13:00:00 +01:00
|
|
|
Subthings: SubThing[];
|
2025-02-03 19:07:21 +01:00
|
|
|
|
|
|
|
static createFrom(source: any = {}) {
|
|
|
|
return new Thing(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(source: any = {}) {
|
|
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
|
|
this.ID = source["ID"];
|
|
|
|
this.Name = source["Name"];
|
2025-02-10 13:00:00 +01:00
|
|
|
this.Subthings = this.convertValues(source["Subthings"], SubThing);
|
2025-02-03 19:07:21 +01:00
|
|
|
}
|
2025-02-10 13:00:00 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2025-02-03 19:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|