Skip to content

Commit 15d5962

Browse files
authored
Merge pull request #498 from inplayer-org/v3-chore/extend_getDiscount_object_parameter
Extend the getDiscount object atttribute
2 parents 174cad6 + e421e5b commit 15d5962

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
# [3.0.0-beta.14] - 14-07-2020
6+
7+
### Changes
8+
9+
- Extend the getDiscount object atttribute with itemId
10+
511
# [3.0.0-beta.13] - 02-07-2020
612

713
### Added

src/endpoints/voucher.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import qs from 'qs';
2-
import { VoucherDiscountPriceData } from '../models/IVoucher&Promotion';
2+
import { DiscountData, DiscountBodyData } from '../models/IVoucher&Promotion';
33
import { ApiConfig, Request } from '../models/Config';
44
import BaseExtend from '../extends/base';
55
import { API } from '../constants';
@@ -19,8 +19,9 @@ class Voucher extends BaseExtend {
1919
* @method getDiscount
2020
* @async
2121
* @param {Object} data - {
22-
* accessFeeId: number,
2322
* voucherCode: string
23+
* accessFeeId?: number,
24+
* itemId?: number,
2425
* }
2526
* @example
2627
* InPlayer.Voucher
@@ -31,12 +32,19 @@ class Voucher extends BaseExtend {
3132
* .then(data => console.log(data));
3233
* @returns {AxiosResponse<VoucherDiscountPrice>}
3334
*/
34-
async getDiscount(data: VoucherDiscountPriceData) {
35-
const body = {
36-
access_fee_id: data.accessFeeId,
35+
async getDiscount(data: DiscountData) {
36+
const body: DiscountBodyData = {
3737
voucher_code: data.voucherCode,
3838
};
3939

40+
if (data.accessFeeId) {
41+
body.access_fee_id = data.accessFeeId;
42+
}
43+
44+
if (data.itemId) {
45+
body.item_id = data.itemId;
46+
}
47+
4048
return this.request.authenticatedPost(API.getDiscount, qs.stringify(body), {
4149
headers: {
4250
Authorization: `Bearer ${this.request.getToken().token}`,

src/index.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,8 @@ export declare class Subscription {
692692

693693
export interface DiscountData {
694694
voucherCode: string;
695-
accessFeeId: number;
695+
accessFeeId?: number;
696+
itemId?: number;
696697
}
697698

698699
export interface VoucherDiscountPrice {

src/models/IVoucher&Promotion.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ export interface VoucherDiscountPrice {
2828
amount: number;
2929
}
3030

31-
export interface VoucherDiscountPriceData {
32-
accessFeeId: number;
31+
export interface DiscountData {
3332
voucherCode: string;
33+
accessFeeId?: number;
34+
itemId?: number;
3435
}
3536

36-
export interface DiscountData {
37-
voucherCode: string;
38-
accessFeeId: number;
37+
export interface DiscountBodyData {
38+
voucher_code: string;
39+
access_fee_id?: number;
40+
item_id?: number;
3941
}
4042

4143
export interface Voucher extends BaseExtend {

0 commit comments

Comments
 (0)