diff --git a/src/sections/orders.ts b/src/sections/orders.ts index f814e407..a76798a6 100644 --- a/src/sections/orders.ts +++ b/src/sections/orders.ts @@ -19,6 +19,7 @@ import { nextToken as nextTokenCodec, } from '../parsing' import { getServiceStatusByResource } from './shared' +import { RequireOnlyOne } from './types' const ORDERS_API_VERSION = '2013-09-01' @@ -322,7 +323,15 @@ const canonicalizeParameters = (parameters: ListOrderParameters) => { export class Orders { constructor(private httpClient: HttpClient) {} - async listOrders(parameters: ListOrderParameters): Promise<[ListOrders, RequestMeta]> { + /** + * If BuyerEmail is specified, then FulfillmentChannel, + * OrderStatus, PaymentMethod, + * LastUpdatedAfter, LastUpdatedBefore, + * and SellerOrderId cannot be specified. + */ + async listOrders( + parameters: RequireOnlyOne, + ): Promise<[ListOrders, RequestMeta]> { const [response, meta] = await this.httpClient.request('POST', { resource: Resource.Orders, version: ORDERS_API_VERSION, diff --git a/test/unit/orders.test.ts b/test/unit/orders.test.ts index ce118223..7caed05c 100644 --- a/test/unit/orders.test.ts +++ b/test/unit/orders.test.ts @@ -84,18 +84,19 @@ const parsingError = 'Expected an object, but received a string with value ""' describe('orders', () => { describe('listOrders', () => { + const parameters = { CreatedAfter: new Date(), MarketplaceId: [] } + it('returns a parsed model when the response is valid', async () => { expect.assertions(1) - - expect(await mockMwsListOrders.orders.listOrders({ MarketplaceId: [] })).toMatchSnapshot() + expect(await mockMwsListOrders.orders.listOrders(parameters)).toMatchSnapshot() }) it('throws a parsing error when the response is not valid', async () => { expect.assertions(1) - await expect(() => - mockMwsFail.orders.listOrders({ MarketplaceId: [] }), - ).rejects.toStrictEqual(new ParsingError(parsingError)) + await expect(() => mockMwsFail.orders.listOrders(parameters)).rejects.toStrictEqual( + new ParsingError(parsingError), + ) }) })