matrix-dimension/web/app/shared/services/admin/admin-integrations-api.service.ts

33 lines
1.3 KiB
TypeScript
Raw Normal View History

import { Injectable } from "@angular/core";
import { Http } from "@angular/http";
import { AuthedApi } from "../authed-api";
import { FE_Bridge, FE_Widget } from "../../models/integration";
2019-04-13 16:37:56 -04:00
import { map } from "rxjs/operators";
@Injectable()
export class AdminIntegrationsApiService extends AuthedApi {
constructor(http: Http) {
super(http);
}
public getAllWidgets(): Promise<FE_Widget[]> {
2019-04-13 16:37:56 -04:00
return this.authedGet("/api/v1/dimension/admin/integrations/widget/all")
.pipe(map(r => r.json())).toPromise();
}
public getAllBridges(): Promise<FE_Bridge<any>[]> {
2019-04-13 16:37:56 -04:00
return this.authedGet("/api/v1/dimension/admin/integrations/bridge/all")
.pipe(map(r => r.json())).toPromise();
}
public toggleIntegration(category: string, type: string, enabled: boolean): Promise<any> {
2019-04-13 16:37:56 -04:00
return this.authedPost("/api/v1/dimension/admin/integrations/" + category + "/" + type + "/enabled", {enabled: enabled})
.pipe(map(r => r.json())).toPromise();
}
public setIntegrationOptions(category: string, type: string, options: any): Promise<any> {
2019-04-13 16:37:56 -04:00
return this.authedPost("/api/v1/dimension/admin/integrations/" + category + "/" + type + "/options", {options: options})
.pipe(map(r => r.json())).toPromise();
}
}