mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-30 02:40:33 +00:00
144 lines
3.7 KiB
TypeScript
144 lines
3.7 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;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export namespace main {
|
|
|
|
export class BackupInfo {
|
|
filename: string;
|
|
date: number;
|
|
size: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new BackupInfo(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.filename = source["filename"];
|
|
this.date = source["date"];
|
|
this.size = source["size"];
|
|
}
|
|
}
|
|
export class LogEntry {
|
|
id: string;
|
|
time: string;
|
|
level: string;
|
|
message: string;
|
|
data: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new LogEntry(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.id = source["id"];
|
|
this.time = source["time"];
|
|
this.level = source["level"];
|
|
this.message = source["message"];
|
|
this.data = source["data"];
|
|
}
|
|
}
|
|
export class Problem {
|
|
id: string;
|
|
details: any;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new Problem(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.id = source["id"];
|
|
this.details = source["details"];
|
|
}
|
|
}
|
|
export class VersionInfo {
|
|
release: string;
|
|
// Go type: debug
|
|
build?: any;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new VersionInfo(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.release = source["release"];
|
|
this.build = this.convertValues(source["build"], 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;
|
|
}
|
|
}
|
|
|
|
}
|
|
|