This holds the code for the webhooks plug client used to connect to the server
yarn add webplug
import Webplug from "webplug";
const webplugClient = new Webplug({
url: "api-gateway-url",
apiKey: "api-key-api-gateway",
});
- Create a service:
webplugClient.services.create
const service = await webplugClient.services.create("service-name");
- Retreive all services:
webplugClient.services.all
const services = await webplugClient.services.all();
- Get the details of a service:
webplugClient.services.get
const service = await webplugClient.services.get("service-id");
- Delete a service:
webplugClient.services.delete
const service = await webplugClient.services.delete("service-id");
- Create a user:
webplugClient.users.create
const user = await webplugClient.users.create("name-of-user", "service-id");
- Retreive all users:
webplugClient.users.all
const users = await webplugClient.users.all("service-id");
- Get the details of a user:
webplugClient.users.get
const user = await webplugClient.users.get("user-id");
- Delete a user:
webplugClient.users.delete
const user = await webplugClient.users.delete("user-id");
- Create a subscription:
webplugClient.subscriptions.create
const subscription = await webplugClient.subscriptions.create(
"event-type-name",
"endpoint-url",
"id-of-user"
);
- Retreive all subscriptions for an event type:
webplugClient.subscriptions.all
const subscriptions = await webplugClient.subscriptions.all("event-type-id");
- Get the details of a subscription:
webplugClient.subscriptions.get
const subscription = await webplugClient.subscriptions.get("subscription-id");
- Delete a subscription:
webplugClient.subscriptions.delete
const subscription = await webplugClient.subscriptions.delete(
"subscription-id"
);
- Create an event type:
webplugClient.eventTypes.create
const eventType = await webplugClient.eventTypes.create(
"event-type-name",
"service-id"
);
- Retreive all event types for a service:
webplugClient.eventTypes.all
const eventTypes = await webplugClient.eventTypes.all("service-id");
- Get the details of an event type:
webplugClient.eventTypes.get
const eventType = await webplugClient.eventTypes.get("event-type-id");
- Delete an event type:
webplugClient.eventTypes.delete
const eventType = await webplugClient.eventTypes.delete("event-type-id");
- Publish an event:
webplugClient.events.publish
const event = await webplugClient.events.create(
"event-type-name",
"user-id",
"message-payload"
);