Skip to content

Commit

Permalink
Changes generated by 077582650d394c0b2af7c83ab8cb677b40b87b1b
Browse files Browse the repository at this point in the history
  • Loading branch information
gocardless-robot committed Aug 16, 2021
1 parent c9bf22d commit b1be7e0
Show file tree
Hide file tree
Showing 10 changed files with 718 additions and 87 deletions.
13 changes: 13 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BankAuthorisationService } from './services/bankAuthorisationService';
import { BankDetailsLookupService } from './services/bankDetailsLookupService';
import { BillingRequestService } from './services/billingRequestService';
import { BillingRequestFlowService } from './services/billingRequestFlowService';
import { BillingRequestTemplateService } from './services/billingRequestTemplateService';
import { CreditorService } from './services/creditorService';
import { CreditorBankAccountService } from './services/creditorBankAccountService';
import { CurrencyExchangeRateService } from './services/currencyExchangeRateService';
Expand Down Expand Up @@ -37,6 +38,7 @@ export class GoCardlessClient {
private _bankDetailsLookups: BankDetailsLookupService;
private _billingRequests: BillingRequestService;
private _billingRequestFlows: BillingRequestFlowService;
private _billingRequestTemplates: BillingRequestTemplateService;
private _creditors: CreditorService;
private _creditorBankAccounts: CreditorBankAccountService;
private _currencyExchangeRates: CurrencyExchangeRateService;
Expand Down Expand Up @@ -68,6 +70,7 @@ export class GoCardlessClient {
this._bankDetailsLookups = undefined;
this._billingRequests = undefined;
this._billingRequestFlows = undefined;
this._billingRequestTemplates = undefined;
this._creditors = undefined;
this._creditorBankAccounts = undefined;
this._currencyExchangeRates = undefined;
Expand Down Expand Up @@ -125,6 +128,16 @@ export class GoCardlessClient {
return this._billingRequestFlows;
}

get billingRequestTemplates(): BillingRequestTemplateService {
if (!this._billingRequestTemplates) {
this._billingRequestTemplates = new BillingRequestTemplateService(
this._api
);
}

return this._billingRequestTemplates;
}

get creditors(): CreditorService {
if (!this._creditors) {
this._creditors = new CreditorService(this._api);
Expand Down
35 changes: 32 additions & 3 deletions src/services/billingRequestFlowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ interface BillingRequestFlowListResponse extends Types.APIResponse {
}

interface BillingRequestFlowCreateRequest {
// Fulfil the Billing Request on completion of the flow (true by default)

auto_fulfil?: boolean;

// Resources linked to this BillingRequestFlow.
links: Types.BillingRequestFlowCreateRequestLinks;

// If true, the payer will not be able to edit their existing details (e.g.
// customer and bank account) within the billing request flow.
// If true, the payer will not be able to change their bank account within the
// flow

lock_bank_account?: boolean;

lock_existing_details?: boolean;
// If true, the payer will not be able to edit their customer details within the
// flow

lock_customer_details?: boolean;

// URL that the payer can be redirected to after completing the request flow.

Expand Down Expand Up @@ -58,4 +67,24 @@ export class BillingRequestFlowService {

return formattedResponse;
}

async initialise(identity: string): Promise<BillingRequestFlowResponse> {
const urlParameters = [{ key: 'identity', value: identity }];
const requestParams = {
path: '/billing_request_flows/:identity/actions/initialise',
method: 'post',
urlParameters,

payloadKey: null,
fetch: null,
};

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

return formattedResponse;
}
}
47 changes: 39 additions & 8 deletions src/services/billingRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ interface BillingRequestListRequest {
}

interface BillingRequestCreateRequest {
// Should the billing request be fulfilled as soon as it's ready

auto_fulfil?: boolean;

// Resources linked to this BillingRequest.
links?: Types.BillingRequestCreateRequestLinks;

Expand All @@ -74,7 +70,7 @@ interface BillingRequestCollectCustomerDetailsRequest {
customer_billing_detail?: Types.BillingRequestCustomerBillingDetail;
}

interface BillingRequestCollectBankAccountDetailsRequest {
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
Expand All @@ -88,6 +84,11 @@ interface BillingRequestCollectBankAccountDetailsRequest {

account_number?: string;

// Account number suffix (only for bank accounts denominated in NZD) - see
// [local details](#local-bank-details-new-zealand) for more information.

account_number_suffix?: string;

// Bank account type. Required for USD-denominated bank accounts. Must not be
// provided for bank accounts in other currencies. See [local
// details](#local-bank-details-united-states) for more information.
Expand Down Expand Up @@ -137,6 +138,13 @@ interface BillingRequestFulfilRequest {
metadata?: Types.JsonMap;
}

interface BillingRequestConfirmPayerDetailsRequest {
// 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.

metadata?: Types.JsonMap;
}

interface BillingRequestCancelRequest {
// 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 Expand Up @@ -267,13 +275,13 @@ export class BillingRequestService {
return formattedResponse;
}

async collect_bank_account_details(
async collect_bank_account(
identity: string,
requestParameters: BillingRequestCollectBankAccountDetailsRequest
requestParameters: BillingRequestCollectBankAccountRequest
): Promise<BillingRequestResponse> {
const urlParameters = [{ key: 'identity', value: identity }];
const requestParams = {
path: '/billing_requests/:identity/actions/collect_bank_account_details',
path: '/billing_requests/:identity/actions/collect_bank_account',
method: 'post',
urlParameters,
requestParameters,
Expand Down Expand Up @@ -313,6 +321,29 @@ export class BillingRequestService {
return formattedResponse;
}

async confirm_payer_details(
identity: string,
requestParameters: BillingRequestConfirmPayerDetailsRequest
): Promise<BillingRequestResponse> {
const urlParameters = [{ key: 'identity', value: identity }];
const requestParams = {
path: '/billing_requests/:identity/actions/confirm_payer_details',
method: 'post',
urlParameters,
requestParameters,
payloadKey: null,
fetch: null,
};

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

return formattedResponse;
}

async cancel(
identity: string,
requestParameters: BillingRequestCancelRequest
Expand Down
Loading

0 comments on commit b1be7e0

Please sign in to comment.