paypal-rest-api
Version:
A typescript module for integrating with PayPal REST APIs.
43 lines (42 loc) • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const abstracts_1 = require("../abstracts");
const schemas_1 = require("./schemas");
class WebhookApi extends abstracts_1.Api {
constructor(client) {
super(client, WebhookApi.schemas, WebhookApi.paths);
}
events(id, options = {}) {
if (WebhookApi.schemas.id) {
id = this.schemaValidate(id, WebhookApi.schemas.id);
}
options.uri = this.parsePath(WebhookApi.paths.events, { id });
options = this.schemaValidate(options, WebhookApi.schemas.events);
return this.client.request(options);
}
types(options = {}) {
options.uri = WebhookApi.paths.types;
options = this.schemaValidate(options, WebhookApi.schemas.types);
return this.client.request(options);
}
}
WebhookApi.paths = {
create: `/v1/notifications/webhooks`,
delete: `/v1/notifications/webhooks/{id}`,
events: `/v1/notifications/webhooks/{id}/event-types`,
get: `/v1/notifications/webhooks/{id}`,
list: `/v1/notifications/webhooks`,
types: `/v1/notifications/webhooks-event-types`,
update: `/v1/notifications/webhooks/{id}`,
};
WebhookApi.schemas = {
create: schemas_1.webhookCreateRequestSchema,
delete: schemas_1.webhookDeleteRequestSchema,
events: schemas_1.webhookGetEventsRequestSchema,
get: schemas_1.webhookGetRequestSchema,
id: schemas_1.webhookIdSchema,
list: schemas_1.webhookListRequestSchema,
types: schemas_1.webhookEventTypeListRequestSchema,
update: schemas_1.webhookUpdateRequestSchema,
};
exports.WebhookApi = WebhookApi;