From c994ef45254facc27a4ce8801aa69f3de0a44869 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Wed, 19 May 2021 12:24:06 +0700 Subject: [PATCH] fix: change rate limit value as a number --- src/types/errors/selling-partner-api-errors.ts | 7 +++++-- test/types/errors/errors.test.ts | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/types/errors/selling-partner-api-errors.ts b/src/types/errors/selling-partner-api-errors.ts index adcb658c..ff6c0e8c 100644 --- a/src/types/errors/selling-partner-api-errors.ts +++ b/src/types/errors/selling-partner-api-errors.ts @@ -47,11 +47,14 @@ export class SellingPartnerNotFoundError extends SellingPartnerGenericError {} export class SellingPartnerRequestTooLongError extends SellingPartnerGenericError {} export class SellingPartnerUnsupportedMediaTypeError extends SellingPartnerGenericError {} export class SellingPartnerTooManyRequestsError extends SellingPartnerGenericError { - public rateLimit?: string + public rateLimit?: number public constructor(error: ModelError, headers: Headers) { super(error, headers) - this.rateLimit = headers['x-amzn-RateLimit-Limit'] || headers['x-amzn-ratelimit-limit'] + this.rateLimit = + Number(headers['x-amzn-RateLimit-Limit']) || + Number(headers['x-amzn-ratelimit-limit']) || + undefined } } export class SellingPartnerInternalServerError extends SellingPartnerGenericError {} diff --git a/test/types/errors/errors.test.ts b/test/types/errors/errors.test.ts index 611884f6..4cb0a4a2 100644 --- a/test/types/errors/errors.test.ts +++ b/test/types/errors/errors.test.ts @@ -4,6 +4,7 @@ import { } from '@scaleleap/amazon-marketplaces' import { jestPollyContext } from '@scaleleap/jest-polly' import { StatusCodes } from 'http-status-codes' +import { toNumber } from 'lodash' import { APIConfigurationParameters, @@ -112,7 +113,7 @@ describe(`client`, () => { ) await expect(client.getMarketplaceParticipations()).rejects.toHaveProperty( 'rateLimit', - defaultRateLimit, + toNumber(defaultRateLimit), ) }) })