# Event

This class defines an Event from a [[Book]].

An event is an object that represents an action (such as posting or deleting a [[Transaction]]) made by an actor (such as a user or a [Bot](https://bkper.com/apps) acting on behalf of a user).

### Constructor

```ts
new Event(book, payload?): Event;
```

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `book` | [`Book`](https://bkper.com/docs/api/bkper-js/classes/book.md) |
| `payload?` | `Event` |

#### Returns

`Event`

### payload

```ts
payload: Event;
```

### getAgent()

```ts
getAgent(): Agent | undefined;
```

Gets the Agent who performed the Event.

#### Returns

[`Agent`](https://bkper.com/docs/api/bkper-js/classes/agent.md) \| `undefined`

The Agent who performed the Event

***

### getBook()

```ts
getBook(): Book;
```

Gets the book in which the Event was created.

#### Returns

[`Book`](https://bkper.com/docs/api/bkper-js/classes/book.md)

The book in which the Event was created

***

### getBotResponses()

```ts
getBotResponses(): BotResponse[];
```

Gets the Bot Responses associated to this Event.

#### Returns

[`BotResponse`](https://bkper.com/docs/api/bkper-js/classes/botresponse.md)[]

The Bot Responses associated to this Event

***

### getCreatedAt()

```ts
getCreatedAt(): Date | undefined;
```

Gets the date the Event was created.

#### Returns

`Date` \| `undefined`

The date the Event was created

***

### getId()

```ts
getId(): string | undefined;
```

Gets the id of the Event.

#### Returns

`string` \| `undefined`

The id of the Event

***

### getType()

```ts
getType(): EventType | undefined;
```

Gets the type of the Event.

#### Returns

[`EventType`](https://bkper.com/docs/api/bkper-js/enumerations/eventtype.md) \| `undefined`

The type of the Event

***

### getUser()

```ts
getUser(): User | undefined;
```

Gets the user who performed the Event.

#### Returns

[`User`](https://bkper.com/docs/api/bkper-js/classes/user.md) \| `undefined`

The user who performed the Event

***

### hasErrorResponse()

```ts
hasErrorResponse(): boolean;
```

Checks if this Event has at least one Bot Response of type ERROR.

#### Returns

`boolean`

True if this Event has at least one Bot Response of type ERROR

***

### json()

```ts
json(): Event;
```

Gets an immutable copy of the JSON payload for this Event.

#### Returns

`Event`

The wrapped plain json object
