mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-20 02:00:49 +00:00
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
|
export namespace helix {
|
||
|
|
||
|
export class User {
|
||
|
id: string;
|
||
|
login: string;
|
||
|
display_name: string;
|
||
|
type: string;
|
||
|
broadcaster_type: string;
|
||
|
description: string;
|
||
|
profile_image_url: string;
|
||
|
offline_image_url: string;
|
||
|
view_count: number;
|
||
|
email: string;
|
||
|
// Go type: Time
|
||
|
created_at: any;
|
||
|
|
||
|
static createFrom(source: any = {}) {
|
||
|
return new User(source);
|
||
|
}
|
||
|
|
||
|
constructor(source: any = {}) {
|
||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||
|
this.id = source["id"];
|
||
|
this.login = source["login"];
|
||
|
this.display_name = source["display_name"];
|
||
|
this.type = source["type"];
|
||
|
this.broadcaster_type = source["broadcaster_type"];
|
||
|
this.description = source["description"];
|
||
|
this.profile_image_url = source["profile_image_url"];
|
||
|
this.offline_image_url = source["offline_image_url"];
|
||
|
this.view_count = source["view_count"];
|
||
|
this.email = source["email"];
|
||
|
this.created_at = this.convertValues(source["created_at"], null);
|
||
|
}
|
||
|
|
||
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||
|
if (!a) {
|
||
|
return a;
|
||
|
}
|
||
|
if (a.slice) {
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|