Skip to content

Commit

Permalink
Merge 0792618 into e347851
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpaul committed Aug 9, 2022
2 parents e347851 + 0792618 commit aa8a58d
Show file tree
Hide file tree
Showing 82 changed files with 5,929 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const createClient = (apiKey = process.env.ADYEN_API_KEY): Client => {
config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_TEST;
config.terminalManagementEndpoint = Client.TERMINAL_MANAGEMENT_API_ENDPOINT_TEST;
config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_TEST;
config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_TEST;

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

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class Client {
public static TERMINAL_MANAGEMENT_API_ENDPOINT_LIVE = "https://postfmapi-live.adyen.com/postfmapi/terminal";
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 @@ -123,6 +126,7 @@ class Client {
this.config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_TEST;
this.config.terminalManagementEndpoint = Client.TERMINAL_MANAGEMENT_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 @@ -132,6 +136,7 @@ class Client {
this.config.storedValueEndpoint = Client.STOREDVALUE_API_ENDPOINT_LIVE;
this.config.terminalManagementEndpoint = Client.TERMINAL_MANAGEMENT_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
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface ConfigConstructor {
storedValueEndpoint?: string;
terminalManagementEndpoint?: string;
managementEndpoint?: string;
balancePlatformEndpoint?: string;
}

class Config {
Expand Down Expand Up @@ -66,6 +67,7 @@ class Config {
public storedValueEndpoint?: string;
public terminalManagementEndpoint?: string;
public managementEndpoint?: string;
public balancePlatformEndpoint?: string;

public constructor(options: ConfigConstructor = {}) {
if (options.username) this.username = options.username;
Expand All @@ -89,6 +91,7 @@ class Config {
if (options.storedValueEndpoint) this.storedValueEndpoint = options.storedValueEndpoint;
if (options.terminalManagementEndpoint) this.terminalManagementEndpoint = options.terminalManagementEndpoint;
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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,
"",
{ ...requestOptions, 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 aa8a58d

Please sign in to comment.