From 5f47e8c7a86a4e3b2ccb78a3b0a0f64538b783c5 Mon Sep 17 00:00:00 2001 From: EJ Mercado Date: Thu, 21 May 2020 22:02:36 +0800 Subject: [PATCH] fix: product api FeeDetail property, temporary fix --- src/sections/products.ts | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/sections/products.ts b/src/sections/products.ts index b38b4be4..e8dc0120 100644 --- a/src/sections/products.ts +++ b/src/sections/products.ts @@ -1,4 +1,15 @@ -import { boolean, Codec, exactly, GetInterface, number, oneOf, optional, string } from 'purify-ts' +import { + array, + boolean, + Codec, + exactly, + GetInterface, + number, + oneOf, + optional, + string, + unknown, +} from 'purify-ts' import { ParsingError } from '../error' import { HttpClient, RequestMeta, Resource } from '../http' @@ -103,12 +114,32 @@ enum FeeType { FBADeliveryServicesFee = 'FBADeliveryServicesFee', } +type AvailableFeeTypes = + | 'ReferralFee' + | 'VariableClosingFee' + | 'PerItemFee' + | 'FBAFees' + | 'FBAPickAndPack' + | 'FBAWeightHandling' + | 'FBAOrderHandling' + | 'FBADeliveryServicesFee' + +interface FeeDetail { + FeeType: AvailableFeeTypes + FeeAmount: MoneyType + FeePromotion?: MoneyType + TaxAmount?: MoneyType + FinalFee: MoneyType + IncludedFeeDetailList?: FeeDetail +} + const FeeDetail = Codec.interface({ FeeType: oneOf(Object.values(FeeType).map((x) => exactly(x))), FeeAmount: MoneyType, FeePromotion: optional(MoneyType), TaxAmount: optional(MoneyType), FinalFee: MoneyType, + IncludedFeeDetailList: optional(array(unknown)), // Unsure how to handle this // IncludedFeeDetailList: optional(ensureArray('IncludedFeeDetail', FeeDetail)) // Need to think about how to get around this })