Skip to content

Commit

Permalink
Merge pull request #186 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Template changes
  • Loading branch information
KarmanLeung committed May 30, 2024
2 parents 47d9db9 + af3824a commit 3b95278
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.24.0",
"version": "3.25.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
22 changes: 22 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import { CustomerNotificationService } from './services/customerNotificationServ
import { EventService } from './services/eventService';
import { InstalmentScheduleService } from './services/instalmentScheduleService';
import { InstitutionService } from './services/institutionService';
import { LogoService } from './services/logoService';
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 { PayerThemeService } from './services/payerThemeService';
import { PaymentService } from './services/paymentService';
import { PayoutService } from './services/payoutService';
import { PayoutItemService } from './services/payoutItemService';
Expand Down Expand Up @@ -54,12 +56,14 @@ export class GoCardlessClient {
private _events: EventService;
private _instalmentSchedules: InstalmentScheduleService;
private _institutions: InstitutionService;
private _logos: LogoService;
private _mandates: MandateService;
private _mandateImports: MandateImportService;
private _mandateImportEntries: MandateImportEntryService;
private _mandatePdfs: MandatePdfService;
private _negativeBalanceLimits: NegativeBalanceLimitService;
private _payerAuthorisations: PayerAuthorisationService;
private _payerThemes: PayerThemeService;
private _payments: PaymentService;
private _payouts: PayoutService;
private _payoutItems: PayoutItemService;
Expand Down Expand Up @@ -91,12 +95,14 @@ export class GoCardlessClient {
this._events = undefined;
this._instalmentSchedules = undefined;
this._institutions = undefined;
this._logos = undefined;
this._mandates = undefined;
this._mandateImports = undefined;
this._mandateImportEntries = undefined;
this._mandatePdfs = undefined;
this._negativeBalanceLimits = undefined;
this._payerAuthorisations = undefined;
this._payerThemes = undefined;
this._payments = undefined;
this._payouts = undefined;
this._payoutItems = undefined;
Expand Down Expand Up @@ -233,6 +239,14 @@ export class GoCardlessClient {
return this._institutions;
}

get logos(): LogoService {
if (!this._logos) {
this._logos = new LogoService(this._api);
}

return this._logos;
}

get mandates(): MandateService {
if (!this._mandates) {
this._mandates = new MandateService(this._api);
Expand Down Expand Up @@ -281,6 +295,14 @@ export class GoCardlessClient {
return this._payerAuthorisations;
}

get payerThemes(): PayerThemeService {
if (!this._payerThemes) {
this._payerThemes = new PayerThemeService(this._api);
}

return this._payerThemes;
}

get payments(): PaymentService {
if (!this._payments) {
this._payments = new PaymentService(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.24.0';
const CLIENT_VERSION = '3.25.0';
const API_VERSION = '2015-07-06';

export { Environments, CLIENT_VERSION, API_VERSION };
54 changes: 54 additions & 0 deletions src/services/logoService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';

import { Api } from '../api/api';
import * as Types from '../types/Types';

interface LogoResponse extends Types.Logo, Types.APIResponse {}

interface LogoListResponse extends Types.APIResponse {
logos: Types.Logo[];
meta: Types.ListMeta;
}

interface LogoCreateForCreditorRequest {
// Base64 encoded string.

image: string;

// Resources linked to this Logo.
links?: Types.LogoCreateForCreditorRequestLinks;
}

export class LogoService {
private api: Api;

constructor(api) {
this.api = api;
}

async createForCreditor(
requestParameters: LogoCreateForCreditorRequest,
idempotencyKey = '',
customHeaders: Types.JsonMap = {}
): Promise<LogoResponse> {
const urlParameters = [];
const requestParams = {
path: '/branding/logos',
method: 'post',
urlParameters,
requestParameters,
payloadKey: 'logos',
idempotencyKey,
customHeaders,
fetch: undefined,
};

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

return formattedResponse;
}
}
66 changes: 66 additions & 0 deletions src/services/payerThemeService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use strict';

import { Api } from '../api/api';
import * as Types from '../types/Types';

interface PayerThemeResponse extends Types.PayerTheme, Types.APIResponse {}

interface PayerThemeListResponse extends Types.APIResponse {
payer_themes: Types.PayerTheme[];
meta: Types.ListMeta;
}

interface PayerThemeCreateForCreditorRequest {
// Colour for buttons background (hexcode)

button_background_colour?: string;

// Colour for content box border (hexcode)

content_box_border_colour?: string;

// Colour for header background (hexcode)

header_background_colour?: string;

// Colour for text links (hexcode)

link_text_colour?: string;

// Resources linked to this PayerTheme.
links?: Types.PayerThemeCreateForCreditorRequestLinks;
}

export class PayerThemeService {
private api: Api;

constructor(api) {
this.api = api;
}

async createForCreditor(
requestParameters: PayerThemeCreateForCreditorRequest,
idempotencyKey = '',
customHeaders: Types.JsonMap = {}
): Promise<PayerThemeResponse> {
const urlParameters = [];
const requestParams = {
path: '/branding/payer_themes',
method: 'post',
urlParameters,
requestParameters,
payloadKey: 'payer_themes',
idempotencyKey,
customHeaders,
fetch: undefined,
};

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

return formattedResponse;
}
}
6 changes: 6 additions & 0 deletions src/services/subscriptionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ interface SubscriptionPauseRequest {

// The number of cycles to pause a subscription for. A cycle is one duration of
// `interval` and `interval_unit`. This should be a non zero positive value.
// For AUD subscriptions with `interval_unit: weekly` the minimum value varies
// between `3` & `4` because of the [mandatory minimum waiting
// period](#subscriptions-resume-a-subscription).
// For NZD subscriptions with `interval_unit: weekly` the minimum value is `2`
// because of the [mandatory minimum waiting
// period](#subscriptions-resume-a-subscription).

pause_cycles?: number;
}
Expand Down
40 changes: 40 additions & 0 deletions src/types/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,17 @@ export interface BillingRequestPaymentRequest {
//
description?: string | null;

// This field will decide how GoCardless handles settlement of funds from the
// customer.
//
// - `managed` will be moved through GoCardless' account, batched, and payed
// out.
// - `direct` will be a direct transfer from the payer's account to the
// merchant where
// invoicing will be handled separately.
//
funds_settlement?: BillingRequestPaymentRequestFundsSettlement;

// Resources linked to this BillingRequestPaymentRequest.
links?: BillingRequestPaymentRequestLinks;

Expand All @@ -636,6 +647,11 @@ export interface BillingRequestPaymentRequest {
scheme?: string | null;
}

export enum BillingRequestPaymentRequestFundsSettlement {
Managed = 'managed',
Direct = 'direct',
}

/** Type for a billingrequestpaymentrequestlinks resource. */
export interface BillingRequestPaymentRequestLinks {
// (Optional) ID of the [payment](#core-endpoints-payments) that was created
Expand Down Expand Up @@ -2290,6 +2306,18 @@ export interface Institution {
/** Type for a institutionid resource. */
export interface InstitutionId {}

/** Type for a logo resource. */
export interface Logo {
// Unique identifier, beginning with "LO".
id?: string;
}

/** Type for a logocreateforcreditorrequestlinks resource. */
export interface LogoCreateForCreditorRequestLinks {
// ID of the creditor the logo belongs to
creditor?: string;
}

/** Type for a mandate resource. */
export interface Mandate {
// This field is ACH specific, sometimes referred to as [SEC
Expand Down Expand Up @@ -3041,6 +3069,18 @@ export enum PayerAuthorisationStatus {
Failed = 'failed',
}

/** Type for a payertheme resource. */
export interface PayerTheme {
// Unique identifier, beginning with "PTH".
id?: string;
}

/** Type for a payerthemecreateforcreditorrequestlinks resource. */
export interface PayerThemeCreateForCreditorRequestLinks {
// ID of the creditor the payer theme belongs to
creditor?: string | null;
}

/** Type for a payment resource. */
export interface Payment {
// Amount, in the lowest denomination for the currency (e.g. pence in GBP,
Expand Down

0 comments on commit 3b95278

Please sign in to comment.