webhookevent-sdk
v1.0.2
Published
JS API client generated by OpenAPI Generator
Readme
WebhookEvent SDK
WebhookEvent SDK provides a simple way to integrate webhook functionality into your JavaScript applications. It allows you to manage webhook endpoints and events with features like creation, retrieval, enumeration, and deletion.
Features
- Webhook endpoint management (create, retrieve, update, delete)
- Webhook event handling
- User onboarding and account management
- API key management
- Built-in error handling
- Comprehensive test coverage
Requirements
- Node.js (v18.20.4 or higher)
- npm
Installation
Install the package using npm:
npm install webhookevent-sdkQuick Start
const { WebhookEventSdk } = require('webhookevent-sdk');
//only endpoint is required, other parameters are optional
//rest parameters are optional, and can be set later using setter methods
const sdk = new WebhookEventSdk({
endpoint: 'https://api.webhookevent.com/',
bearerToken: '**********',
accountGuid: 'default',
basicAuth: {
username: '[email protected]',
password: 'password',
},
});
const createWebhookEndpoint = async () => {
try {
const result = await sdk.Endpoint.create({
Name: 'My webhook endpoint',
Notes: 'My notes',
HttpMethod: 'POST',
HttpStatus: 200,
});
console.log(result, 'result');
} catch (error) {
console.log(error, 'error');
}
};
createWebhookEndpoint();
const sendWebhookEvent = async () => {
try {
const result = await sdk.Event.send('09a8748e-6741-4065-8305-dfde2a3080bb', {
message: 'Hello, world!',
});
console.log(result, 'result');
} catch (error) {
console.log(error, 'error');
}
};
sendWebhookEvent();API Reference
For detailed information on the available methods and their parameters, please refer below
| Method | Description | Parameters | Returns | Endpoint |
| --------------------------- | --------------------------------------- | --------------------------------------------------------------- | ------------------------------------ | --------------------------------------------------------------------------------- |
| sdk.User.onboard | Onboards a new user. | userData, cancellationToken? | Promise<OnboardingResponse> | POST /v1.0/onboarding |
| sdk.Account.retrieve | Retrieves an account using credentials. | credentials, cancellationToken? | Promise<Account> | GET /v1.0/accounts |
| sdk.Account.exists | Checks if an account exists by GUID. | accountGuid, cancellationToken? | Promise<boolean> | HEAD /v1.0/accounts/{accountGuid} |
| sdk.Account.update | Updates an existing account. | accountData, cancellationToken? | Promise<Account> | PUT /v1.0/accounts/{accountGuid} |
| sdk.User.retrieve | Retrieves a user by their GUID. | userGuid, cancellationToken? | Promise<User> | GET /v1.0/accounts/{accountGuid}/users/{userGuid} |
| sdk.User.exists | Checks if a user exists. | userGuid, cancellationToken? | Promise<boolean> | HEAD /v1.0/accounts/{accountGuid}/users/{userGuid} |
| sdk.User.update | Updates a user by their GUID. | userData, cancellationToken? | Promise<User> | PUT /v1.0/accounts/{accountGuid}/users/{userGuid} |
| sdk.ApiKey.enumerate | Lists all API keys for an account. | cancellationToken? | Promise<EnumeratedApiKey> | GET /v1.0/accounts/{accountGuid}/keys |
| sdk.ApiKey.exists | Checks if an API key exists. | apiKeyGuid, cancellationToken? | Promise<boolean> | HEAD /v1.0/accounts/{accountGuid}/keys/{apiKeyGuid} |
| sdk.ApiKey.generate | Generates a new API key. | obj?, cancellationToken? | Promise<ApiKey> | PUT /v1.0/accounts/{accountGuid}/keys |
| sdk.ApiKey.update | Updates an API key. | updateData, cancellationToken? | Promise<ApiKey> | PUT /v1.0/accounts/{accountGuid}/keys/{guid} |
| sdk.ApiKey.delete | Deletes an API key. | apiKeyGuid, cancellationToken? | Promise<boolean> | DELETE /v1.0/accounts/{accountGuid}/keys/{apiKeyGuid} |
| sdk.Endpoint.retrieve | Retrieves a webhook endpoint by GUID. | webhookEndpointGuid, cancellationToken? | Promise<WebhookEndpoint> | GET /v1.0/accounts/{accountGuid}/endpoints/{guid} |
| sdk.Endpoint.enumerate | Lists all webhook endpoints. | cancellationToken? | Promise<EnumeratedWebhookEndpoint> | GET /v1.0/accounts/{accountGuid}/endpoints |
| sdk.Endpoint.exists | Checks if a webhook endpoint exists. | webhookEndpointGuid, cancellationToken? | Promise<boolean> | HEAD /v1.0/accounts/{accountGuid}/endpoints/{guid} |
| sdk.Endpoint.create | Creates a new webhook endpoint. | webhookEndpointData, cancellationToken? | Promise<WebhookEndpoint> | PUT /v1.0/accounts/{accountGuid}/endpoints |
| sdk.Endpoint.update | Updates an existing webhook endpoint. | webhookEndpointData, cancellationToken? | Promise<WebhookEndpoint> | PUT /v1.0/accounts/{accountGuid}/endpoints/{guid} |
| sdk.Endpoint.delete | Deletes a webhook endpoint. | webhookEndpointGuid, cancellationToken? | Promise<boolean> | DELETE /v1.0/accounts/{accountGuid}/endpoints/{guid} |
| sdk.Event.retrieve | Retrieves a webhook event. | webhookEndpointGuid, webhookEventGuid, cancellationToken? | Promise<WebhookEvent> | GET /v1.0/accounts/{accountGuid}/endpoints/{endpointGuid}/events/{eventGuid} |
| sdk.Event.enumerate | Lists webhook events for an endpoint. | webhookEndpointGuid, cancellationToken? | Promise<EnumeratedWebhookEvent> | GET /v1.0/accounts/{accountGuid}/endpoints/{endpointGuid}/events |
| sdk.Event.exists | Checks if a webhook event exists. | webhookEndpointGuid, webhookEventGuid, cancellationToken? | Promise<boolean> | HEAD /v1.0/accounts/{accountGuid}/endpoints/{endpointGuid}/events/{eventGuid} |
| sdk.Event.delete | Deletes a webhook event. | webhookEndpointGuid, webhookEventGuid, cancellationToken? | Promise<boolean> | DELETE /v1.0/accounts/{accountGuid}/endpoints/{endpointGuid}/events/{eventGuid} |
| sdk.Event.send | Sends a new webhook event. | webhookEndpointGuid, webhookEventData, cancellationToken? | Promise<WebhookEvent> | POST /v1.0/endpoints/{endpointGuid} |
Development
Linking the project locally (for development and testing)
To use the library locally without publishing to a remote npm registry, first install the dependencies with the command:
npm installNext, link it globally in local system's npm with the following command:
npm linkTo use the link you just defined in your project, switch to the directory you want to use your litegraphdb from, and run:
npm link webhookevent-sdkFinally, you need to build the sdk, use command:
npm run buildYou can then import the SDK with either import or require based on the ES Module (esm) or CommonJS (cjs) project, as shown below:
import { WebhookEventSdk } from 'webhookevent-sdk';
//or
var { WebhookEventSdk } = require('webhookevent-sdk');Setting up Pre-commit Hooks
The pre-commit hooks will run automatically on git commit. They help maintain:
- Code formatting (using ruff)
- Import sorting
- Code quality checks
- And other project-specific checks
Running Tests
The project uses jest for running tests in isolated environments. Make sure you have jest installed, which should automatically be there if you have installed dependencies via npm i command:
# Run only the tests
npm run test
# Run tests with coverage report
npm run test:coverage
Contributing
We welcome contributions! Please see our Contributing Guidelines for details
Feedback and Issues
Have feedback or found an issue? Please file an issue in our GitHub repository.
Version History
Please refer to CHANGELOG.md for a detailed version history.
