0.0.12 • Published 4 months ago
webplug v0.0.12
Webhooks Plug JS Client
This holds the code for the webhooks plug client used to connect to the server
installation
yarn add webplug
Usage
import Webplug from "webplug";
const webplugClient = new Webplug({
url: "api-gateway-url",
apiKey: "api-key-api-gateway",
});
Documentation
Services Module
- 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");
Users Module
- 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");
Subscriptions Module
- 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"
);
Event Types Module
- 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");
Events Module
- Publish an event:
webplugClient.events.publish
const event = await webplugClient.events.create(
"event-type-name",
"user-id",
"message-payload"
);