Skip to content

Commit

Permalink
Merge pull request #164 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Template changes
  • Loading branch information
hjheath authored Sep 26, 2023
2 parents 7b1dd75 + 4dff0c4 commit ed870cb
Show file tree
Hide file tree
Showing 13 changed files with 660 additions and 303 deletions.
579 changes: 332 additions & 247 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
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": {
Expand Down
11 changes: 11 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { MandateService } from './services/mandateService';
import { MandateImportService } from './services/mandateImportService';
import { MandateImportEntryService } from './services/mandateImportEntryService';
import { MandatePdfService } from './services/mandatePdfService';
import { NegativeBalanceLimitService } from './services/negativeBalanceLimitService';
import { PayerAuthorisationService } from './services/payerAuthorisationService';
import { PaymentService } from './services/paymentService';
import { PayoutService } from './services/payoutService';
Expand Down Expand Up @@ -56,6 +57,7 @@ export class GoCardlessClient {
private _mandateImports: MandateImportService;
private _mandateImportEntries: MandateImportEntryService;
private _mandatePdfs: MandatePdfService;
private _negativeBalanceLimits: NegativeBalanceLimitService;
private _payerAuthorisations: PayerAuthorisationService;
private _payments: PaymentService;
private _payouts: PayoutService;
Expand Down Expand Up @@ -91,6 +93,7 @@ export class GoCardlessClient {
this._mandateImports = undefined;
this._mandateImportEntries = undefined;
this._mandatePdfs = undefined;
this._negativeBalanceLimits = undefined;
this._payerAuthorisations = undefined;
this._payments = undefined;
this._payouts = undefined;
Expand Down Expand Up @@ -259,6 +262,14 @@ export class GoCardlessClient {
return this._mandatePdfs;
}

get negativeBalanceLimits(): NegativeBalanceLimitService {
if (!this._negativeBalanceLimits) {
this._negativeBalanceLimits = new NegativeBalanceLimitService(this._api);
}

return this._negativeBalanceLimits;
}

get payerAuthorisations(): PayerAuthorisationService {
if (!this._payerAuthorisations) {
this._payerAuthorisations = new PayerAuthorisationService(this._api);
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ enum Environments {
Sandbox = 'SANDBOX',
}

const CLIENT_VERSION = '3.14.0';
const CLIENT_VERSION = '3.15.0';
const API_VERSION = '2015-07-06';

export { Environments, CLIENT_VERSION, API_VERSION };
4 changes: 2 additions & 2 deletions src/services/billingRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface BillingRequestCreateRequest {
// Should not be set if GoCardless payment intelligence feature is used.
//
// See [Billing Requests: Retain customers with
// Fallbacks](https://developer.gocardless.com/getting-started/billing-requests/retain-customers-with-fallbacks/)
// Fallbacks](https://developer.gocardless.com/billing-requests/retain-customers-with-fallbacks/)
// for more information.

fallback_enabled?: boolean;
Expand Down Expand Up @@ -186,7 +186,7 @@ interface BillingRequestChooseCurrencyRequest {
// Currently "AUD", "CAD", "DKK", "EUR", "GBP", "NZD", "SEK" and "USD" are
// supported.

currency?: string;
currency: string;

// Key-value store of custom data. Up to 3 keys are permitted, with key names up
// to 50 characters and values up to 500 characters.
Expand Down
3 changes: 2 additions & 1 deletion src/services/creditorBankAccountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ interface CreditorBankAccountListRequest {

creditor?: string;

// Boolean value showing whether the bank account is enabled or disabled
// If `true`, only return enabled bank accounts. If `false`, only return
// disabled bank accounts.

enabled?: boolean;

Expand Down
50 changes: 22 additions & 28 deletions src/services/creditorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ interface CreditorListResponse extends Types.APIResponse {
}

interface CreditorCreateRequest {
// Prefix for the bank reference of payouts sent to this creditor. For instance,
// if
// the creditor's `bank_reference_prefix` was `ACME`, the bank reference of a
// payout
// sent to that creditor could be `ACME-8G7Q8`.
//
// This prefix is also used for refunds in EUR and GBP.
//

bank_reference_prefix?: string;

// [ISO 3166-1 alpha-2
// code.](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)

Expand Down Expand Up @@ -56,6 +67,17 @@ interface CreditorUpdateRequest {

address_line3?: string;

// Prefix for the bank reference of payouts sent to this creditor. For instance,
// if
// the creditor's `bank_reference_prefix` was `ACME`, the bank reference of a
// payout
// sent to that creditor could be `ACME-8G7Q8`.
//
// This prefix is also used for refunds in EUR and GBP.
//

bank_reference_prefix?: string;

// The city of the creditor's address.

city?: string;
Expand All @@ -81,11 +103,6 @@ interface CreditorUpdateRequest {
region?: string;
}

interface CreditorApplySchemeIdentifierRequest {
// Resources linked to this Creditor.
links: Types.CreditorApplySchemeIdentifierRequestLinks;
}

export class CreditorService {
private api: Api;

Expand Down Expand Up @@ -198,27 +215,4 @@ export class CreditorService {

return formattedResponse;
}

async applySchemeIdentifier(
identity: string,
requestParameters: CreditorApplySchemeIdentifierRequest
): Promise<CreditorResponse> {
const urlParameters = [{ key: 'identity', value: identity }];
const requestParams = {
path: '/creditors/:identity/actions/apply_scheme_identifier',
method: 'post',
urlParameters,
requestParameters,
payloadKey: null,
fetch: null,
};

const response = await this.api.request(requestParams);
const formattedResponse: CreditorResponse = {
...response.body['creditors'],
__response__: response.__response__,
};

return formattedResponse;
}
}
3 changes: 0 additions & 3 deletions src/services/currencyExchangeRateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ interface CurrencyExchangeRateListRequest {

before?: string;

// The creation date of this CurrencyExchangeRate.
created_at?: Types.CreatedAtFilter;

// Number of records to return.

limit?: string;
Expand Down
3 changes: 3 additions & 0 deletions src/services/mandateImportService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ interface MandateImportListResponse extends Types.APIResponse {
}

interface MandateImportCreateRequest {
// Resources linked to this MandateImport.
links?: Types.MandateImportCreateRequestLinks;

// A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs",
// "becs_nz", "betalingsservice", "faster_payments", "pad", "pay_to" and
// "sepa_core" are supported.
Expand Down
123 changes: 123 additions & 0 deletions src/services/negativeBalanceLimitService.ts
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;
}
}
7 changes: 7 additions & 0 deletions src/services/schemeIdentifierService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ interface SchemeIdentifierListResponse extends Types.APIResponse {
}

interface SchemeIdentifierCreateRequest {
// Resources linked to this SchemeIdentifier.
links?: Types.SchemeIdentifierCreateRequestLinks;

// The name which appears on customers' bank statements. This should usually be
// the merchant's trading name.

Expand All @@ -32,6 +35,10 @@ interface SchemeIdentifierListRequest {

before?: string;

// Unique identifier, beginning with "CR".

creditor?: string;

// Number of records to return.

limit?: string;
Expand Down
4 changes: 4 additions & 0 deletions src/services/taxRateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ interface TaxRateListRequest {
// The jurisdiction this tax rate applies to

jurisdiction?: string;

// Number of records to return.

limit?: string;
}

export class TaxRateService {
Expand Down
Loading

0 comments on commit ed870cb

Please sign in to comment.