2018-10-20 20:33:01 -04:00
|
|
|
import { Injectable } from "@angular/core";
|
|
|
|
import { AuthedApi } from "../authed-api";
|
|
|
|
import { FE_Webhook, FE_WebhookOptions } from "../../models/webhooks";
|
2019-06-29 02:21:56 -04:00
|
|
|
import { HttpClient } from "@angular/common/http";
|
2018-10-20 20:33:01 -04:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class WebhooksApiService extends AuthedApi {
|
2019-06-29 02:21:56 -04:00
|
|
|
constructor(http: HttpClient) {
|
2018-10-20 20:33:01 -04:00
|
|
|
super(http);
|
|
|
|
}
|
|
|
|
|
|
|
|
public createWebhook(roomId: string, options: FE_WebhookOptions): Promise<FE_Webhook> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedPost<FE_Webhook>("/api/v1/dimension/webhooks/room/" + roomId + "/webhooks/new", options).toPromise();
|
2018-10-20 20:33:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public updateWebhook(roomId: string, hookId: string, options: FE_WebhookOptions): Promise<FE_Webhook> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedPost<FE_Webhook>("/api/v1/dimension/webhooks/room/" + roomId + "/webhooks/" + hookId, options).toPromise();
|
2018-10-20 20:33:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public deleteWebhook(roomId: string, hookId: string): Promise<any> {
|
2019-06-29 02:21:56 -04:00
|
|
|
return this.authedDelete("/api/v1/dimension/webhooks/room/" + roomId + "/webhooks/" + hookId).toPromise();
|
2018-10-20 20:33:01 -04:00
|
|
|
}
|
|
|
|
}
|