npm package: @mimik/event-helper
Description: Helper for setting up and using a topic to send events
Author: mimik technology inc
Latest version: 2.1.1

<a name="module_event-helper"></a>

## event-helper
**Example**  
```js
import eventHelper from '@mimik/event-helper';
```

* [event-helper](#module_event-helper)
    * [~eventHelper(config)](#module_event-helper..eventHelper) ⇒ <code>object</code>
    * _async_
        * [~validate()](#module_event-helper..validate) ⇒ <code>Promise</code>
        * [~sendEvent(eventType, event, ids, body, correlationId, options)](#module_event-helper..sendEvent) ⇒ <code>Promise</code>
        * [~sendEvents(eventType, event, ids, body, correlationId, options)](#module_event-helper..sendEvents) ⇒ <code>Promise</code>

<a name="module_event-helper..eventHelper"></a>

### event-helper~eventHelper(config) ⇒ <code>object</code>
Creates an event helper instance for sending events to an AWS SNS topic.

**Kind**: inner method of [<code>event-helper</code>](#module_event-helper)  
**Returns**: <code>object</code> - An object with `validate`, `sendEvent`, and `sendEvents` methods.  
**Throws**:

- <code>Error</code> Will throw if `config.topic.set` is not `'on'`, `'mock'`, or `'off'`.

**Requires**: <code>module:@mimik/sumologic-winston-logger</code>  

| Param | Type | Description |
| --- | --- | --- |
| config | <code>object</code> | Configuration object. |
| config.topic | <code>object</code> | Topic configuration. |
| config.topic.set | <code>string</code> | Topic mode: `'on'`, `'mock'`, or `'off'`. |
| config.topicSettings | <code>object</code> | SNS topic settings. |
| config.topicSettings.region | <code>string</code> | AWS region. |
| config.topicSettings.name | <code>string</code> | SNS topic name. |
| [config.topicSettings.accessKeyId] | <code>string</code> | AWS access key ID. |
| [config.topicSettings.secretAccessKey] | <code>string</code> | AWS secret access key. |
| [config.topicSettings.isFifoTopic] | <code>string</code> | `'true'` or `'false'` string indicating whether the topic is a FIFO topic. |
| [config.topicSettings.contentBasedDeduplication] | <code>string</code> | `'true'` or `'false'` string indicating whether to enable content-based deduplication. |

<a name="module_event-helper..validate"></a>

### event-helper~validate() ⇒ <code>Promise</code>
Topic initialization and validation

**Kind**: inner method of [<code>event-helper</code>](#module_event-helper)  
**Category**: async  
**Requires**: <code>module:@mimik/sumologic-winston-logger</code>  
**Fulfil**:  Return `undefined` if config.topic is set to `off`.  
**Fulfil**: <code>object</code> Return `eventProcessor` if config.topic is set to `on` or `mock`.  
**Reject**: <code>Error</code> Will reject if topic creation fails.  
<a name="module_event-helper..sendEvent"></a>

### event-helper~sendEvent(eventType, event, ids, body, correlationId, options) ⇒ <code>Promise</code>
Sending an event to a topic

**Kind**: inner method of [<code>event-helper</code>](#module_event-helper)  
**Category**: async  
**Requires**: <code>module:@mimik/sumologic-winston-logger</code>  
**Fulfil**:  Return `undefined`.  
**Reject**: <code>Error</code> Will reject if SNS publish fails.  

| Param | Type | Description |
| --- | --- | --- |
| eventType | <code>string</code> | Type of event to be sent. |
| event | <code>string</code> | Event to be sent. |
| ids | <code>object</code> | Object containing ids of the user. |
| body | <code>object</code> | Body to add to the event to be sent. |
| correlationId | <code>string</code> | Correlation id associated with the event to be sent. |
| options | <code>object</code> | Options associated with the call. Use to apply `metrics`. Can use `messageDeduplicationId`, `messageGroupId` for fifo sns. |

<a name="module_event-helper..sendEvents"></a>

### event-helper~sendEvents(eventType, event, ids, body, correlationId, options) ⇒ <code>Promise</code>
Sending events to a topic in batch request

**Kind**: inner method of [<code>event-helper</code>](#module_event-helper)  
**Category**: async  
**Requires**: <code>module:@mimik/sumologic-winston-logger</code>  
**Fulfil**:  Return `undefined`.  
**Reject**: <code>Error</code> Will reject if SNS batch publish fails.  

| Param | Type | Description |
| --- | --- | --- |
| eventType | <code>string</code> | Type of event to be sent. |
| event | <code>string</code> | Event to be sent. |
| ids | <code>Array.&lt;object&gt;</code> | Array of id objects containing ids of the users associated with the events. |
| body | <code>object</code> | Body to add to the event to be sent. |
| correlationId | <code>string</code> | Correlation id associated with the events to be sent. |
| options | <code>object</code> | Options associated with the call. Use to apply `metrics`. Can use `messageDeduplicationIds`, `messageGroupIds` for fifo sns. |