# Subscription History Model

## Request User Subscription History

- When requesting `subscription.getSubscriptionHistoryByUserId` or `subscription.getSubscriptionHistoryById` a SubscriptionHistoryModel instance is returned.

```javascript
try {
	const history = await subscription.getSubscriptionHistoryByUserId(userId);
} catch (error) {
	throw error;
}
```

### Required Parameters

| Parameters   | Required | Type   | Description        | Example                             |
| ----------   | -------- | ------ | ------------------ | ----------------------------------- |
| userId       | Yes      | String | This is the user ID of a specific user | zyoRrJB7YEJC...|

```javascript
try {
	const history = await subscription.getSubscriptionHistoryById(subscriptionId);
} catch (error) {
	throw error;
}
```

### Required Parameters

| Parameters   | Required | Type   | Description        | Example                             |
| ----------   | -------- | ------ | ------------------ | ----------------------------------- |
| subscriptionId | Yes    | String | This is the ID of a user's subscription | A-S00000000    |


## Table of Contents

* [Initiate Class](#Initiate-Class)
* [Model Properties](#Properties)
* [Prototypes](#Prototypes)
* [Membership Response](#Membership-Response)

### Initiate Class

```javascript
	const subscriptionHistoryItem = new SubscriptionHistoryModel(mappedSubscriptionHistoryItem);
```

| Parameters              | Required | Type    | Description                               | Example      |
| ----------------------- | -------- | ------- | ----------------------------------------- | ------------ |
| subscriptionHistoryItem | Yes      | Object  | Mapped membership subscription history item      |              |

### Properties

| Properties              | Type   | Description                             | Example                         |
| ----------------------- | ------ | ------------------------------------    | ------------------------------- |
| eventEffectiveDate      | String | Date the event will come into effect    | 2019-10-16T11:06:31.907Z        |
| eventDate               | String | Date of event creation                  | 2018-10-16T11:06:31.907Z        |
| eventType               | String | Event type                              | StepUp                          |
| subscriptionBefore      | String | Optional property of sub before change  | See SubscriptionDetails type    |
| subscriptionAfter       | String | Optional property of sub after change   | See SubscriptionDetails type    |

### Prototypes

* [Get isFutureStepUp](#isFutureStepUp)

#### isFutureStepUp

```javascript
const isInStepUpWindow = subscriptionHistoryItem.isFutureStepUp;
```

- Returns whether the user subscription item is a future step up event.

### Membership Response

A full example can be found in the [test fixture file](../../test/fixtures/subscription-history.ts)
