diff --git a/src/sections/reports.ts b/src/sections/reports.ts
index c5617541..253c015b 100644
--- a/src/sections/reports.ts
+++ b/src/sections/reports.ts
@@ -131,10 +131,6 @@ const GetReportRequestListByNextTokenResponse = Codec.interface({
}),
})
-export interface GetReportRequestListByNextTokenParameters {
- NextToken: NextToken<'GetReportRequestList'>
-}
-
export interface GetReportRequestCountParameters {
ReportTypeList?: ReportType[]
ReportProcessingStatusList?: ReportProcessing[]
@@ -205,10 +201,6 @@ const GetReportListResponse = Codec.interface({
}),
})
-export interface GetReportListByNextTokenParameters {
- NextToken: NextToken<'GetReportList'>
-}
-
const GetReportListByNextTokenResponse = Codec.interface({
GetReportListByNextTokenResponse: Codec.interface({
GetReportListByNextTokenResult: GetReportListResult,
@@ -464,14 +456,14 @@ export class Reports {
}
async getReportListByNextToken(
- parameters: GetReportListByNextTokenParameters,
+ nextToken: NextToken<'GetReportList'>,
): Promise<[GetReportListResult, RequestMeta]> {
const [response, meta] = await this.httpClient.request('POST', {
resource: Resource.Reports,
version: REPORTS_API_VERSION,
action: 'GetReportListByNextToken',
parameters: {
- NextToken: parameters.NextToken.token,
+ NextToken: nextToken.token,
},
})
@@ -556,14 +548,14 @@ export class Reports {
}
async getReportRequestListByNextToken(
- parameters: GetReportRequestListByNextTokenParameters,
+ nextToken: NextToken<'GetReportRequestList'>,
): Promise<[GetReportRequestListResult, RequestMeta]> {
const [response, meta] = await this.httpClient.request('POST', {
resource: Resource.Reports,
version: REPORTS_API_VERSION,
action: 'GetReportListByNextToken',
parameters: {
- NextToken: parameters.NextToken.token,
+ NextToken: nextToken.token,
},
})
diff --git a/test/integration/__recordings__/Feeds_2160823042/should-be-able-to-submit-sample-feed_2567144032/recording.har b/test/integration/__recordings__/Feeds_2160823042/should-be-able-to-submit-sample-feed_2567144032/recording.har
index d493f86a..ca082e69 100644
--- a/test/integration/__recordings__/Feeds_2160823042/should-be-able-to-submit-sample-feed_2567144032/recording.har
+++ b/test/integration/__recordings__/Feeds_2160823042/should-be-able-to-submit-sample-feed_2567144032/recording.har
@@ -8,7 +8,7 @@
},
"entries": [
{
- "_id": "d8629899729c640584baef2db86f2622",
+ "_id": "5ff95739bdbd570acef97863eab75ac4",
"_order": 0,
"cache": {},
"request": {
@@ -71,7 +71,7 @@
},
{
"name": "Signature",
- "value": "tD7hfvr0yP7yyImiKckwTzYQvJOV2SUbWH9r8YMblRw="
+ "value": "P3YPb5Od6+J4TLn0brBtyGQFvrzEyAQ3VsVPCGrtLss="
},
{
"name": "SignatureMethod",
@@ -83,21 +83,21 @@
},
{
"name": "Timestamp",
- "value": "2020-06-25T13:07:07.903Z"
+ "value": "2020-06-25T12:32:14.240Z"
},
{
"name": "Version",
"value": "2009-01-01"
}
],
- "url": "https://mws.amazonservices.ca/Feeds/2009-01-01?AWSAccessKeyId=x&Action=SubmitFeed&ContentMD5Value=bDhJasSNYDMcVWyPpo%2Bvyw%3D%3D&FeedType=_POST_PRODUCT_DATA_&MWSAuthToken=x&SellerId=x&Signature=tD7hfvr0yP7yyImiKckwTzYQvJOV2SUbWH9r8YMblRw%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2020-06-25T13%3A07%3A07.903Z&Version=2009-01-01"
+ "url": "https://mws.amazonservices.ca/Feeds/2009-01-01?AWSAccessKeyId=x&Action=SubmitFeed&ContentMD5Value=bDhJasSNYDMcVWyPpo%2Bvyw%3D%3D&FeedType=_POST_PRODUCT_DATA_&MWSAuthToken=x&SellerId=x&Signature=P3YPb5Od6%2BJ4TLn0brBtyGQFvrzEyAQ3VsVPCGrtLss%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2020-06-25T12%3A32%3A14.240Z&Version=2009-01-01"
},
"response": {
"bodySize": 486,
"content": {
"mimeType": "text/xml",
"size": 486,
- "text": "\n51800018438_POST_PRODUCT_DATA_2020-06-25T13:07:08+00:00_SUBMITTED_99cb54df-69c2-454d-b0aa-49da94092d18"
+ "text": "\n51799018438_POST_PRODUCT_DATA_2020-06-25T12:32:14+00:00_SUBMITTED_cdf4c6ca-67ec-42d9-9cc7-5cac67df723a"
},
"cookies": [],
"headers": [
@@ -107,7 +107,7 @@
},
{
"name": "date",
- "value": "Thu, 25 Jun 2020 13:07:08 GMT"
+ "value": "Thu, 25 Jun 2020 12:32:14 GMT"
},
{
"name": "content-type",
@@ -135,19 +135,19 @@
},
{
"name": "x-mws-response-context",
- "value": "9PSFFB/bO20TBQPIsEe0gkTrY8ufWcBnKlJDU3m8+3RcKGX3yXR5LXM8pNeHS4ir8cGFalY0wQI=, 3nlbmsxkAzfsqB1kAxdwxr4DkR+uGUamiWmBtsFySulWScnsQb5MU53w0jiG1Ify/CNjGzJ2uao="
+ "value": "KaMSjJJFKD5H8WoDG0Rf6THe/fAmsueFQ7Pcjlu+Ac5R4bH3TXoS7st5Vgz3NZlVFgNqf4Kdi1E=, ytN4oXk4X/HCufBmiasfjZ8QYEaeC0kK/VZRmhWnxttkL50/1APA+IR+yZvNvyt6Wdba4zTlw7Q="
},
{
"name": "x-amz-request-id",
- "value": "99cb54df-69c2-454d-b0aa-49da94092d18"
+ "value": "cdf4c6ca-67ec-42d9-9cc7-5cac67df723a"
},
{
"name": "x-mws-request-id",
- "value": "99cb54df-69c2-454d-b0aa-49da94092d18"
+ "value": "cdf4c6ca-67ec-42d9-9cc7-5cac67df723a"
},
{
"name": "x-mws-timestamp",
- "value": "2020-06-25T13:07:08.265Z"
+ "value": "2020-06-25T12:32:14.514Z"
},
{
"name": "vary",
@@ -155,7 +155,7 @@
},
{
"name": "x-amz-rid",
- "value": "A2GEZ93HB45VKJK4JS45"
+ "value": "JKCPZQPS3F65PPYWSKE5"
}
],
"headersSize": 678,
@@ -164,8 +164,8 @@
"status": 200,
"statusText": "OK"
},
- "startedDateTime": "2020-06-25T13:07:07.908Z",
- "time": 734,
+ "startedDateTime": "2020-06-25T12:32:14.245Z",
+ "time": 614,
"timings": {
"blocked": -1,
"connect": -1,
@@ -173,7 +173,7 @@
"receive": 0,
"send": 0,
"ssl": -1,
- "wait": 734
+ "wait": 614
}
}
],
diff --git a/test/integration/__recordings__/submit-feed_3193551092/should-be-able-to-submit-sample-feed_2567144032/recording.har b/test/integration/__recordings__/submit-feed_3193551092/should-be-able-to-submit-sample-feed_2567144032/recording.har
new file mode 100644
index 00000000..09993f2c
--- /dev/null
+++ b/test/integration/__recordings__/submit-feed_3193551092/should-be-able-to-submit-sample-feed_2567144032/recording.har
@@ -0,0 +1,183 @@
+{
+ "log": {
+ "_recordingName": "submit-feed/should be able to submit sample feed",
+ "creator": {
+ "comment": "persister:fs",
+ "name": "Polly.JS",
+ "version": "4.3.0"
+ },
+ "entries": [
+ {
+ "_id": "b4391da807354cda8b8ffaab25e22621",
+ "_order": 0,
+ "cache": {},
+ "request": {
+ "bodySize": 1484,
+ "cookies": [],
+ "headers": [
+ {
+ "name": "accept",
+ "value": "application/json, text/plain, */*"
+ },
+ {
+ "name": "content-type",
+ "value": "text/xml"
+ },
+ {
+ "name": "user-agent",
+ "value": "@scaleleap/amazon-mws-api-sdk/1.0.0 (Language=JavaScript)"
+ },
+ {
+ "name": "content-length",
+ "value": 1484
+ },
+ {
+ "name": "host",
+ "value": "mws.amazonservices.ca"
+ }
+ ],
+ "headersSize": 628,
+ "httpVersion": "HTTP/1.1",
+ "method": "POST",
+ "postData": {
+ "mimeType": "text/xml",
+ "params": [],
+ "text": "\n\n \n 1.01\n M_EXAMPLE_123456\n \n Product\n false\n \n 1\n Update\n \n 56789\n \n ASIN\n B0EXAMPLEG\n \n A_GEN_NOTAX\n \n Example Product Title\n Example Product Brand\n This is an example product description.\n Example Bullet Point 1\n Example Bullet Point 2\n 25.19\n Example Product Manufacturer\n example-item-type\n \n \n \n \n \n Example Ingredients\n Example Directions\n \n \n \n \n \n \n\n"
+ },
+ "queryString": [
+ {
+ "name": "AWSAccessKeyId",
+ "value": "AKIAIAIAAT7ND54ZZHCA"
+ },
+ {
+ "name": "Action",
+ "value": "SubmitFeed"
+ },
+ {
+ "name": "ContentMD5Value",
+ "value": "bDhJasSNYDMcVWyPpo+vyw=="
+ },
+ {
+ "name": "FeedType",
+ "value": "_POST_PRODUCT_DATA_"
+ },
+ {
+ "name": "MWSAuthToken",
+ "value": "amzn.mws.ceb0168c-9b0a-a870-3728-898489b540f5"
+ },
+ {
+ "name": "SellerId",
+ "value": "AUZWHWR0590BC"
+ },
+ {
+ "name": "Signature",
+ "value": "V+nhflAhhUzOKbbtJ3atvKo9M5H3u1ybF4U31BRHnJE="
+ },
+ {
+ "name": "SignatureMethod",
+ "value": "HmacSHA256"
+ },
+ {
+ "name": "SignatureVersion",
+ "value": "2"
+ },
+ {
+ "name": "Timestamp",
+ "value": "2020-06-25T13:17:18.123Z"
+ },
+ {
+ "name": "Version",
+ "value": "2009-01-01"
+ }
+ ],
+ "url": "https://mws.amazonservices.ca/Feeds/2009-01-01?AWSAccessKeyId=x&Action=SubmitFeed&ContentMD5Value=bDhJasSNYDMcVWyPpo%2Bvyw%3D%3D&FeedType=_POST_PRODUCT_DATA_&MWSAuthToken=x&SellerId=x&Signature=V%2BnhflAhhUzOKbbtJ3atvKo9M5H3u1ybF4U31BRHnJE%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2020-06-25T13%3A17%3A18.123Z&Version=2009-01-01"
+ },
+ "response": {
+ "bodySize": 486,
+ "content": {
+ "mimeType": "text/xml",
+ "size": 486,
+ "text": "\n51801018438_POST_PRODUCT_DATA_2020-06-25T13:17:18+00:00_SUBMITTED_e6226f27-7e18-4f25-98b1-c76ea0f49e91"
+ },
+ "cookies": [],
+ "headers": [
+ {
+ "name": "server",
+ "value": "Server"
+ },
+ {
+ "name": "date",
+ "value": "Thu, 25 Jun 2020 13:17:18 GMT"
+ },
+ {
+ "name": "content-type",
+ "value": "text/xml"
+ },
+ {
+ "name": "transfer-encoding",
+ "value": "chunked"
+ },
+ {
+ "name": "connection",
+ "value": "close"
+ },
+ {
+ "name": "x-mws-quota-max",
+ "value": "30.0"
+ },
+ {
+ "name": "x-mws-quota-remaining",
+ "value": "30.0"
+ },
+ {
+ "name": "x-mws-quota-resetson",
+ "value": "2020-06-25T14:12:00.000Z"
+ },
+ {
+ "name": "x-mws-response-context",
+ "value": "d5TXZmKIPMUzVw195OP40nbl1G8bEaVdNnso0VphoRcMrBTqtYfP9XT2XVm73qGEL8If3QMZoF0=, PYo4uTL5lD+Nn0F6nhYC6P9LEWZwRuXVmYfvrjOfDD8UoAzBKJDoiLuxjH3z0uVOC5CufnQUWqw="
+ },
+ {
+ "name": "x-amz-request-id",
+ "value": "e6226f27-7e18-4f25-98b1-c76ea0f49e91"
+ },
+ {
+ "name": "x-mws-request-id",
+ "value": "e6226f27-7e18-4f25-98b1-c76ea0f49e91"
+ },
+ {
+ "name": "x-mws-timestamp",
+ "value": "2020-06-25T13:17:18.266Z"
+ },
+ {
+ "name": "vary",
+ "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent"
+ },
+ {
+ "name": "x-amz-rid",
+ "value": "3ZFYRJEG1X9VWBTXM9Q5"
+ }
+ ],
+ "headersSize": 678,
+ "httpVersion": "HTTP/1.1",
+ "redirectURL": "",
+ "status": 200,
+ "statusText": "OK"
+ },
+ "startedDateTime": "2020-06-25T13:17:18.136Z",
+ "time": 365,
+ "timings": {
+ "blocked": -1,
+ "connect": -1,
+ "dns": -1,
+ "receive": 0,
+ "send": 0,
+ "ssl": -1,
+ "wait": 365
+ }
+ }
+ ],
+ "pages": [],
+ "version": "1.2"
+ }
+}
diff --git a/test/integration/feeds.test.ts b/test/integration/feeds.test.ts
index ce88390f..ed541139 100644
--- a/test/integration/feeds.test.ts
+++ b/test/integration/feeds.test.ts
@@ -1,7 +1,4 @@
-import { readFileSync } from 'fs'
-import { join } from 'path'
-
-import { Feeds, SubmitFeedParameters } from '../../src'
+import { Feeds } from '../../src'
import { Config } from './config'
import { itci } from './it'
@@ -39,21 +36,6 @@ describe(`${Feeds.name}`, () => {
expect(typeof response.Count).toBe('number')
})
- itci('should be able to submit sample feed', async () => {
- expect.assertions(1)
-
- const parameters: SubmitFeedParameters = {
- FeedContent: readFileSync(join(__dirname, `/submit_feed_sample_feed_content.xml`), {
- encoding: 'utf8',
- }),
- FeedType: '_POST_PRODUCT_DATA_',
- }
-
- const [response] = await feeds.submitFeed(parameters)
-
- expect(response).toBeDefined()
- })
-
itci('should be able to list feed submission list', async () => {
expect.assertions(1)
diff --git a/test/integration/submit-feed.test.ts b/test/integration/submit-feed.test.ts
new file mode 100644
index 00000000..05bbf2f6
--- /dev/null
+++ b/test/integration/submit-feed.test.ts
@@ -0,0 +1,39 @@
+import { jestPollyConfigService } from '@scaleleap/jest-polly'
+import { readFileSync } from 'fs'
+import { join } from 'path'
+
+import { Feeds, SubmitFeedParameters } from '../../src'
+import { Config } from './config'
+import { itci } from './it'
+
+/**
+ * `submitFeed` modifies URL for each request which normally
+ * triggers Polly to re-record, this is a workaround to that
+ */
+jestPollyConfigService.config = {
+ matchRequestsBy: {
+ url: false,
+ },
+}
+
+const httpClient = new Config().createHttpClient()
+
+/* eslint-disable jest/no-standalone-expect */
+describe(`submit-feed`, () => {
+ const feeds = new Feeds(httpClient)
+ itci('should be able to submit sample feed', async () => {
+ expect.assertions(1)
+
+ const parameters: SubmitFeedParameters = {
+ FeedContent: readFileSync(join(__dirname, `/submit_feed_sample_feed_content.xml`), {
+ encoding: 'utf8',
+ }),
+ FeedType: '_POST_PRODUCT_DATA_',
+ }
+
+ const [response] = await feeds.submitFeed(parameters)
+
+ expect(response).toBeDefined()
+ })
+})
+/* eslint-enable jest/no-standalone-expect */
diff --git a/test/unit/reports.test.ts b/test/unit/reports.test.ts
index 2111f090..0a8619cf 100644
--- a/test/unit/reports.test.ts
+++ b/test/unit/reports.test.ts
@@ -148,9 +148,6 @@ describe('reports', () => {
describe('getReportListByNextToken', () => {
const mockNextToken = new NextToken('GetReportList', '123')
- const parameters = {
- NextToken: mockNextToken,
- }
it('returns report info and next token if succesful', async () => {
expect.assertions(1)
@@ -158,7 +155,7 @@ describe('reports', () => {
const mockGetReportListByNextToken = createMockHttpClient('reports_get_report_list_nt')
expect(
- await mockGetReportListByNextToken.reports.getReportListByNextToken(parameters),
+ await mockGetReportListByNextToken.reports.getReportListByNextToken(mockNextToken),
).toMatchSnapshot()
})
@@ -166,7 +163,7 @@ describe('reports', () => {
expect.assertions(1)
await expect(() =>
- mockMwsFail.reports.getReportListByNextToken(parameters),
+ mockMwsFail.reports.getReportListByNextToken(mockNextToken),
).rejects.toStrictEqual(new ParsingError(parsingError))
})
})
@@ -245,9 +242,6 @@ describe('reports', () => {
describe('getReportRequestListByNextToken', () => {
const mockNextToken = new NextToken('GetReportRequestList', '123')
- const parameters = {
- NextToken: mockNextToken,
- }
it('returns report request info if succesful', async () => {
expect.assertions(1)
@@ -258,7 +252,7 @@ describe('reports', () => {
expect(
await mockGetReportRequestListByNextToken.reports.getReportRequestListByNextToken(
- parameters,
+ mockNextToken,
),
).toMatchSnapshot()
})
@@ -267,7 +261,7 @@ describe('reports', () => {
expect.assertions(1)
await expect(() =>
- mockMwsFail.reports.getReportRequestListByNextToken(parameters),
+ mockMwsFail.reports.getReportRequestListByNextToken(mockNextToken),
).rejects.toStrictEqual(new ParsingError(parsingError))
})
})