impactify-sdk
v1.1.0
Published
TypeScript SDK for the Impactify Public API
Maintainers
Readme
Impactify SDK
A TypeScript SDK for the Impactify Public API.
Installation
npm install impactify-sdk
# or
yarn add impactify-sdk
# or
pnpm add impactify-sdkUsage
Basic Setup
import { ImpactifyClient } from 'impactify-sdk';
const client = new ImpactifyClient({
baseURL: 'https://impactify.ro/api/rest/v1',
apiKey: 'your-api-key',
timeout: 10000,
});Chat Messages
// Get all chat messages
const messages = await client.listChatMessages();
console.log(messages.data);Events
// Get event details
const event = await client.getEvent();
console.log(event.data);
// Update event
const updatedEvent = await client.updateEvent({
title: 'Updated Event Title',
livestreamLink: 'https://example.com/stream',
location: {
latitude: 40.7128,
longitude: -74.0060,
},
});Widgets
// Create an INFO widget
const infoWidget = await client.createWidget({
type: 'INFO',
text: 'This is an information widget',
});
// Create a MARKDOWN widget
const markdownWidget = await client.createWidget({
type: 'MARKDOWN',
title: 'Documentation',
content: '# Welcome\n\nThis is **markdown** content.',
});
// Create a POLL widget
const pollWidget = await client.createWidget({
type: 'POLL',
question: 'What is your favorite programming language?',
options: [
{ id: '1', text: 'TypeScript', voterIds: [] },
{ id: '2', text: 'JavaScript', voterIds: [] },
{ id: '3', text: 'Python', voterIds: [] },
],
isActive: true,
});
// Get a specific widget
const widget = await client.getWidget('widget-id');
// Update a widget
const updatedWidget = await client.updateWidget('widget-id', {
type: 'INFO',
text: 'Updated information',
});
// Delete a widget
await client.deleteWidget('widget-id');
// List all widgets
const widgets = await client.listWidgets();Health Check
// Check API health
const health = await client.health();
console.log(health.data);Error Handling
try {
const event = await client.getEvent();
console.log(event.data);
} catch (error) {
if (error.status === 404) {
console.log('Event not found');
} else if (error.status === 401) {
console.log('Unauthorized');
} else {
console.log('Error:', error.message);
}
}Authentication
// Set authentication token
client.setAuthToken('your-new-token');
// Remove authentication token
client.removeAuthToken();
// Set request timeout
client.setTimeout(15000);API Reference
ImpactifyClient
The main client class for interacting with the Impactify API.
Constructor Options
baseURL(string, optional): API base URL. Default:https://impactify.ro/api/rest/v1apiKey(string, optional): API authentication keytimeout(number, optional): Request timeout in milliseconds. Default:10000headers(object, optional): Additional headers to include in requests
Methods
Chat
listChatMessages(): Get all chat messages
Events
getEvent(): Get event detailsupdateEvent(eventData): Update event information
Widgets
createWidget(widgetData): Create a new widgetgetWidget(widgetId): Get a specific widgetupdateWidget(widgetId, widgetData): Update a widgetdeleteWidget(widgetId): Delete a widgetlistWidgets(): Get all widgets
Health
health(): Check API health status
Utility
setAuthToken(token): Set authentication tokenremoveAuthToken(): Remove authentication tokensetTimeout(timeout): Set request timeout
Types
The SDK includes comprehensive TypeScript types for all API entities:
ChatMessageEventWidgetWidgetData(union ofInfoWidgetData,MarkdownWidgetData,PollWidgetData)LocationPricingPollOptionUpdateEventRequestBodyCreateWidgetRequestBodyApiResponse<T>ApiErrorImpactifyConfig
Development
Setup
pnpm installBuild
pnpm run buildTest
pnpm run test
pnpm run test:watchLint
pnpm run lint
pnpm run lint:fixType Check
pnpm run type-checkLicense
MIT
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
