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 list nt
Browse files Browse the repository at this point in the history
  • Loading branch information
justinemmanuelmercado committed Jun 9, 2020
1 parent 0aae222 commit b154318
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/sections/reports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof GetReportListResult>
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]> {
Expand Down Expand Up @@ -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,
},
Expand Down
27 changes: 27 additions & 0 deletions test/unit/__snapshots__/reports.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b154318

Please sign in to comment.