Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
feat: get report schedule list
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jun 11, 2020
1 parent 0b30891 commit da73f83
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/sections/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof GetReportScheduleList>

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]> {
Expand Down
24 changes: 24 additions & 0 deletions test/unit/__snapshots__/reports.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit da73f83

Please sign in to comment.