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

33 lines
1.6 KiB
TypeScript
Raw Normal View History

import { Injectable } from "@angular/core";
import { AuthedApi } from "../authed-api";
import { FE_IntegrationsResponse } from "../../models/dimension-responses";
import { FE_Integration } from "../../models/integration";
2019-06-29 02:21:56 -04:00
import { HttpClient } from "@angular/common/http";
@Injectable()
export class IntegrationsApiService extends AuthedApi {
2019-06-29 02:21:56 -04:00
constructor(http: HttpClient) {
super(http);
}
public getIntegrations(roomId: string): Promise<FE_IntegrationsResponse> {
2019-06-29 02:21:56 -04:00
return this.authedGet<FE_IntegrationsResponse>("/api/v1/dimension/integrations/room/" + roomId).toPromise();
}
public getIntegration(category: string, type: string): Promise<FE_Integration> {
2019-06-29 02:21:56 -04:00
return this.http.get<FE_Integration>("/api/v1/dimension/integrations/" + category + "/" + type).toPromise();
}
public getIntegrationInRoom(category: string, type: string, roomId: string): Promise<FE_Integration> {
2019-06-29 02:21:56 -04:00
return this.authedGet<FE_Integration>("/api/v1/dimension/integrations/room/" + roomId + "/integrations/" + category + "/" + type).toPromise();
}
public setIntegrationConfiguration(category: string, type: string, roomId: string, newConfig: any): Promise<any> {
2019-06-29 02:21:56 -04:00
return this.authedPost("/api/v1/dimension/integrations/room/" + roomId + "/integrations/" + category + "/" + type + "/config", newConfig).toPromise();
}
public removeIntegration(category: string, type: string, roomId: string): Promise<any> {
2019-06-29 02:21:56 -04:00
return this.authedDelete("/api/v1/dimension/integrations/room/" + roomId + "/integrations/" + category + "/" + type).toPromise();
}
}