-
Notifications
You must be signed in to change notification settings - Fork 20
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 #164 from gocardless/template-changes
Template changes
- Loading branch information
Showing
13 changed files
with
660 additions
and
303 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.14.0", | ||
"version": "3.15.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
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,123 @@ | ||
'use strict'; | ||
|
||
import { Api } from '../api/api'; | ||
import * as Types from '../types/Types'; | ||
|
||
interface NegativeBalanceLimitResponse | ||
extends Types.NegativeBalanceLimit, | ||
Types.APIResponse {} | ||
|
||
interface NegativeBalanceLimitListResponse extends Types.APIResponse { | ||
negative_balance_limits: Types.NegativeBalanceLimit[]; | ||
meta: Types.ListMeta; | ||
} | ||
|
||
interface NegativeBalanceLimitListRequest { | ||
// Cursor pointing to the start of the desired set. | ||
|
||
after?: string; | ||
|
||
// Cursor pointing to the end of the desired set. | ||
|
||
before?: string; | ||
|
||
// Unique identifier, beginning with "CR". | ||
|
||
creditor?: string; | ||
|
||
// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. | ||
// Currently "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are | ||
// supported. | ||
|
||
currency?: Types.NegativeBalanceLimitCurrency; | ||
|
||
// Number of records to return. | ||
|
||
limit?: string; | ||
} | ||
|
||
interface NegativeBalanceLimitCreateRequest { | ||
// The limit amount in pence (e.g. 10000 for a -100 GBP limit). | ||
|
||
balance_limit: string; | ||
|
||
// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code. | ||
// Currently "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are | ||
// supported. | ||
|
||
currency: Types.NegativeBalanceLimitCurrency; | ||
|
||
// Resources linked to this NegativeBalanceLimit. | ||
links?: Types.NegativeBalanceLimitCreateRequestLinks; | ||
} | ||
|
||
export class NegativeBalanceLimitService { | ||
private api: Api; | ||
|
||
constructor(api) { | ||
this.api = api; | ||
} | ||
|
||
async list( | ||
requestParameters: NegativeBalanceLimitListRequest | ||
): Promise<NegativeBalanceLimitListResponse> { | ||
const urlParameters = []; | ||
const requestParams = { | ||
path: '/negative_balance_limits', | ||
method: 'get', | ||
urlParameters, | ||
requestParameters, | ||
payloadKey: null, | ||
fetch: null, | ||
}; | ||
|
||
const response = await this.api.request(requestParams); | ||
const formattedResponse: NegativeBalanceLimitListResponse = { | ||
...response.body, | ||
__response__: response.__response__, | ||
}; | ||
|
||
return formattedResponse; | ||
} | ||
|
||
async *all( | ||
requestParameters: NegativeBalanceLimitListRequest | ||
): AsyncGenerator<Types.NegativeBalanceLimit, void, unknown> { | ||
let cursor = undefined; | ||
do { | ||
const list = await this.list({ ...requestParameters, after: cursor }); | ||
|
||
for (const negativebalancelimit of list.negative_balance_limits) { | ||
yield negativebalancelimit; | ||
} | ||
|
||
cursor = list.meta.cursors.after; | ||
} while (cursor); | ||
} | ||
|
||
async create( | ||
requestParameters: NegativeBalanceLimitCreateRequest, | ||
idempotencyKey = '', | ||
customHeaders: Types.JsonMap = {} | ||
): Promise<NegativeBalanceLimitResponse> { | ||
const urlParameters = []; | ||
const requestParams = { | ||
path: '/negative_balance_limits', | ||
method: 'post', | ||
urlParameters, | ||
requestParameters, | ||
payloadKey: 'negative_balance_limits', | ||
idempotencyKey, | ||
customHeaders, | ||
fetch: undefined, | ||
}; | ||
|
||
const response = await this.api.request(requestParams); | ||
const formattedResponse: NegativeBalanceLimitResponse = { | ||
...(response.body?.['negative_balance_limits'] ?? response), | ||
__response__: response.__response__, | ||
}; | ||
|
||
return formattedResponse; | ||
} | ||
} |
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
Oops, something went wrong.