Skip to content

Commit

Permalink
Merge 10f7f7a into dd9eca1
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpaul committed Aug 3, 2022
2 parents dd9eca1 + 10f7f7a commit 057a17e
Show file tree
Hide file tree
Showing 81 changed files with 5,739 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Makefile
@@ -1,6 +1,6 @@
generator:=typescript-node
openapi-generator-cli:=docker run --user $(shell id -u):$(shell id -g) --rm -v ${PWD}:/local -w /local openapitools/openapi-generator-cli:v5.4.0
services:=checkout storedValue terminalManagement payments recurring payouts management platformsAccount platformsFund platformsNotificationConfiguration platformsHostedOnboardingPage
services:=checkout storedValue terminalManagement payments recurring payouts management balancePlatform platformsAccount platformsFund platformsNotificationConfiguration platformsHostedOnboardingPage

# Generate models (for each service)
models: $(services)
Expand All @@ -12,6 +12,7 @@ payments: spec=PaymentService-v68
recurring: spec=RecurringService-v68
payouts: spec=PayoutService-v68
management: spec=ManagementService-v1
balancePlatform: spec=BalancePlatformService-v2
platformsAccount: spec=AccountService-v6
platformsFund: spec=FundService-v6
platformsNotificationConfiguration: spec=NotificationConfigurationService-v6
Expand Down
1 change: 1 addition & 0 deletions src/__mocks__/base.ts
Expand Up @@ -47,6 +47,7 @@ export const createClient = (apiKey = process.env.ADYEN_API_KEY): Client => {
config.paymentEndpoint = Client.PAYMENT_API_ENDPOINT_TEST;
config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_TEST;
config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_TEST;
config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_TEST;

return new Client({ config });
};
Expand Down
759 changes: 759 additions & 0 deletions src/__tests__/balancePlatform.spec.ts

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/client.ts
Expand Up @@ -78,7 +78,9 @@ class Client {
public static STOREDVALUE_API_ENDPOINT_LIVE = "https://pal-live.adyen.com/pal/servlet/StoredValue";
public static MANAGEMENT_API_ENDPOINT_TEST = "https://management-test.adyen.com";
public static MANAGEMENT_API_ENDPOINT_LIVE = "https://management-live.adyen.com";

public static BALANCE_PLATFORM_API_VERSION = "v2";
public static BALANCE_PLATFORM_API_ENDPOINT_TEST = "https://balanceplatform-api-test.adyen.com/bcl";
public static BALANCE_PLATFORM_API_ENDPOINT_LIVE = "https://balanceplatform-api-live.adyen.com/bcl";

private _httpClient!: ClientInterface;
public config: Config;
Expand Down Expand Up @@ -120,6 +122,7 @@ class Client {
this.config.paymentEndpoint = Client.PAYMENT_API_ENDPOINT_TEST;
this.config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_TEST;
this.config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_TEST;
this.config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_TEST;
} else if (environment === "LIVE") {
this.config.endpoint = Client.ENDPOINT_LIVE;
this.config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_LIVE;
Expand All @@ -128,6 +131,7 @@ class Client {
this.config.paymentEndpoint = Client.PAYMENT_API_ENDPOINT_LIVE;
this.config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_LIVE;
this.config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_LIVE;
this.config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_LIVE;

if (liveEndpointUrlPrefix) {
this.config.endpoint =
Expand Down
4 changes: 3 additions & 1 deletion src/config.ts
Expand Up @@ -37,6 +37,7 @@ interface ConfigConstructor {
paymentEndpoint?: string;
storedValueEndpoint?: string;
managementEndpoint?: string;
balancePlatformEndpoint?: string;
}

class Config {
Expand Down Expand Up @@ -64,6 +65,7 @@ class Config {
public paymentEndpoint?: string;
public storedValueEndpoint?: string;
public managementEndpoint?: string;
public balancePlatformEndpoint?: string;

public constructor(options: ConfigConstructor = {}) {
if (options.username) this.username = options.username;
Expand All @@ -86,7 +88,7 @@ class Config {
if (options.paymentEndpoint) this.paymentEndpoint = options.paymentEndpoint;
if (options.storedValueEndpoint) this.storedValueEndpoint = options.storedValueEndpoint;
if (options.managementEndpoint) this.managementEndpoint = options.managementEndpoint;

if (options.balancePlatformEndpoint) this.balancePlatformEndpoint = options.balancePlatformEndpoint;
}

public set checkoutEndpoint(checkoutEndpoint: string | undefined) {
Expand Down
6 changes: 5 additions & 1 deletion src/httpClient/httpURLConnectionClient.ts
Expand Up @@ -22,7 +22,7 @@ import { Agent, AgentOptions, request as httpsRequest } from "https";
import { HttpsProxyAgent } from "https-proxy-agent";

import * as fs from "fs";
import { URL } from "url";
import { URL, URLSearchParams } from "url";
import Client from "../client";
import Config from "../config";
import HttpClientException from "./httpClientException";
Expand Down Expand Up @@ -87,6 +87,10 @@ class HttpURLConnectionClient implements ClientInterface {
requestOptions.port = url.port;
requestOptions.path = url.pathname;

if (requestOptions.params) {
requestOptions.path += '?' + new URLSearchParams(requestOptions.params).toString();
}

if (requestOptions && requestOptions.idempotencyKey) {
requestOptions.headers[ApiConstants.IDEMPOTENCY_KEY] = requestOptions.idempotencyKey;
delete requestOptions.idempotencyKey;
Expand Down
52 changes: 52 additions & 0 deletions src/services/balancePlaftform/accountHolders.ts
@@ -0,0 +1,52 @@
import getJsonResponse from "../../helpers/getJsonResponse";
import Service from "../../service";
import { AccountHolder, AccountHolderInfo, ObjectSerializer, PaginatedBalanceAccountsResponse } from "../../typings/balancePlatform/models";
import { IRequest } from "../../typings/requestOptions";
import BalancePlatformResource from "../resource/balancePlaftformResource";

// @TODO PW-7013: make this change at the spec level?
export type AccountHolderUpdate = Omit<AccountHolder, 'id'>;

class AccountHolders extends Service {
public async create(request: AccountHolderInfo): Promise<AccountHolder> {
const resource = new BalancePlatformResource(this, `/accountHolders`);
const response = await getJsonResponse<AccountHolderInfo, AccountHolder>(
resource,
request,
{ method: "POST" }
);
return ObjectSerializer.deserialize(response, "AccountHolder");
}

public async retrieve(id: string): Promise<AccountHolder> {
const resource = new BalancePlatformResource(this, `/accountHolders/${id}`);
const response = await getJsonResponse<string, AccountHolder>(
resource,
'',
{ method: "GET" }
);
return ObjectSerializer.deserialize(response, "AccountHolder");
}

public async update(id: string, request: AccountHolderUpdate): Promise<AccountHolder> {
const resource = new BalancePlatformResource(this, `/accountHolders/${id}`);
const response = await getJsonResponse<AccountHolderUpdate, AccountHolder>(
resource,
request,
{ method: "PATCH" }
);
return ObjectSerializer.deserialize(response, "AccountHolder");
}

public async listBalanceAccounts(id: string, requestOptions?: IRequest.Options): Promise<PaginatedBalanceAccountsResponse> {
const resource = new BalancePlatformResource(this, `/accountHolders/${id}/balanceAccounts`);
const response = await getJsonResponse<string, PaginatedBalanceAccountsResponse>(
resource,
'',
{ ...requestOptions, method: "GET" }
);
return ObjectSerializer.deserialize(response, "PaginatedBalanceAccountsResponse");
}
}

export default AccountHolders;
103 changes: 103 additions & 0 deletions src/services/balancePlaftform/balanceAccounts.ts
@@ -0,0 +1,103 @@
import getJsonResponse from "../../helpers/getJsonResponse";
import Service from "../../service";
import { BalanceAccount, BalanceAccountInfo, BalanceAccountUpdateRequest, BalanceSweepConfigurationsResponse, ObjectSerializer, PaginatedPaymentInstrumentsResponse, SweepConfigurationV2 } from "../../typings/balancePlatform/models";
import { IRequest } from "../../typings/requestOptions";
import BalancePlatformResource from "../resource/balancePlaftformResource";

// @TODO PW-7013: make this change at the spec level?
export type SweepConfigurationV2Create = Omit<SweepConfigurationV2, 'id'>;
export type SweepConfigurationV2Update = Partial<SweepConfigurationV2>;

class BalanceAccounts extends Service {
public async create(request: BalanceAccountInfo): Promise<BalanceAccount> {
const resource = new BalancePlatformResource(this, `/balanceAccounts`);
const response = await getJsonResponse<BalanceAccountInfo, BalanceAccount>(
resource,
request,
{ method: "POST" }
);
return ObjectSerializer.deserialize(response, "BalanceAccount");
}

public async listSweeps(balanceAccountId: string, requestOptions?: IRequest.Options): Promise<BalanceSweepConfigurationsResponse> {
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps`);
const response = await getJsonResponse<string, BalanceSweepConfigurationsResponse>(
resource,
'',
{ method: "GET" }
);
return ObjectSerializer.deserialize(response, "BalanceSweepConfigurationsResponse");
}

public async createSweep(balanceAccountId: string, request: SweepConfigurationV2Create): Promise<SweepConfigurationV2> {
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps`);
const response = await getJsonResponse<SweepConfigurationV2Create, SweepConfigurationV2>(
resource,
request,
{ method: "POST" }
);
return ObjectSerializer.deserialize(response, "SweepConfigurationV2");
}

public async deleteSweep(balanceAccountId: string, sweepId: string): Promise<void> {
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`);
await getJsonResponse<string, string>(
resource,
'',
{ method: "DELETE" }
);
}

public async retrieveSweep(balanceAccountId: string, sweepId: string): Promise<SweepConfigurationV2> {
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`);
const response = await getJsonResponse<string, SweepConfigurationV2>(
resource,
'',
{ method: "GET" }
);
return ObjectSerializer.deserialize(response, "SweepConfigurationV2");
}

public async updateSweep(balanceAccountId: string, sweepId: string, request: SweepConfigurationV2Update): Promise<SweepConfigurationV2> {
const resource = new BalancePlatformResource(this, `/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`);
const response = await getJsonResponse<SweepConfigurationV2Update, SweepConfigurationV2>(
resource,
request,
{ method: "PATCH" }
);
return ObjectSerializer.deserialize(response, "SweepConfigurationV2");
}

public async retrieve(id: string): Promise<BalanceAccount> {
const resource = new BalancePlatformResource(this, `/balanceAccounts/${id}`);
const response = await getJsonResponse<string, BalanceAccount>(
resource,
'',
{ method: "GET" }
);
return ObjectSerializer.deserialize(response, "BalanceAccount");
}

public async update(id: string, request: BalanceAccountUpdateRequest): Promise<BalanceAccount> {
const resource = new BalancePlatformResource(this, `/balanceAccounts/${id}`);
const response = await getJsonResponse<BalanceAccountUpdateRequest, BalanceAccount>(
resource,
request,
{ method: "PATCH" }
);
return ObjectSerializer.deserialize(response, "BalanceAccount");
}

public async listPaymentInstruments(id: string, requestOptions?: IRequest.Options): Promise<PaginatedPaymentInstrumentsResponse> {
const resource = new BalancePlatformResource(this, `/balanceAccounts/${id}/paymentInstruments`);
const response = await getJsonResponse<string, PaginatedPaymentInstrumentsResponse>(
resource,
'',
{ ...requestOptions, method: "GET" }
);
return ObjectSerializer.deserialize(response, "PaginatedPaymentInstrumentsResponse");
}

}

export default BalanceAccounts;
29 changes: 29 additions & 0 deletions src/services/balancePlaftform/general.ts
@@ -0,0 +1,29 @@
import getJsonResponse from "../../helpers/getJsonResponse";
import Service from "../../service";
import { BalancePlatform, ObjectSerializer, PaginatedAccountHoldersResponse } from "../../typings/balancePlatform/models";
import { IRequest } from "../../typings/requestOptions";
import BalancePlatformResource from "../resource/balancePlaftformResource";

class General extends Service {
public async retrieve(id: string): Promise<BalancePlatform> {
const resource = new BalancePlatformResource(this, `/balancePlatforms/${id}`);
const response = await getJsonResponse<string, BalancePlatform>(
resource,
'',
{ method: "GET" }
);
return ObjectSerializer.deserialize(response, "BalancePlatform");
}

public async listAccountHolders(id: string, requestOptions?: IRequest.Options): Promise<PaginatedAccountHoldersResponse> {
const resource = new BalancePlatformResource(this, `/balancePlatforms/${id}/accountHolders`);
const response = await getJsonResponse<string, PaginatedAccountHoldersResponse>(
resource,
'',
{ ...requestOptions, method: "GET" }
);
return ObjectSerializer.deserialize(response, "PaginatedAccountHoldersResponse");
}
}

export default General;
39 changes: 39 additions & 0 deletions src/services/balancePlaftform/paymentInstrumentGroups.ts
@@ -0,0 +1,39 @@
import getJsonResponse from "../../helpers/getJsonResponse";
import Service from "../../service";
import { ObjectSerializer, PaymentInstrumentGroup, PaymentInstrumentGroupInfo, TransactionRulesResponse } from "../../typings/balancePlatform/models";
import BalancePlatformResource from "../resource/balancePlaftformResource";

class PaymentInstrumentGroups extends Service {
public async create(request: PaymentInstrumentGroupInfo): Promise<PaymentInstrumentGroup> {
const resource = new BalancePlatformResource(this, `/paymentInstrumentGroups`);
const response = await getJsonResponse<PaymentInstrumentGroupInfo, PaymentInstrumentGroup>(
resource,
request,
{ method: "POST" }
);
return ObjectSerializer.deserialize(response, "PaymentInstrumentGroup");
}

public async retrieve(id: string): Promise<PaymentInstrumentGroup> {
const resource = new BalancePlatformResource(this, `/paymentInstrumentGroups/${id}`);
const response = await getJsonResponse<string, PaymentInstrumentGroup>(
resource,
"",
{ method: "GET" }
);
return ObjectSerializer.deserialize(response, "PaymentInstrumentGroup");
}

public async listTransactionRules(id: string): Promise<TransactionRulesResponse> {
const resource = new BalancePlatformResource(this, `/paymentInstrumentGroups/${id}/transactionRules`);
const response = await getJsonResponse<string, TransactionRulesResponse>(
resource,
"",
{ method: "GET" }
);
return ObjectSerializer.deserialize(response, "TransactionRulesResponse");
}
}

export default PaymentInstrumentGroups;

48 changes: 48 additions & 0 deletions src/services/balancePlaftform/paymentInstruments.ts
@@ -0,0 +1,48 @@
import getJsonResponse from "../../helpers/getJsonResponse";
import Service from "../../service";
import { ObjectSerializer, PaymentInstrument, PaymentInstrumentInfo, PaymentInstrumentUpdateRequest, TransactionRulesResponse } from "../../typings/balancePlatform/models";
import BalancePlatformResource from "../resource/balancePlaftformResource";

class PaymentInstruments extends Service {
public async create(request: PaymentInstrumentInfo): Promise<PaymentInstrument> {
const resource = new BalancePlatformResource(this, `/paymentInstruments`);
const response = await getJsonResponse<PaymentInstrumentInfo, PaymentInstrument>(
resource,
request,
{ method: "POST" }
);
return ObjectSerializer.deserialize(response, "PaymentInstrument");
}

public async retrieve(id: string): Promise<PaymentInstrument> {
const resource = new BalancePlatformResource(this, `/paymentInstruments/${id}`);
const response = await getJsonResponse<string, PaymentInstrument>(
resource,
'',
{ method: "GET" }
);
return ObjectSerializer.deserialize(response, "PaymentInstrument");
}

public async update(id: string, request: PaymentInstrumentUpdateRequest): Promise<PaymentInstrument> {
const resource = new BalancePlatformResource(this, `/paymentInstruments/${id}`);
const response = await getJsonResponse<PaymentInstrumentUpdateRequest, PaymentInstrument>(
resource,
request,
{ method: "PATCH" }
);
return ObjectSerializer.deserialize(response, "PaymentInstrument");
}

public async listTransactionRules(id: string): Promise<TransactionRulesResponse> {
const resource = new BalancePlatformResource(this, `/paymentInstruments/${id}/transactionRules`);
const response = await getJsonResponse<string, TransactionRulesResponse>(
resource,
'',
{ method: "GET" }
);
return ObjectSerializer.deserialize(response, "TransactionRulesResponse");
}
}

export default PaymentInstruments;

0 comments on commit 057a17e

Please sign in to comment.