pancake-client-sdk
Version:
Official TypeScript SDK for Pancake POS API
97 lines • 2.77 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebhookResource = void 0;
const base_1 = require("./base");
class WebhookResource extends base_1.BaseResource {
/**
* Get list of webhooks
*/
async list() {
return this.client.get(this.getShopPath('/webhooks'));
}
/**
* Get webhook by ID
*/
async getById(webhookId) {
return this.client.get(this.getShopPath(`/webhooks/${webhookId}`));
}
/**
* Create new webhook
*/
async create(data) {
return this.client.post(this.getShopPath('/webhooks'), data);
}
/**
* Update webhook
*/
async update(webhookId, data) {
return this.client.put(this.getShopPath(`/webhooks/${webhookId}`), data);
}
/**
* Delete webhook
*/
async delete(webhookId) {
return this.client.delete(this.getShopPath(`/webhooks/${webhookId}`));
}
/**
* Get webhook deliveries
*/
async listDeliveries(params) {
return this.client.get(this.getShopPath('/webhook-deliveries'), params);
}
/**
* Get webhook delivery by ID
*/
async getDeliveryById(deliveryId) {
return this.client.get(this.getShopPath(`/webhook-deliveries/${deliveryId}`));
}
/**
* Retry webhook delivery
*/
async retryDelivery(deliveryId) {
return this.client.post(this.getShopPath(`/webhook-deliveries/${deliveryId}/retry`), {});
}
/**
* Get webhook statistics
*/
async getStats(webhookId, params) {
return this.client.get(this.getShopPath(`/webhooks/${webhookId}/stats`), params);
}
/**
* Test webhook
*/
async test(webhookId, event, payload) {
return this.client.post(this.getShopPath(`/webhooks/${webhookId}/test`), {
event,
payload: payload || {}
});
}
/**
* Rotate webhook secret
*/
async rotateSecret(webhookId) {
return this.client.post(this.getShopPath(`/webhooks/${webhookId}/rotate-secret`), {});
}
/**
* Enable/disable webhook
*/
async setActive(webhookId, isActive) {
return this.client.put(this.getShopPath(`/webhooks/${webhookId}/set-active`), {
is_active: isActive
});
}
/**
* Get pending deliveries
*/
async getPendingDeliveries() {
return this.client.get(this.getShopPath('/webhook-deliveries/pending'));
}
/**
* Clear webhook delivery history
*/
async clearDeliveryHistory(webhookId, params) {
return this.client.post(this.getShopPath(`/webhooks/${webhookId}/clear-history`), params || {});
}
}
exports.WebhookResource = WebhookResource;
//# sourceMappingURL=webhook.js.map