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

35 lines
1.5 KiB
TypeScript
Raw Normal View History

import { Injectable } from "@angular/core";
import { AuthedApi } from "../authed-api";
import { HttpClient } from "@angular/common/http";
2021-12-01 16:35:16 -05:00
import { FE_HookshotJiraConnection, FE_HookshotJiraInstance, FE_HookshotJiraProject } from "../../models/hookshot_jira";
@Injectable()
export class HookshotJiraApiService extends AuthedApi {
constructor(http: HttpClient) {
super(http);
}
2021-12-01 16:35:16 -05:00
public getProjects(instanceName: string): Promise<FE_HookshotJiraProject[]> {
return this.authedGet("/api/v1/dimension/hookshot/jira/instance/" + instanceName + "/projects").toPromise().then(r => r['projects']);
}
public getInstances(): Promise<FE_HookshotJiraInstance[]> {
return this.authedGet("/api/v1/dimension/hookshot/jira/instances").toPromise().then(r => r['instances']);
}
public getAuthUrl(): Promise<string> {
return this.authedGet("/api/v1/dimension/hookshot/jira/auth").toPromise().then(r => r['authUrl']);
}
public bridgeRoom(roomId: string, instanceName: string, projectKey: string): Promise<FE_HookshotJiraConnection> {
return this.authedPost<FE_HookshotJiraConnection>("/api/v1/dimension/hookshot/jira/room/" + roomId + "/connect", {
2021-12-01 16:35:16 -05:00
instanceName: instanceName,
projectKey: projectKey,
}).toPromise();
}
public unbridgeRoom(roomId: string): Promise<any> {
2021-12-01 16:35:16 -05:00
return this.authedDelete("/api/v1/dimension/hookshot/jira/room/" + roomId + "/connections/all").toPromise();
}
}