# Migration v21

Contains 1 breaking change of the SDK interface.

## Changes

- [new method getUserSubscriptionBySubscriptionNumber](#New-method-created-getUserSubscriptionBySubscriptionNumber)
- [change response on method getUserSubscriptionByNumber](#Change-to_getUserSubscriptionByNumber)
- [change to PaymentOptions interface](#Change-to-subscription-type)
- [new routes available in demo project](#New-routes-available-in-demo-project)

### New method created getUserSubscriptionBySubscriptionNumber

Membership's Subscription API has the `/membership/subscriptions/v1/{subscriptionNumber}` endpoint, the SDK now allows to get the subscription calling this endpoint.

New Param

**subscriptionNumber** - of type string.

Response:
Additional to the current subscription structure, the subscription term is a new object and it has this new format.
```
export class SubscriptionTerm {
	public iso8601Duration = '';
	public billingPeriod = '';
	public termType = '';
	public autoRenewTerm = false;
	public termPeriodType = '';
	public termEndDate = '';
	public termStartDate = '';
}
```
### Change to getUserSubscriptionByNumber

Response:
Additional to the current subscription structure, the subscription term is a new object and it has this new format.
```
export class SubscriptionTerm {
	public iso8601Duration = '';
	public billingPeriod = '';
	public termType = '';
	public autoRenewTerm = false;
	public termPeriodType = '';
	public termEndDate = '';
	public termStartDate = '';
}
```
### Change to subscription type  (`src/types/subscription.ts`)

#### PaymentOptions interface

New Keys

**singleTermSubscription** - of type boolean to define if the subscription on creation is a singleTermSubscription.

**closePaymentMethod** - of type boolean to define if the payment method should be closed after the subscription creation.

#### MappedPaymentOptions interface
The breaking change is the singleTermSubscription field in the MappedPaymentOptionsInterface was a string (the selectedPaymentTerm.subscriptionCode), but it's now a subscriptionTerm object.


```diff
- subscriptionTerm: string;
+ subscriptionTerm: SubscriptionTerm;
```
The SDK set the `SubscriptionTerm` object with the right values according to the `singleTermSubscription` property

#### SubscriptionTerm interface
The new object to send to memberships API has the following structure
```
export interface SubscriptionTerm {
	iso8601Duration: string;
	subscriptionTermType: string;
	autoRenewTerm: boolean;
}
```

### New routes available in demo project
Changes in `demo/service/subscription/routes.js` to support the test from rest clients or curl

#### Adding get-by-user-id-subscription-number route in order to get the current getUserSubscriptionByNumber SDK method
```
    router.get('/get-by-user-id-subscription-number', subscriptionService.getBySubscriptionNumberController);
```

#### Adding get-by-subscription-number route in order to get the new getUserSubscriptionBySubscriptionNumber SDK method
```
    router.get('/get-by-subscription-number/:subscriptionNumber', subscriptionService.getUserSubscriptionBySubscriptionNumberController);
```
