This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: made getFeedSubmissionsList and fix tests
- Loading branch information
1 parent
1c143e8
commit cf2c0f2
Showing
4 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,58 @@ | ||
import { HttpClient } from '../http' | ||
import { boolean, Codec, GetInterface, optional, unknown } from 'purify-ts' | ||
|
||
import { ParsingError } from '../error' | ||
import { HttpClient, RequestMeta, Resource } from '../http' | ||
import { nextToken as nextTokenCodec } from '../parsing' | ||
|
||
const FEEDS_API_VERSION = '2009-01-01' | ||
interface GetFeedSubmissionListParameters { | ||
FeedSubmissionIdList?: string[] | ||
MaxCount?: number | ||
FeedTypeList?: string[] | ||
FeedProcessingStatusList?: string[] | ||
SubmittedFromDate?: Date | ||
SubmittedToDate?: Date | ||
} | ||
|
||
const GetFeedSubmissionList = Codec.interface({ | ||
HasToken: optional(boolean), | ||
NextToken: optional(nextTokenCodec('GetFeedSubmissionList')), | ||
FeedSubmissionInfo: optional(unknown), | ||
}) | ||
|
||
type GetFeedSubmissionList = GetInterface<typeof GetFeedSubmissionList> | ||
|
||
const GetFeedSubmissionListResponse = Codec.interface({ | ||
GetFeedSubmissionListResponse: Codec.interface({ | ||
GetFeedSubmissionListResult: GetFeedSubmissionList, | ||
}), | ||
}) | ||
|
||
export class Feeds { | ||
constructor(private httpClient: HttpClient) {} | ||
|
||
async getFeedSubmissionList( | ||
parameters: GetFeedSubmissionListParameters = {}, | ||
): Promise<[GetFeedSubmissionList, RequestMeta]> { | ||
const [response, meta] = await this.httpClient.request('POST', { | ||
resource: Resource.Feeds, | ||
version: FEEDS_API_VERSION, | ||
action: 'GetFeedSubmissionList', | ||
parameters: { | ||
'FeedSubmissionIdList.Id': parameters.FeedSubmissionIdList, | ||
MaxCount: parameters.MaxCount, | ||
'FeedTypeList.Type': parameters.FeedTypeList, | ||
'FeedProcessingStatusList.Status': parameters.FeedProcessingStatusList, | ||
SubmittedFromDate: parameters.SubmittedFromDate?.toISOString(), | ||
SubmittedToDate: parameters.SubmittedToDate?.toISOString(), | ||
}, | ||
}) | ||
|
||
return GetFeedSubmissionListResponse.decode(response).caseOf({ | ||
Right: (x) => [x.GetFeedSubmissionListResponse.GetFeedSubmissionListResult, meta], | ||
Left: (error) => { | ||
throw new ParsingError(error) | ||
}, | ||
}) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`feeds getFeedSubmissionList returns a next token and feed submission info if succesful 1`] = ` | ||
Array [ | ||
Object { | ||
"FeedSubmissionInfo": Object { | ||
"FeedProcessingStatus": "_SUBMITTED_", | ||
"FeedSubmissionId": 2291326430, | ||
"FeedType": "_POST_PRODUCT_DATA_", | ||
"SubmittedDate": "2009-02-20T02:10:35+00:00", | ||
}, | ||
"NextToken": NextToken { | ||
"action": "GetFeedSubmissionList", | ||
"token": "2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=", | ||
}, | ||
}, | ||
Object { | ||
"quotaMax": 1000, | ||
"quotaRemaining": 999, | ||
"quotaResetOn": 2020-04-06T10:22:23.582Z, | ||
"requestId": "0", | ||
"timestamp": 2020-05-06T09:22:23.582Z, | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters