From 1c578de5085dab7888749a6ba76e95159b28444c Mon Sep 17 00:00:00 2001 From: Robot Date: Thu, 30 May 2024 13:36:20 +0000 Subject: [PATCH] Changes generated by c55b5b124f1deab3efd5df00101041ded4cf8e14 --- src/client.ts | 22 ++++++++++ src/services/logoService.ts | 54 +++++++++++++++++++++++ src/services/payerThemeService.ts | 66 +++++++++++++++++++++++++++++ src/services/subscriptionService.ts | 6 +++ src/types/Types.ts | 40 +++++++++++++++++ 5 files changed, 188 insertions(+) create mode 100644 src/services/logoService.ts create mode 100644 src/services/payerThemeService.ts diff --git a/src/client.ts b/src/client.ts index 4091fbd..e648015 100644 --- a/src/client.ts +++ b/src/client.ts @@ -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'; @@ -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; @@ -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; @@ -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); @@ -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); diff --git a/src/services/logoService.ts b/src/services/logoService.ts new file mode 100644 index 0000000..877f85d --- /dev/null +++ b/src/services/logoService.ts @@ -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 { + 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; + } +} diff --git a/src/services/payerThemeService.ts b/src/services/payerThemeService.ts new file mode 100644 index 0000000..78e73e8 --- /dev/null +++ b/src/services/payerThemeService.ts @@ -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 { + 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; + } +} diff --git a/src/services/subscriptionService.ts b/src/services/subscriptionService.ts index 2931cad..f1d0a4b 100644 --- a/src/services/subscriptionService.ts +++ b/src/services/subscriptionService.ts @@ -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; } diff --git a/src/types/Types.ts b/src/types/Types.ts index c079d46..3f26235 100644 --- a/src/types/Types.ts +++ b/src/types/Types.ts @@ -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; @@ -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 @@ -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 @@ -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,