2017-12-24 04:02:57 -05:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
import { Http } from "@angular/http";
|
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";
|
2017-12-24 04:02:57 -05:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class IntegrationsApiService extends AuthedApi {
|
|
|
|
constructor(http: Http) {
|
|
|
|
super(http);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getIntegrations(roomId: string): Promise<FE_IntegrationsResponse> {
|
|
|
|
return this.authedGet("/api/v1/dimension/integrations/room/" + roomId).map(r => r.json()).toPromise();
|
|
|
|
}
|
|
|
|
|
|
|
|
public getIntegration(category: string, type: string): Promise<FE_Integration> {
|
|
|
|
return this.http.get("/api/v1/dimension/integrations/" + category + "/" + type).map(r => r.json()).toPromise();
|
|
|
|
}
|
|
|
|
|
2018-03-25 23:01:05 -04:00
|
|
|
public getIntegrationInRoom(category: string, type: string, roomId: string): Promise<FE_Integration> {
|
|
|
|
return this.authedGet("/api/v1/dimension/integrations/room/" + roomId + "/integrations/" + category + "/" + type).map(r => r.json()).toPromise();
|
|
|
|
}
|
|
|
|
|
2018-03-26 23:48:44 -04:00
|
|
|
public setIntegrationConfiguration(category: string, type: string, roomId: string, newConfig: any): Promise<any> {
|
|
|
|
return this.authedPost("/api/v1/dimension/integrations/room/" + roomId + "/integrations/" + category + "/" + type + "/config", newConfig).map(r => r.json()).toPromise();
|
|
|
|
}
|
|
|
|
|
2018-03-25 18:20:15 -04:00
|
|
|
public removeIntegration(category: string, type: string, roomId: string): Promise<any> {
|
|
|
|
return this.authedDelete("/api/v1/dimension/integrations/room/" + roomId + "/integrations/" + category + "/" + type).map(r => r.json()).toPromise();
|
|
|
|
}
|
2017-12-24 04:02:57 -05:00
|
|
|
}
|