28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.WebhookEndpoint = void 0;
|
|
const Entity_1 = require("../../../../shared/domain/Entity");
|
|
const UniqueId_1 = require("../../../../shared/domain/UniqueId");
|
|
const WebhookSecret_1 = require("../value-objects/WebhookSecret");
|
|
class WebhookEndpoint extends Entity_1.Entity {
|
|
static create(props, id) {
|
|
return new WebhookEndpoint({ ...props, secret: WebhookSecret_1.WebhookSecret.generate(), enabled: true, createdAt: new Date() }, id ?? UniqueId_1.UniqueId.create());
|
|
}
|
|
static reconstitute(props, id) {
|
|
return new WebhookEndpoint(props, id);
|
|
}
|
|
get url() { return this.props.url; }
|
|
get secret() { return this.props.secret; }
|
|
get enabled() { return this.props.enabled; }
|
|
get createdAt() { return this.props.createdAt; }
|
|
get lastDeliveredAt() { return this.props.lastDeliveredAt; }
|
|
get lastStatus() { return this.props.lastStatus; }
|
|
recordDelivery(statusCode) {
|
|
this.props.lastDeliveredAt = new Date();
|
|
this.props.lastStatus = statusCode;
|
|
}
|
|
enable() { this.props.enabled = true; }
|
|
disable() { this.props.enabled = false; }
|
|
}
|
|
exports.WebhookEndpoint = WebhookEndpoint;
|