diff --git a/src/sections/reports.ts b/src/sections/reports.ts index 144f5ec8..ffc78ee2 100644 --- a/src/sections/reports.ts +++ b/src/sections/reports.ts @@ -156,10 +156,40 @@ const GetReportListResponse = Codec.interface({ }), }) +interface GetReportListByNextTokenParameters { + NextToken: NextToken<'GetReportList'> +} + +const GetReportListByNextTokenResponse = Codec.interface({ + GetReportListByNextTokenResponse: Codec.interface({ + GetReportListByNextTokenResult: GetReportListResult, + }), +}) + type GetReportListResult = GetInterface export class Reports { constructor(private httpClient: HttpClient) {} + async getReportListByNextToken( + parameters: GetReportListByNextTokenParameters, + ): Promise<[GetReportListResult, RequestMeta]> { + const [response, meta] = await this.httpClient.request('POST', { + resource: Resource.Report, + version: REPORTS_API_VERSION, + action: 'GetReportListByNextToken', + parameters: { + NextToken: parameters.NextToken.token, + }, + }) + + return GetReportListByNextTokenResponse.decode(response).caseOf({ + Right: (x) => [x.GetReportListByNextTokenResponse.GetReportListByNextTokenResult, meta], + Left: (error) => { + throw new ParsingError(error) + }, + }) + } + async getReportList( parameters: GetReportListParameters, ): Promise<[GetReportListResult, RequestMeta]> { @@ -238,7 +268,7 @@ export class Reports { const [response, meta] = await this.httpClient.request('POST', { resource: Resource.Report, version: REPORTS_API_VERSION, - action: 'GetReportRequestListByNextToken', + action: 'GetReportListByNextToken', parameters: { NextToken: parameters.NextToken.token, }, diff --git a/test/unit/__snapshots__/reports.test.ts.snap b/test/unit/__snapshots__/reports.test.ts.snap index 653ea4b3..c3e1f3e0 100644 --- a/test/unit/__snapshots__/reports.test.ts.snap +++ b/test/unit/__snapshots__/reports.test.ts.snap @@ -54,6 +54,33 @@ Array [ ] `; +exports[`reports getReportListByNextToken returns report info and next token if succesful 1`] = ` +Array [ + Object { + "HasNext": false, + "NextToken": NextToken { + "action": "GetReportList", + "token": "none", + }, + "ReportInfo": Object { + "Acknowledged": false, + "AcknowledgedDate": undefined, + "AvailableDate": 2009-02-10T09:22:33.000Z, + "ReportId": "898899473", + "ReportRequestId": "2278662938", + "ReportType": "_GET_MERCHANT_LISTINGS_DATA_", + }, + }, + Object { + "quotaMax": 1000, + "quotaRemaining": 999, + "quotaResetOn": 2020-04-06T10:22:23.582Z, + "requestId": "0", + "timestamp": 2020-05-06T09:22:23.582Z, + }, +] +`; + exports[`reports getReportRequestCount returns report request count if succesful 1`] = ` Array [ Object {