UNPKG

@commercelayer/sdk

Version:
54 lines (52 loc) 2.25 kB
import { ApiResource } from './chunk-XKERR6OR.js'; // src/resources/webhooks.ts var Webhooks = class _Webhooks extends ApiResource { static TYPE = "webhooks"; async create(resource, params, options) { return this.resources.create({ ...resource, type: _Webhooks.TYPE }, params, options); } async update(resource, params, options) { return this.resources.update({ ...resource, type: _Webhooks.TYPE }, params, options); } async delete(id, options) { await this.resources.delete(typeof id === "string" ? { id, type: _Webhooks.TYPE } : id, options); } async last_event_callbacks(webhookId, params, options) { const _webhookId = webhookId.id || webhookId; return this.resources.fetch({ type: "event_callbacks" }, `webhooks/${_webhookId}/last_event_callbacks`, params, options); } async versions(webhookId, params, options) { const _webhookId = webhookId.id || webhookId; return this.resources.fetch({ type: "versions" }, `webhooks/${_webhookId}/versions`, params, options); } async event_stores(webhookId, params, options) { const _webhookId = webhookId.id || webhookId; return this.resources.fetch({ type: "event_stores" }, `webhooks/${_webhookId}/event_stores`, params, options); } async _disable(id, params, options) { return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Webhooks.TYPE, _disable: true }, params, options); } async _enable(id, params, options) { return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Webhooks.TYPE, _enable: true }, params, options); } async _reset_circuit(id, params, options) { return this.resources.update({ id: typeof id === "string" ? id : id.id, type: _Webhooks.TYPE, _reset_circuit: true }, params, options); } isWebhook(resource) { return resource.type && resource.type === _Webhooks.TYPE; } relationship(id) { return super.relationshipOneToOne(id); } relationshipToMany(...ids) { return super.relationshipOneToMany(...ids); } type() { return _Webhooks.TYPE; } }; var instance = new Webhooks(); var webhooks_default = instance; export { webhooks_default }; //# sourceMappingURL=chunk-5BIP4OLZ.js.map //# sourceMappingURL=chunk-5BIP4OLZ.js.map