mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 01:05:53 -04:00
751e1b9c8c
Adds #119
44 lines
2.0 KiB
TypeScript
44 lines
2.0 KiB
TypeScript
import { Injectable } from "@angular/core";
|
|
import { Http } from "@angular/http";
|
|
import { Integration } from "./models/integration";
|
|
|
|
@Injectable()
|
|
export class ApiService {
|
|
constructor(private http: Http) {
|
|
}
|
|
|
|
checkScalarToken(scalarToken: string): Promise<boolean> {
|
|
return this.http.get("/api/v1/scalar/checkToken", {params: {scalar_token: scalarToken}})
|
|
.map(res => res.status === 200).toPromise();
|
|
}
|
|
|
|
getIntegrations(roomId: string, scalarToken: string): Promise<Integration[]> {
|
|
return this.http.get("/api/v1/dimension/integrations/" + roomId, {params: {scalar_token: scalarToken}})
|
|
.map(res => res.json()).toPromise();
|
|
}
|
|
|
|
removeIntegration(roomId: string, type: string, integrationType: string, scalarToken: string): Promise<any> {
|
|
const url = "/api/v1/dimension/integrations/" + roomId + "/" + type + "/" + integrationType;
|
|
return this.http.delete(url, {params: {scalar_token: scalarToken}})
|
|
.map(res => res.json()).toPromise();
|
|
}
|
|
|
|
updateIntegrationState(roomId: string, type: string, integrationType: string, scalarToken: string, newState: any): Promise<any> {
|
|
const url = "/api/v1/dimension/integrations/" + roomId + "/" + type + "/" + integrationType + "/state";
|
|
return this.http.put(url, {scalar_token: scalarToken, state: newState})
|
|
.map(res => res.json()).toPromise();
|
|
}
|
|
|
|
getIntegrationState(roomId: string, type: string, integrationType: string, scalarToken: string): Promise<any> {
|
|
const url = "/api/v1/dimension/integrations/" + roomId + "/" + type + "/" + integrationType + "/state";
|
|
return this.http.get(url, {params: {scalar_token: scalarToken}})
|
|
.map(res => res.json()).toPromise();
|
|
}
|
|
|
|
isEmbeddable(checkUrl: string): Promise<any> {
|
|
const url = "/api/v1/dimension/widgets/embeddable";
|
|
return this.http.get(url, {params: {url: checkUrl}})
|
|
.map(res => res.json()).toPromise();
|
|
}
|
|
}
|