-
Notifications
You must be signed in to change notification settings - Fork 17
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 #151 from gocardless/template-changes
Release version 3.9.0
- Loading branch information
Showing
11 changed files
with
597 additions
and
136 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
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.8.0", | ||
"version": "3.9.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
'use strict'; | ||
|
||
import { Api } from '../api/api'; | ||
import * as Types from '../types/Types'; | ||
|
||
interface SchemeIdentifierResponse | ||
extends Types.SchemeIdentifier, | ||
Types.APIResponse {} | ||
|
||
interface SchemeIdentifierListResponse extends Types.APIResponse { | ||
scheme_identifiers: Types.SchemeIdentifier[]; | ||
meta: Types.ListMeta; | ||
} | ||
|
||
interface SchemeIdentifierCreateRequest { | ||
// The name which appears on customers' bank statements. This should usually be | ||
// the merchant's trading name. | ||
|
||
name: string; | ||
|
||
// The scheme which this scheme identifier applies to. | ||
|
||
scheme: Types.SchemeIdentifierScheme; | ||
} | ||
|
||
interface SchemeIdentifierListRequest { | ||
// 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 SchemeIdentifierService { | ||
private api: Api; | ||
|
||
constructor(api) { | ||
this.api = api; | ||
} | ||
|
||
async create( | ||
requestParameters: SchemeIdentifierCreateRequest, | ||
idempotencyKey = '', | ||
customHeaders: Types.JsonMap = {} | ||
): Promise<SchemeIdentifierResponse> { | ||
const urlParameters = []; | ||
const requestParams = { | ||
path: '/scheme_identifiers', | ||
method: 'post', | ||
urlParameters, | ||
requestParameters, | ||
payloadKey: 'scheme_identifiers', | ||
idempotencyKey, | ||
customHeaders, | ||
fetch: async identity => this.find(identity), | ||
}; | ||
|
||
const response = await this.api.request(requestParams); | ||
const formattedResponse: SchemeIdentifierResponse = { | ||
...(response.body?.['scheme_identifiers'] ?? response), | ||
__response__: response.__response__, | ||
}; | ||
|
||
return formattedResponse; | ||
} | ||
|
||
async list( | ||
requestParameters: SchemeIdentifierListRequest | ||
): Promise<SchemeIdentifierListResponse> { | ||
const urlParameters = []; | ||
const requestParams = { | ||
path: '/scheme_identifiers', | ||
method: 'get', | ||
urlParameters, | ||
requestParameters, | ||
payloadKey: null, | ||
fetch: null, | ||
}; | ||
|
||
const response = await this.api.request(requestParams); | ||
const formattedResponse: SchemeIdentifierListResponse = { | ||
...response.body, | ||
__response__: response.__response__, | ||
}; | ||
|
||
return formattedResponse; | ||
} | ||
|
||
async *all( | ||
requestParameters: SchemeIdentifierListRequest | ||
): AsyncGenerator<Types.SchemeIdentifier, void, unknown> { | ||
let cursor = undefined; | ||
do { | ||
const list = await this.list({ ...requestParameters, after: cursor }); | ||
|
||
for (const schemeidentifier of list.scheme_identifiers) { | ||
yield schemeidentifier; | ||
} | ||
|
||
cursor = list.meta.cursors.after; | ||
} while (cursor); | ||
} | ||
|
||
async find(identity: string): Promise<SchemeIdentifierResponse> { | ||
const urlParameters = [{ key: 'identity', value: identity }]; | ||
const requestParams = { | ||
path: '/scheme_identifiers/:identity', | ||
method: 'get', | ||
urlParameters, | ||
|
||
payloadKey: null, | ||
fetch: null, | ||
}; | ||
|
||
const response = await this.api.request(requestParams); | ||
const formattedResponse: SchemeIdentifierResponse = { | ||
...response.body['scheme_identifiers'], | ||
__response__: response.__response__, | ||
}; | ||
|
||
return formattedResponse; | ||
} | ||
} |
Oops, something went wrong.