Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template changes #191

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 91 additions & 129 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.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": {
Expand Down
11 changes: 11 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { CustomerService } from './services/customerService';
import { CustomerBankAccountService } from './services/customerBankAccountService';
import { CustomerNotificationService } from './services/customerNotificationService';
import { EventService } from './services/eventService';
import { ExportService } from './services/exportService';
import { InstalmentScheduleService } from './services/instalmentScheduleService';
import { InstitutionService } from './services/institutionService';
import { LogoService } from './services/logoService';
Expand Down Expand Up @@ -54,6 +55,7 @@ export class GoCardlessClient {
private _customerBankAccounts: CustomerBankAccountService;
private _customerNotifications: CustomerNotificationService;
private _events: EventService;
private _exports: ExportService;
private _instalmentSchedules: InstalmentScheduleService;
private _institutions: InstitutionService;
private _logos: LogoService;
Expand Down Expand Up @@ -93,6 +95,7 @@ export class GoCardlessClient {
this._customerBankAccounts = undefined;
this._customerNotifications = undefined;
this._events = undefined;
this._exports = undefined;
this._instalmentSchedules = undefined;
this._institutions = undefined;
this._logos = undefined;
Expand Down Expand Up @@ -223,6 +226,14 @@ export class GoCardlessClient {
return this._events;
}

get exports(): ExportService {
if (!this._exports) {
this._exports = new ExportService(this._api);
}

return this._exports;
}

get instalmentSchedules(): InstalmentScheduleService {
if (!this._instalmentSchedules) {
this._instalmentSchedules = new InstalmentScheduleService(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.27.0';
const CLIENT_VERSION = '3.28.0';
const API_VERSION = '2015-07-06';

export { Environments, CLIENT_VERSION, API_VERSION };
7 changes: 3 additions & 4 deletions src/services/billingRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ interface BillingRequestCollectCustomerDetailsRequest {
}

interface BillingRequestCollectBankAccountRequest {
// Name of the account holder, as known by the bank. Usually this is the same as
// the name stored with the linked [creditor](#core-endpoints-creditors). This
// field will be transliterated, upcased and truncated to 18 characters. This
// field is required unless the request includes a [customer bank account
// Name of the account holder, as known by the bank. This field will be
// transliterated, upcased and truncated to 18 characters. This field is
// required unless the request includes a [customer bank account
// token](#javascript-flow-customer-bank-account-tokens).

account_holder_name?: string;
Expand Down
18 changes: 10 additions & 8 deletions src/services/billingRequestTemplateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ interface BillingRequestTemplateCreateRequest {

// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code.
// `GBP` and `EUR` supported; `GBP` with your customers in the UK and for `EUR`
// with your customers in Germany only.
// with your customers in supported Eurozone countries only.

payment_request_currency?: string;

Expand All @@ -116,9 +116,10 @@ interface BillingRequestTemplateCreateRequest {

// (Optional) A scheme used for Open Banking payments. Currently
// `faster_payments` is supported in the UK (GBP) and `sepa_credit_transfer` and
// `sepa_instant_credit_transfer` are supported in Germany (EUR). In Germany,
// `sepa_credit_transfer` is used as the default. Please be aware that
// `sepa_instant_credit_transfer` may incur an additional fee for your customer.
// `sepa_instant_credit_transfer` are supported in supported Eurozone countries
// (EUR). For Eurozone countries, `sepa_credit_transfer` is used as the default.
// Please be aware that `sepa_instant_credit_transfer` may incur an additional
// fee for your customer.

payment_request_scheme?: string;

Expand Down Expand Up @@ -196,7 +197,7 @@ interface BillingRequestTemplateUpdateRequest {

// [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217#Active_codes) currency code.
// `GBP` and `EUR` supported; `GBP` with your customers in the UK and for `EUR`
// with your customers in Germany only.
// with your customers in supported Eurozone countries only.

payment_request_currency?: string;

Expand All @@ -214,9 +215,10 @@ interface BillingRequestTemplateUpdateRequest {

// (Optional) A scheme used for Open Banking payments. Currently
// `faster_payments` is supported in the UK (GBP) and `sepa_credit_transfer` and
// `sepa_instant_credit_transfer` are supported in Germany (EUR). In Germany,
// `sepa_credit_transfer` is used as the default. Please be aware that
// `sepa_instant_credit_transfer` may incur an additional fee for your customer.
// `sepa_instant_credit_transfer` are supported in supported Eurozone countries
// (EUR). For Eurozone countries, `sepa_credit_transfer` is used as the default.
// Please be aware that `sepa_instant_credit_transfer` may incur an additional
// fee for your customer.

payment_request_scheme?: string;

Expand Down
7 changes: 3 additions & 4 deletions src/services/customerBankAccountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ interface CustomerBankAccountListResponse extends Types.APIResponse {
}

interface CustomerBankAccountCreateRequest {
// Name of the account holder, as known by the bank. Usually this is the same as
// the name stored with the linked [creditor](#core-endpoints-creditors). This
// field will be transliterated, upcased and truncated to 18 characters. This
// field is required unless the request includes a [customer bank account
// Name of the account holder, as known by the bank. This field will be
// transliterated, upcased and truncated to 18 characters. This field is
// required unless the request includes a [customer bank account
// token](#javascript-flow-customer-bank-account-tokens).

account_holder_name?: string;
Expand Down
10 changes: 8 additions & 2 deletions src/services/eventService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ interface EventListRequest {

creditor?: string;

// ID of an export. If specified, this endpoint will return all events for the
// given export.

export?: string;

// Includes linked resources in the response. Must be used with the
// `resource_type` parameter specified. The include should be one of:
// <ul>
Expand Down Expand Up @@ -94,12 +99,13 @@ interface EventListRequest {

// Type of resource that you'd like to get all events for.
// Cannot be used together with the `billing_request`, `creditor`,
// `instalment_schedule`, `mandate`, `payer_authorisation`, `payment`, `payout`,
// `refund`, `scheme_identifier` or `subscription` parameters.
// `export`,`instalment_schedule`, `mandate`, `payer_authorisation`, `payment`,
// `payout`, `refund`, `scheme_identifier` or `subscription` parameters.
// The type can be one of:
// <ul>
// <li>`billing_requests`</li>
// <li>`creditors`</li>
// <li>`exports`</li>
// <li>`instalment_schedules`</li>
// <li>`mandates`</li>
// <li>`payer_authorisations`</li>
Expand Down
90 changes: 90 additions & 0 deletions src/services/exportService.ts
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);
}
}
17 changes: 17 additions & 0 deletions src/services/mandatePdfService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ interface MandatePdfCreateRequest {

city?: string;

// The customer's company name. Used to populate the "Customer Name or Company
// name" field on the PDF.

company_name?: string;

// [ISO
// 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements)
// alpha-2 code. Required if providing local details.
Expand All @@ -70,6 +75,18 @@ interface MandatePdfCreateRequest {

danish_identity_number?: string;

// The customer's family name (i.e. last name). Used to populate the "Customer
// Name or Company name" field on the PDF. Ignored if `company_name` is
// provided.

family_name?: string;

// The customer's given name (i.e. first name). Used to populate the "Customer
// Name or Company name" field on the PDF. Ignored if `company_name` is
// provided.

given_name?: string;

// International Bank Account Number. Alternatively you can provide [local
// details](#appendix-local-bank-details). IBANs cannot be provided for Autogiro
// mandates.
Expand Down
Loading
Loading