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

23 lines
1011 B
TypeScript
Raw Normal View History

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";
@Injectable()
export class WebhooksApiService extends AuthedApi {
2019-06-29 02:21:56 -04:00
constructor(http: HttpClient) {
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();
}
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();
}
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();
}
}