-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes generated by c62ce6b46cd0bc42a2aff60cbba5cf6a4c550008
- Loading branch information
1 parent
122a5f2
commit 01d6655
Showing
9 changed files
with
334 additions
and
175 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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,90 @@ | ||
'use strict'; | ||
|
||
import { Api } from '../api/api'; | ||
import * as Types from '../types/Types'; | ||
|
||
interface ExportResponse extends Types.Export, Types.APIResponse {} | ||
|
||
interface ExportListResponse extends Types.APIResponse { | ||
exports: Types.Export[]; | ||
meta: Types.ListMeta; | ||
} | ||
|
||
interface ExportListRequest { | ||
// Cursor pointing to the start of the desired set. | ||
|
||
after?: string; | ||
|
||
// Cursor pointing to the end of the desired set. | ||
|
||
before?: string; | ||
|
||
// Number of records to return. | ||
|
||
limit?: string; | ||
} | ||
|
||
export class ExportService { | ||
private api: Api; | ||
|
||
constructor(api) { | ||
this.api = api; | ||
} | ||
|
||
async find(identity: string): Promise<ExportResponse> { | ||
const urlParameters = [{ key: 'identity', value: identity }]; | ||
const requestParams = { | ||
path: '/exports/:identity', | ||
method: 'get', | ||
urlParameters, | ||
|
||
payloadKey: null, | ||
fetch: null, | ||
}; | ||
|
||
const response = await this.api.request(requestParams); | ||
const formattedResponse: ExportResponse = { | ||
...response.body['exports'], | ||
__response__: response.__response__, | ||
}; | ||
|
||
return formattedResponse; | ||
} | ||
|
||
async list( | ||
requestParameters: ExportListRequest | ||
): Promise<ExportListResponse> { | ||
const urlParameters = []; | ||
const requestParams = { | ||
path: '/exports', | ||
method: 'get', | ||
urlParameters, | ||
requestParameters, | ||
payloadKey: null, | ||
fetch: null, | ||
}; | ||
|
||
const response = await this.api.request(requestParams); | ||
const formattedResponse: ExportListResponse = { | ||
...response.body, | ||
__response__: response.__response__, | ||
}; | ||
|
||
return formattedResponse; | ||
} | ||
|
||
async *all( | ||
requestParameters: ExportListRequest | ||
): AsyncGenerator<Types.Export, void, unknown> { | ||
let cursor = undefined; | ||
do { | ||
const list = await this.list({ ...requestParameters, after: cursor }); | ||
|
||
for (const exportdata of list.exports) { | ||
yield exportdata; | ||
} | ||
|
||
cursor = list.meta.cursors.after; | ||
} while (cursor); | ||
} | ||
} |
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
Oops, something went wrong.