diff --git a/src/sections/reports.ts b/src/sections/reports.ts index 8cd262dc..749ed5d1 100644 --- a/src/sections/reports.ts +++ b/src/sections/reports.ts @@ -281,9 +281,47 @@ const ManageReportScheduleResponse = Codec.interface({ }), }) +interface GetReportScheduleListParameters { + ReportTypeList?: ReportType[] +} + +const GetReportScheduleList = Codec.interface({ + NextToken: optional(nextTokenCodec('GetReportScheduleList')), + HasNext: optional(boolean), + ReportSchedule: optional(ReportSchedule), +}) + +type GetReportScheduleList = GetInterface + +const GetReportScheduleListResponse = Codec.interface({ + GetReportScheduleListResponse: Codec.interface({ + GetReportScheduleListResult: GetReportScheduleList, + }), +}) + export class Reports { constructor(private httpClient: HttpClient) {} + async getReportScheduleList( + parameters: GetReportScheduleListParameters, + ): Promise<[GetReportScheduleList, RequestMeta]> { + const [response, meta] = await this.httpClient.request('POST', { + resource: Resource.Reports, + version: REPORTS_API_VERSION, + action: 'GetReportScheduleList', + parameters: { + 'ReportTypeList.Type': parameters.ReportTypeList, + }, + }) + + return GetReportScheduleListResponse.decode(response).caseOf({ + Right: (x) => [x.GetReportScheduleListResponse.GetReportScheduleListResult, meta], + Left: (error) => { + throw new ParsingError(error) + }, + }) + } + async manageReportSchedule( parameters: ManageReportScheduleParameters, ): Promise<[ManageReportSchedule, RequestMeta]> { diff --git a/test/unit/__snapshots__/reports.test.ts.snap b/test/unit/__snapshots__/reports.test.ts.snap index edab1d5c..22d6f66a 100644 --- a/test/unit/__snapshots__/reports.test.ts.snap +++ b/test/unit/__snapshots__/reports.test.ts.snap @@ -350,6 +350,30 @@ Array [ ] `; +exports[`reports getReportScheduleList returns detailed information about a report schedule if succesful 1`] = ` +Array [ + Object { + "HasNext": false, + "NextToken": NextToken { + "action": "GetReportScheduleList", + "token": "", + }, + "ReportSchedule": Object { + "ReportType": "_GET_ORDERS_DATA_", + "Schedule": "_30_DAYS_", + "ScheduleDate": undefined, + }, + }, + Object { + "quotaMax": 1000, + "quotaRemaining": 999, + "quotaResetOn": 2020-04-06T10:22:23.582Z, + "requestId": "0", + "timestamp": 2020-05-06T09:22:23.582Z, + }, +] +`; + exports[`reports manageReportSchedule returns count and report schedule if succesful 1`] = ` Array [ Object {