2018-10-23 00:10:28 -04:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
import { AuthedApi } from "../authed-api";
|
|
|
|
import { FE_CustomSimpleBot, FE_CustomSimpleBotTemplate, FE_UserProfile } from "../../models/admin-responses";
|
2019-06-29 02:21:56 -04:00
|
|
|
import { HttpClient } from "@angular/common/http";
|
2018-10-23 00:10:28 -04:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class AdminCustomSimpleBotsApiService extends AuthedApi {
|
2019-06-29 02:21:56 -04:00
|
|
|
constructor(http: HttpClient) {
|
2018-10-23 00:10:28 -04:00
|
|
|
super(http);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getBots(): Promise<FE_CustomSimpleBot[]> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedGet<FE_CustomSimpleBot[]>("/api/v1/dimension/admin/bots/simple/custom/all").toPromise();
|
2018-10-23 00:10:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public getBot(id: number): Promise<FE_CustomSimpleBot> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedGet<FE_CustomSimpleBot>("/api/v1/dimension/admin/bots/simple/custom/" + id).toPromise();
|
2018-10-23 00:10:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public updateBot(id: number, config: FE_CustomSimpleBotTemplate): Promise<FE_CustomSimpleBot> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedPost<FE_CustomSimpleBot>("/api/v1/dimension/admin/bots/simple/custom/" + id, config).toPromise();
|
2018-10-23 00:10:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public createBot(config: FE_CustomSimpleBotTemplate): Promise<FE_CustomSimpleBot> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedPost<FE_CustomSimpleBot>("/api/v1/dimension/admin/bots/simple/custom/new", config).toPromise();
|
2018-10-23 00:10:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public getProfile(userId: string): Promise<FE_UserProfile> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedGet<FE_UserProfile>("/api/v1/dimension/admin/bots/simple/custom/profile/" + userId).toPromise();
|
2018-10-23 00:10:28 -04:00
|
|
|
}
|
|
|
|
}
|