2017-12-24 04:02:57 -05:00
|
|
|
import { Injectable } from "@angular/core";
|
2018-03-24 19:16:52 -04:00
|
|
|
import { AuthedApi } from "../authed-api";
|
|
|
|
import { FE_IntegrationsResponse } from "../../models/dimension-responses";
|
2018-03-31 18:38:38 -04:00
|
|
|
import { FE_Integration } from "../../models/integration";
|
2019-06-29 02:21:56 -04:00
|
|
|
import { HttpClient } from "@angular/common/http";
|
2017-12-24 04:02:57 -05:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class IntegrationsApiService extends AuthedApi {
|
2019-06-29 02:21:56 -04:00
|
|
|
constructor(http: HttpClient) {
|
2017-12-24 04:02:57 -05:00
|
|
|
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();
|
2017-12-24 04:02:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2017-12-24 04:02:57 -05:00
|
|
|
}
|
|
|
|
|
2018-03-25 23:01:05 -04:00
|
|
|
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();
|
2018-03-25 23:01:05 -04:00
|
|
|
}
|
|
|
|
|
2018-03-26 23:48:44 -04:00
|
|
|
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();
|
2018-03-26 23:48:44 -04:00
|
|
|
}
|
|
|
|
|
2018-03-25 18:20:15 -04:00
|
|
|
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();
|
2018-03-25 18:20:15 -04:00
|
|
|
}
|
2017-12-24 04:02:57 -05:00
|
|
|
}
|