added simkl login to backend

This commit is contained in:
2024-07-30 12:59:06 -04:00
parent c6972ad765
commit 237958cce5
6 changed files with 256 additions and 0 deletions

View File

@ -14,4 +14,8 @@ export function GetAniListLoggedInUserId():Promise<main.AniListUser>;
export function GetAniListUserWatchingList(arg1:number,arg2:number,arg3:string):Promise<main.AniListCurrentUserWatchList>;
export function GetSimklLoggedInUserId():Promise<main.SimklUser>;
export function Greet(arg1:string):Promise<string>;
export function SimklLogin():Promise<void>;

View File

@ -26,6 +26,14 @@ export function GetAniListUserWatchingList(arg1, arg2, arg3) {
return window['go']['main']['App']['GetAniListUserWatchingList'](arg1, arg2, arg3);
}
export function GetSimklLoggedInUserId() {
return window['go']['main']['App']['GetSimklLoggedInUserId']();
}
export function Greet(arg1) {
return window['go']['main']['App']['Greet'](arg1);
}
export function SimklLogin() {
return window['go']['main']['App']['SimklLogin']();
}

View File

@ -147,6 +147,37 @@ export namespace main {
return a;
}
}
export class SimklUser {
// Go type: struct { Viewer struct { ID int "json:\"id\""; Name string "json:\"name\"" } "json:\"Viewer\"" }
data: any;
static createFrom(source: any = {}) {
return new SimklUser(source);
}
constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source);
this.data = this.convertValues(source["data"], Object);
}
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;
}
}
}