Skip to content

Commit

Permalink
fix: change rate limit value as a number
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentoanit committed May 19, 2021
1 parent 540abee commit c994ef4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/types/errors/selling-partner-api-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
3 changes: 2 additions & 1 deletion test/types/errors/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -112,7 +113,7 @@ describe(`client`, () => {
)
await expect(client.getMarketplaceParticipations()).rejects.toHaveProperty(
'rateLimit',
defaultRateLimit,
toNumber(defaultRateLimit),
)
})
})

0 comments on commit c994ef4

Please sign in to comment.