2021-11-30 21:25:35 -05:00
|
|
|
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";
|
2021-11-30 21:25:35 -05:00
|
|
|
|
|
|
|
@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> {
|
2021-11-30 21:25:35 -05:00
|
|
|
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,
|
2021-11-30 21:25:35 -05:00
|
|
|
}).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();
|
2021-11-30 21:25:35 -05:00
|
|
|
}
|
|
|
|
}
|