Skip to content
Open
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
34 changes: 31 additions & 3 deletions src/services/balancePlatform/accountHoldersApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { AccountHolderInfo } from "../../typings/balancePlatform/models";
import { AccountHolderUpdateRequest } from "../../typings/balancePlatform/models";
import { GetTaxFormResponse } from "../../typings/balancePlatform/models";
import { PaginatedBalanceAccountsResponse } from "../../typings/balancePlatform/models";
import { TaxFormSummaryResponse } from "../../typings/balancePlatform/models";
import { TransactionRulesResponse } from "../../typings/balancePlatform/models";

/**
Expand Down Expand Up @@ -128,9 +129,9 @@ export class AccountHoldersApi extends Service {
* @summary Get a tax form
* @param id {@link string } The unique identifier of the account holder.
* @param requestOptions {@link IRequest.Options }
* @param formType {@link 'US1099k' | 'US1099nec' } (Required) The type of tax form you want to retrieve. Accepted values are **US1099k** and **US1099nec**
* @param year {@link number } (Required) The tax year in YYYY format for the tax form you want to retrieve
* @param legalEntityId {@link string } The legal entity reference whose tax form you want to retrieve
* @param formType {@link 'US1099k' | 'US1099nec' } (Required) The type of tax form you want to retrieve. Accepted values are **US1099k** and **US1099nec**.
* @param year {@link number } (Required) The tax year in **YYYY** format for the tax form you want to retrieve.
* @param legalEntityId {@link string } The legal entity reference whose tax form you want to retrieve.
* @return {@link GetTaxFormResponse }
*/
public async getTaxForm(id: string, formType: "US1099k" | "US1099nec", year: number, legalEntityId?: string, requestOptions?: IRequest.Options): Promise<GetTaxFormResponse> {
Expand All @@ -155,6 +156,33 @@ export class AccountHoldersApi extends Service {
return ObjectSerializer.deserialize(response, "GetTaxFormResponse");
}

/**
* @summary Get summary of tax forms for an account holder
* @param id {@link string } The unique identifier of the account holder.
* @param requestOptions {@link IRequest.Options }
* @param formType {@link string } (Required) The type of tax form you want a summary for. Accepted values are **US1099k** and **US1099nec**.
* @return {@link TaxFormSummaryResponse }
*/
public async getTaxFormSummary(id: string, formType: string, requestOptions?: IRequest.Options): Promise<TaxFormSummaryResponse> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better type safety and to align with the JSDoc, which states accepted values are US1099k and US1099nec, the formType parameter should be typed as a string literal union instead of a generic string. This is consistent with other methods in this API, like getTaxForm.

Suggested change
public async getTaxFormSummary(id: string, formType: string, requestOptions?: IRequest.Options): Promise<TaxFormSummaryResponse> {
public async getTaxFormSummary(id: string, formType: "US1099k" | "US1099nec", requestOptions?: IRequest.Options): Promise<TaxFormSummaryResponse> {

const endpoint = `${this.baseUrl}/accountHolders/{id}/taxFormSummary`
.replace("{" + "id" + "}", encodeURIComponent(String(id)));
const resource = new Resource(this, endpoint);

const hasDefinedQueryParams = formType;
if(hasDefinedQueryParams) {
if(!requestOptions) requestOptions = {};
if(!requestOptions.params) requestOptions.params = {};
if(formType) requestOptions.params["formType"] = formType;
}
Comment on lines +171 to +176
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block for handling query parameters is verbose and contains redundant checks. Since formType is a required parameter, it will always have a value. The logic can be simplified to be more direct and readable by using modern TypeScript features and promoting immutability.

        requestOptions = {
            ...requestOptions,
            params: {
                ...requestOptions?.params,
                formType,
            },
        };

const response = await getJsonResponse<string, TaxFormSummaryResponse>(
resource,
"",
{ ...requestOptions, method: "GET" }
);

return ObjectSerializer.deserialize(response, "TaxFormSummaryResponse");
}

/**
* @summary Update an account holder
* @param id {@link string } The unique identifier of the account holder.
Expand Down
122 changes: 122 additions & 0 deletions src/services/balancePlatform/directDebitMandatesApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* The version of the OpenAPI document: v2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit this class manually.
*/


import getJsonResponse from "../../helpers/getJsonResponse";
import Service from "../../service";
import Client from "../../client";
import { IRequest } from "../../typings/requestOptions";
import Resource from "../resource";

import { ObjectSerializer } from "../../typings/balancePlatform/objectSerializer";
import { ListMandatesResponse } from "../../typings/balancePlatform/models";
import { Mandate } from "../../typings/balancePlatform/models";
import { PatchableMandate } from "../../typings/balancePlatform/models";

/**
* API handler for DirectDebitMandatesApi
*/
export class DirectDebitMandatesApi extends Service {

private readonly API_BASEPATH: string = "https://balanceplatform-api-test.adyen.com/bcl/v2";
private baseUrl: string;

public constructor(client: Client){
super(client);
this.baseUrl = this.createBaseUrl(this.API_BASEPATH);
}

/**
* @summary Cancel a mandate
* @param mandateId {@link string } The unique identifier of the mandate.
* @param requestOptions {@link IRequest.Options }
* @return {@link void }
*/
public async cancelMandate(mandateId: string, requestOptions?: IRequest.Options): Promise<void> {
const endpoint = `${this.baseUrl}/mandates/{mandateId}/cancel`
.replace("{" + "mandateId" + "}", encodeURIComponent(String(mandateId)));
const resource = new Resource(this, endpoint);

await getJsonResponse<string, void>(
resource,
"",
{ ...requestOptions, method: "POST" }
);
}

/**
* @summary Get a list of mandates
* @param requestOptions {@link IRequest.Options }
* @param balanceAccountId {@link string } The unique identifier of the balance account linked to the payment instrument.
* @param paymentInstrumentId {@link string } The unique identifier of the payment instrument linked to the mandate.
* @param cursor {@link string } The pagination cursor returned in a previous GET &#x60;/mandates&#x60; request.
* @return {@link ListMandatesResponse }
*/
public async getListOfMandates(balanceAccountId?: string, paymentInstrumentId?: string, cursor?: string, requestOptions?: IRequest.Options): Promise<ListMandatesResponse> {
const endpoint = `${this.baseUrl}/mandates`;
const resource = new Resource(this, endpoint);

const hasDefinedQueryParams = balanceAccountId ?? paymentInstrumentId ?? cursor;
if(hasDefinedQueryParams) {
if(!requestOptions) requestOptions = {};
if(!requestOptions.params) requestOptions.params = {};
if(balanceAccountId) requestOptions.params["balanceAccountId"] = balanceAccountId;
if(paymentInstrumentId) requestOptions.params["paymentInstrumentId"] = paymentInstrumentId;
if(cursor) requestOptions.params["cursor"] = cursor;
}
const response = await getJsonResponse<string, ListMandatesResponse>(
resource,
"",
{ ...requestOptions, method: "GET" }
);

return ObjectSerializer.deserialize(response, "ListMandatesResponse");
}

/**
* @summary Get a specific mandate
* @param mandateId {@link string } The unique identifier of the mandate.
* @param requestOptions {@link IRequest.Options }
* @return {@link Mandate }
*/
public async getMandateById(mandateId: string, requestOptions?: IRequest.Options): Promise<Mandate> {
const endpoint = `${this.baseUrl}/mandates/{mandateId}`
.replace("{" + "mandateId" + "}", encodeURIComponent(String(mandateId)));
const resource = new Resource(this, endpoint);

const response = await getJsonResponse<string, Mandate>(
resource,
"",
{ ...requestOptions, method: "GET" }
);

return ObjectSerializer.deserialize(response, "Mandate");
}

/**
* @summary Amend a mandate
* @param mandateId {@link string } The unique identifier of the mandate.
* @param patchableMandate {@link PatchableMandate }
* @param requestOptions {@link IRequest.Options }
* @return {@link void }
*/
public async updateMandate(mandateId: string, patchableMandate: PatchableMandate, requestOptions?: IRequest.Options): Promise<void> {
const endpoint = `${this.baseUrl}/mandates/{mandateId}`
.replace("{" + "mandateId" + "}", encodeURIComponent(String(mandateId)));
const resource = new Resource(this, endpoint);

const request: PatchableMandate = ObjectSerializer.serialize(patchableMandate, "PatchableMandate");
await getJsonResponse<PatchableMandate, void>(
resource,
request,
{ ...requestOptions, method: "PATCH" }
);
}

}
5 changes: 5 additions & 0 deletions src/services/balancePlatform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { BalanceAccountsApi } from "./balanceAccountsApi";
import { BalancesApi } from "./balancesApi";
import { BankAccountValidationApi } from "./bankAccountValidationApi";
import { CardOrdersApi } from "./cardOrdersApi";
import { DirectDebitMandatesApi } from "./directDebitMandatesApi";
import { GrantAccountsApi } from "./grantAccountsApi";
import { GrantOffersApi } from "./grantOffersApi";
import { ManageCardPINApi } from "./manageCardPINApi";
Expand Down Expand Up @@ -61,6 +62,10 @@ export default class BalancePlatformAPI extends Service {
return new CardOrdersApi(this.client);
}

public get DirectDebitMandatesApi() {
return new DirectDebitMandatesApi(this.client);
}

public get GrantAccountsApi() {
return new GrantAccountsApi(this.client);
}
Expand Down
20 changes: 10 additions & 10 deletions src/typings/balancePlatform/invalidField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@


export class InvalidField {
/**
* Description of the validation error.
*/
"message": string;
/**
* The field that has an invalid value.
*/
Expand All @@ -17,31 +21,27 @@ export class InvalidField {
* The invalid value.
*/
"value": string;
/**
* Description of the validation error.
*/
"message": string;

static readonly discriminator: string | undefined = undefined;

static readonly mapping: {[index: string]: string} | undefined = undefined;

static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "name",
"baseName": "name",
"name": "message",
"baseName": "message",
"type": "string",
"format": ""
},
{
"name": "value",
"baseName": "value",
"name": "name",
"baseName": "name",
"type": "string",
"format": ""
},
{
"name": "message",
"baseName": "message",
"name": "value",
"baseName": "value",
"type": "string",
"format": ""
} ];
Expand Down
46 changes: 46 additions & 0 deletions src/typings/balancePlatform/listMandatesResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* The version of the OpenAPI document: v2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit this class manually.
*/

import { Link } from "./link";
import { Mandate } from "./mandate";


export class ListMandatesResponse {
"link": Link;
/**
* Contains a list of the mandates.
*/
"mandates": Array<Mandate>;

static readonly discriminator: string | undefined = undefined;

static readonly mapping: {[index: string]: string} | undefined = undefined;

static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "link",
"baseName": "link",
"type": "Link",
"format": ""
},
{
"name": "mandates",
"baseName": "mandates",
"type": "Array<Mandate>",
"format": ""
} ];

static getAttributeTypeMap() {
return ListMandatesResponse.attributeTypeMap;
}

public constructor() {
}
}

103 changes: 103 additions & 0 deletions src/typings/balancePlatform/mandate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* The version of the OpenAPI document: v2
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit this class manually.
*/

import { MandateBankAccount } from "./mandateBankAccount";
import { MandateStatus } from "./mandateStatus";
import { MandateType } from "./mandateType";


export class Mandate {
/**
* The unique identifier of the balance account linked to the payment instrument.
*/
"balanceAccountId"?: string;
"counterparty"?: MandateBankAccount | null;
/**
* The date when the mandate was created.
*/
"createdAt"?: Date;
/**
* The unique identifier of the mandate.
*/
"id"?: string;
/**
* The unique identifier of the payment instrument linked to the mandate.
*/
"paymentInstrumentId"?: string;
"status"?: MandateStatus;
"type"?: MandateType;
/**
* The date when the mandate was updated.
*/
"updatedAt"?: Date;

static readonly discriminator: string | undefined = undefined;

static readonly mapping: {[index: string]: string} | undefined = undefined;

static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "balanceAccountId",
"baseName": "balanceAccountId",
"type": "string",
"format": ""
},
{
"name": "counterparty",
"baseName": "counterparty",
"type": "MandateBankAccount | null",
"format": ""
},
{
"name": "createdAt",
"baseName": "createdAt",
"type": "Date",
"format": "date-time"
},
{
"name": "id",
"baseName": "id",
"type": "string",
"format": ""
},
{
"name": "paymentInstrumentId",
"baseName": "paymentInstrumentId",
"type": "string",
"format": ""
},
{
"name": "status",
"baseName": "status",
"type": "MandateStatus",
"format": ""
},
{
"name": "type",
"baseName": "type",
"type": "MandateType",
"format": ""
},
{
"name": "updatedAt",
"baseName": "updatedAt",
"type": "Date",
"format": "date-time"
} ];

static getAttributeTypeMap() {
return Mandate.attributeTypeMap;
}

public constructor() {
}
}

export namespace Mandate {
}
Loading
Loading