@idfy/sdk
Version:
Node.js SDK for Idfy REST API
118 lines • 3.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationService = void 0;
const IdfyBaseService_1 = require("../IdfyBaseService");
const APIHelper_1 = require("../../infrastructure/APIHelper");
const Urls_1 = require("../../infrastructure/Urls");
class NotificationService extends IdfyBaseService_1.default {
/**
* Retrieves up to 100 unhandled events for your account. After you retrieve this list the events will be "locked" for 10 minutes
* to give you time to handle them.
* Please handle the events using one of the endpoints in this API to avoid retrieving the same events multiple times.
* @param eventType
* @param tags
*/
listUnhandledEvents(eventType, tags) {
const url = APIHelper_1.default.appendQueryParams(`${Urls_1.default.notification}/events`, {
eventType,
tags
});
return super.get(url);
}
/**
* Marks the status of an event as handled.
* @param eventId
*/
handleEvent(eventId) {
return super.post(`${Urls_1.default.notification}/events/${eventId}/handle`);
}
/**
* Marks the status of a batch of events as handled.
* @param eventIds
*/
handleMultipleEvents(eventIds) {
return super.post(`${Urls_1.default.notification}/events/handle`, eventIds);
}
/**
* Peeks the top 100 unhandled events regardless if they are locked or not. Don't use this endpoint to handle events.
* @param eventType
* @param tags
*/
peekEvents(eventType, tags) {
const url = APIHelper_1.default.appendQueryParams(`${Urls_1.default.notification}/events/peek`, {
eventType,
tags
});
return super.get(url);
}
/**
* Clears all events for your account.
*/
clearEvents() {
return super.post(`${Urls_1.default.notification}/events/clear`);
}
/**
* Returns a list of all available event types.
*/
listEventTypes() {
return super.get(`${Urls_1.default.notification}/events/types`);
}
/**
* Creates a mock event with a sample payload. Can be used to test your event handling code.
* @param mockEventRequest
*/
mockEvent(mockEventRequest) {
return super.post(`${Urls_1.default.notification}/events/mock`, mockEventRequest);
}
/**
* Retrieves the details of a single webhook.
* @param id
*/
getWebhook(id) {
return super.get(`${Urls_1.default.notification}/webhooks/${id}`);
}
/**
* Deletes the specified webhook.
* @param id
*/
deleteWebhook(id) {
return super.delete(`${Urls_1.default.notification}/webhooks/${id}`);
}
/**
* Updates the specified webhook with the parameters passed. Any parameters not provided will be left unchanged.
* @param id
* @param webhookUpdateOptions
*/
updateWebhook(id, webhookUpdateOptions) {
return super.patch(`${Urls_1.default.notification}/webhooks/${id}`, webhookUpdateOptions);
}
/**
* Returns a list of all your webhooks.
*/
listWebhooks() {
return super.get(`${Urls_1.default.notification}/webhooks`);
}
/**
* Creates a new webhook.
* @param webhookCreateOptions
*/
createWebhook(webhookCreateOptions) {
return super.post(`${Urls_1.default.notification}/webhooks`, webhookCreateOptions);
}
/**
* Triggers a ping event to be sent to the webhook.
* @param id
*/
pingWebhook(id) {
return super.post(`${Urls_1.default.notification}/webhooks/${id}/ping`);
}
/**
* Returns the 10 most recent delivery attempts for a single webhook.
* @param id
*/
listWebhookDeliveries(id) {
return super.get(`${Urls_1.default.notification}/webhooks/${id}/deliveries`);
}
}
exports.NotificationService = NotificationService;
//# sourceMappingURL=NotificationService.js.map