-
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.
Merge pull request #191 from gocardless/template-changes
Template changes
- Loading branch information
Showing
11 changed files
with
337 additions
and
178 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "gocardless-nodejs", | ||
"version": "3.27.0", | ||
"version": "3.28.0", | ||
"description": "Node.js client for the GoCardless API - a powerful, simple solution for the collection of recurring bank-to-bank payments", | ||
"author": "GoCardless Ltd <[email protected]>", | ||
"repository": { | ||
|
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
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.