# Migration v7

Contains 3 breaking changes of the SDK interface.

## Changes

### `RedeemableToken` class rename

The `RedeemableToken` class for redeeming tokens has been renamed to `RedeemableTokenService`. This is to avoid any confusion with the `RedeemableToken` class that represents the actual token rather than the service.

```diff
- const { RedeemableToken } = require('n-membership-sdk');
+ const { RedeemableTokenService } = require('n-membership-sdk');
```

```diff
const membershipSDK = require('n-membership-sdk');
- const tokenService = new membershipSDK.RedeemableToken(…)
+ const tokenService = new membershipSDK.RedeemableTokenService(…)
```

### `RedeemableToken` config changes

The, now `RedeemableTokenService`, requires 2 keys a `redeemableEmailTokenApiKey` and `redeemableTokenApiKey` API key in it’s configuration.

The new `redeemableEmailTokenApiKey` key is needed for getting and redeeming `PersonalisedTokens`

### `RedeemableToken.redeemToken` changes

#### Method renamed

The `redeemToken` method has been renamed to `redeem`.

#### Function signature change

The function now only accepts as its first parameter a `RedeemableToken` or `PersonalisedToken` instance. Anything else will result in an error being thrown.

The second parameter, `userId` is now optional if the token provided is a `PersonalisedToken` but is still required if the token is a `RedeemableToken`. If you pass a `RedeemableToken` without a `userId` the method will now throw an error.

```diff
- tokenService.redeemToken('123…', 'someUserId')
+ tokenService.redeem(token, 'someUserId') // where token is an instance of a RedeemableToken
```
