|
8 | 8 | IdealPaymentRequestBody,
|
9 | 9 | GetDefaultCard,
|
10 | 10 | SetDefaultCard,
|
| 11 | + ChangeSubscriptionPlanRequestBody, |
| 12 | + ChangeSubscriptionPlanResponse, |
11 | 13 | } from '../models/ISubscription';
|
12 | 14 | import { CommonResponse } from '../models/CommonInterfaces';
|
13 | 15 | import { ApiConfig, Request } from '../models/Config';
|
@@ -248,6 +250,46 @@ class Subscription extends BaseExtend {
|
248 | 250 | });
|
249 | 251 | }
|
250 | 252 |
|
| 253 | + /** |
| 254 | + * Changes the subscription plan for a given asset. |
| 255 | + * @method post |
| 256 | + * @async |
| 257 | + * @param {Object} data - { |
| 258 | + * access_fee_id: number, |
| 259 | + * inplayer_token: number |
| 260 | + * } |
| 261 | + * @example |
| 262 | + * InPlayer.Subscription |
| 263 | + * .changeSubscriptionPlan({ |
| 264 | + * access_fee_id: 1, |
| 265 | + * inplayer_token: 'S-xxxxx-ST' |
| 266 | + * } |
| 267 | + * ) |
| 268 | + * .then(data => console.log(data)); |
| 269 | + * @return {Object} |
| 270 | + */ |
| 271 | + async changeSubscriptionPlan({ |
| 272 | + access_fee_id, |
| 273 | + inplayer_token, |
| 274 | + }: { |
| 275 | + access_fee_id: number, |
| 276 | + inplayer_token: string, |
| 277 | + }): Promise<AxiosResponse<ChangeSubscriptionPlanResponse>> { |
| 278 | + const body: ChangeSubscriptionPlanRequestBody = { |
| 279 | + access_fee_id, |
| 280 | + inplayer_token, |
| 281 | + }; |
| 282 | + |
| 283 | + const tokenObject = await this.request.getToken(); |
| 284 | + |
| 285 | + return this.request.authenticatedPost(API.subscriptionPlanChange, qs.stringify(body), { |
| 286 | + headers: { |
| 287 | + Authorization: `Bearer ${tokenObject.token}`, |
| 288 | + 'Content-Type': 'application/x-www-form-urlencoded', |
| 289 | + }, |
| 290 | + }); |
| 291 | + } |
| 292 | + |
251 | 293 | /**
|
252 | 294 | * Process a request for direct debit subscribe
|
253 | 295 | * @method directDebitSubscribe
|
|
0 commit comments