From b61624b392a52532f9180b5ed511dfd0e032f501 Mon Sep 17 00:00:00 2001 From: wouterboe Date: Tue, 20 Apr 2021 13:23:17 +0200 Subject: [PATCH 1/2] overwritten develop with current master source --- src/__tests__/binLookup.spec.ts | 8 +- src/__tests__/checkout.spec.ts | 34 +-- src/__tests__/httpClient.spec.ts | 2 +- src/__tests__/payout.spec.ts | 38 +-- src/__tests__/platforms.spec.ts | 64 ++--- src/__tests__/recurring.spec.ts | 8 +- src/helpers/getJsonResponse.ts | 10 +- src/httpClient/clientInterface.ts | 1 + src/httpClient/httpURLConnectionClient.ts | 14 +- src/services/binLookup.ts | 23 +- src/services/checkout.ts | 135 +++++++++- src/services/index.ts | 2 +- src/services/modification.ts | 96 ++++++- src/services/payout.ts | 91 +++++++ src/services/payouts.ts | 48 ---- src/services/platforms.ts | 245 +++++++++--------- src/services/recurring.ts | 34 ++- src/services/resource.ts | 9 +- .../resource/binLookup/get3dsAvailability.ts | 8 - .../resource/binLookup/getCostEstimate.ts | 8 - src/services/resource/checkout/orders.ts | 14 - .../resource/checkout/ordersCancel.ts | 8 - src/services/resource/checkout/originKeys.ts | 9 - .../resource/checkout/paymentLinks.ts | 26 -- .../resource/checkout/paymentLinksId.ts | 40 +++ .../resource/checkout/paymentMethods.ts | 14 - .../checkout/paymentMethodsBalance.ts | 9 - .../resource/checkout/paymentSession.ts | 13 - src/services/resource/checkout/payments.ts | 19 -- .../resource/checkout/paymentsDetails.ts | 11 - .../resource/checkout/paymentsResult.ts | 9 - .../modification/adjustAuthorisation.ts | 15 -- src/services/resource/modification/cancel.ts | 15 -- .../resource/modification/cancelOrRefund.ts | 16 -- src/services/resource/modification/capture.ts | 15 -- src/services/resource/modification/refund.ts | 15 -- .../resource/modification/technicalCancel.ts | 15 -- .../resource/payout/confirmThirdParty.ts | 8 - .../resource/payout/declineThirdParty.ts | 8 - src/services/resource/payout/payout.ts | 8 - src/services/resource/payout/storeDetail.ts | 9 - .../payout/storeDetailAndSubmitThirdParty.ts | 9 - .../resource/payout/submitThirdParty.ts | 8 - src/services/resource/recurring/disable.ts | 9 - .../recurring/listRecurringDetails.ts | 9 - .../recurring/scheduleAccountUpdater.ts | 8 - src/services/terminalCloudAPI.ts | 4 +- src/services/terminalLocalAPI.ts | 2 +- src/typings/HTTPMethod.ts | 53 ---- src/typings/genericRequest.ts | 4 - src/typings/requestOptions.ts | 1 - 51 files changed, 606 insertions(+), 675 deletions(-) create mode 100644 src/services/payout.ts delete mode 100644 src/services/payouts.ts create mode 100644 src/services/resource/checkout/paymentLinksId.ts delete mode 100644 src/typings/HTTPMethod.ts delete mode 100644 src/typings/genericRequest.ts diff --git a/src/__tests__/binLookup.spec.ts b/src/__tests__/binLookup.spec.ts index 5d10245..190e0fd 100644 --- a/src/__tests__/binLookup.spec.ts +++ b/src/__tests__/binLookup.spec.ts @@ -60,7 +60,7 @@ describe("Bin Lookup", function (): void { scope.post("/get3dsAvailability") .reply(200, threeDSAvailabilitySuccess); - const response = await binLookup.get3dsAvailability.post(threeDSAvailabilityRequest); + const response = await binLookup.get3dsAvailability(threeDSAvailabilityRequest); expect(response).toEqual(threeDSAvailabilitySuccess); }); @@ -77,7 +77,7 @@ describe("Bin Lookup", function (): void { .reply(403, JSON.stringify({status: 403, message: "fail", errorCode: "171"})); try { - await binLookup.get3dsAvailability.post(threeDSAvailabilityRequest as unknown as IBinLookup.ThreeDSAvailabilityRequest); + await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as IBinLookup.ThreeDSAvailabilityRequest); fail("Expected request to fail"); } catch (e) { expect(e instanceof HttpClientException).toBeTruthy(); @@ -113,8 +113,8 @@ describe("Bin Lookup", function (): void { scope.post("/getCostEstimate") .reply(200, expected); - const response = await binLookup.getCostEstimate.post(costEstimateRequest); + const response = await binLookup.getCostEstimate(costEstimateRequest); expect(response).toEqual(expected); }); -}); +}); \ No newline at end of file diff --git a/src/__tests__/checkout.spec.ts b/src/__tests__/checkout.spec.ts index e5bf7ea..c4c7960 100644 --- a/src/__tests__/checkout.spec.ts +++ b/src/__tests__/checkout.spec.ts @@ -148,7 +148,7 @@ describe("Checkout", (): void => { .reply(200, paymentsSuccess); const paymentsRequest: ICheckout.PaymentRequest = createPaymentsCheckoutRequest(); - const paymentsResponse: ICheckout.PaymentResponse = await checkout.payments.post(paymentsRequest); + const paymentsResponse: ICheckout.PaymentResponse = await checkout.payments(paymentsRequest); expect(paymentsResponse.pspReference).toBeTruthy(); }); @@ -159,7 +159,7 @@ describe("Checkout", (): void => { .reply(401); const paymentsRequest: ICheckout.PaymentRequest = createPaymentsCheckoutRequest(); - await checkout.payments.post(paymentsRequest); + await checkout.payments(paymentsRequest); } catch (e) { expect(e instanceof HttpClientException).toBeTruthy(); } @@ -172,7 +172,7 @@ describe("Checkout", (): void => { scope.post("/paymentMethods") .reply(200, paymentMethodsSuccess); - const paymentMethodsResponse = await checkout.paymentMethods.post(paymentMethodsRequest); + const paymentMethodsResponse = await checkout.paymentMethods(paymentMethodsRequest); if (paymentMethodsResponse && paymentMethodsResponse.paymentMethods) { expect(paymentMethodsResponse.paymentMethods.length).toBeGreaterThan(0); } else { @@ -187,7 +187,7 @@ describe("Checkout", (): void => { scope.post("/paymentLinks").reply(200, paymentLinkSuccess); - const paymentSuccessLinkResponse = await checkout.paymentLinks.post(createPaymentLinkRequest()); + const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest()); expect(paymentSuccessLinkResponse).toBeTruthy(); }); @@ -198,10 +198,10 @@ describe("Checkout", (): void => { scope.post("/paymentLinks").reply(200, paymentLinkSuccess); - const paymentSuccessLinkResponse = await checkout.paymentLinks.post(createPaymentLinkRequest()); + const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest()); scope.get(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, paymentLinkSuccess); - const paymentLink = await checkout.paymentLinks.get({ id: paymentSuccessLinkResponse.id }); + const paymentLink = await checkout.getPaymentLinks(paymentSuccessLinkResponse.id); expect(paymentLink).toBeTruthy(); }); @@ -212,10 +212,10 @@ describe("Checkout", (): void => { scope.post("/paymentLinks").reply(200, paymentLinkSuccess); - const paymentSuccessLinkResponse = await checkout.paymentLinks.post(createPaymentLinkRequest()); + const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest()); scope.patch(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, { ...paymentLinkSuccess, status: "expired" }); - const paymentLink = await checkout.paymentLinks.patch({ id: paymentSuccessLinkResponse.id, status: "expired" }); + const paymentLink = await checkout.updatePaymentLinks(paymentSuccessLinkResponse.id, "expired"); expect(paymentLink.status).toEqual("expired"); }); @@ -224,7 +224,7 @@ describe("Checkout", (): void => { scope.post("/payments/details") .reply(200, paymentDetailsSuccess); - const paymentsResponse = await checkout.payments.details.post(createPaymentsDetailsRequest()); + const paymentsResponse = await checkout.paymentsDetails(createPaymentsDetailsRequest()); expect(paymentsResponse.resultCode).toEqual("Authorised"); }); @@ -233,7 +233,7 @@ describe("Checkout", (): void => { scope.post("/paymentSession") .reply(200, paymentSessionSuccess); const paymentSessionRequest: ICheckout.PaymentSetupRequest = createPaymentSessionRequest(); - const paymentSessionResponse = await checkout.paymentSession.post(paymentSessionRequest); + const paymentSessionResponse = await checkout.paymentSession(paymentSessionRequest); expect(paymentSessionResponse.paymentSession).not.toBeUndefined(); }); @@ -244,7 +244,7 @@ describe("Checkout", (): void => { const paymentResultRequest: ICheckout.PaymentVerificationRequest = { payload: "This is a test payload", }; - const paymentResultResponse = await checkout.payments.result.post(paymentResultRequest); + const paymentResultResponse = await checkout.paymentResult(paymentResultRequest); expect(paymentResultResponse.resultCode).toEqual("Authorised"); }); @@ -266,7 +266,7 @@ describe("Checkout", (): void => { .reply(200, paymentsResultMultibancoSuccess); const paymentsRequest: ICheckout.PaymentRequest = createPaymentsCheckoutRequest(); - const paymentsResponse: ICheckout.PaymentResponse = await checkout.payments.post(paymentsRequest); + const paymentsResponse: ICheckout.PaymentResponse = await checkout.payments(paymentsRequest); expect(paymentsResponse.pspReference).toBeTruthy(); expect(paymentsResponse.additionalData).toBeTruthy(); @@ -283,7 +283,7 @@ describe("Checkout", (): void => { .post(`/${Client.CHECKOUT_API_VERSION}/originKeys`) .reply(200, originKeysSuccess); - const originKeysResponse = await checkoutUtility.originKeys.post(originKeysRequest); + const originKeysResponse = await checkoutUtility.originKeys(originKeysRequest); if (originKeysResponse.originKeys) { return expect(originKeysResponse.originKeys["https://www.your-domain.com"].startsWith("pub.v2")).toBeTruthy(); } @@ -304,7 +304,7 @@ describe("Checkout", (): void => { scope.post("/paymentMethods/balance") .reply(200, paymentMethodsBalanceResponse); - const paymentsResponse: ICheckout.CheckoutBalanceCheckResponse = await checkout.paymentMethods.balance.post(paymentMethodsRequest); + const paymentsResponse: ICheckout.CheckoutBalanceCheckResponse = await checkout.paymentMethodsBalance(paymentMethodsRequest); expect(paymentsResponse.balance.value).toEqual(1000); }); @@ -321,7 +321,7 @@ describe("Checkout", (): void => { scope.post("/orders") .reply(200, orderResponse); - const response: ICheckout.CheckoutCreateOrderResponse = await checkout.orders.post(orderRequest); + const response: ICheckout.CheckoutCreateOrderResponse = await checkout.orders(orderRequest); expect(response).toBeTruthy(); }); @@ -338,7 +338,7 @@ describe("Checkout", (): void => { scope.post("/orders") .reply(200, orderResponse); - const createOrderResponse: ICheckout.CheckoutCreateOrderResponse = await checkout.orders.post(orderRequest); + const createOrderResponse: ICheckout.CheckoutCreateOrderResponse = await checkout.orders(orderRequest); const orderCancelResponse: ICheckout.CheckoutCancelOrderResponse = { pspReference: "mocked_psp_ref", @@ -347,7 +347,7 @@ describe("Checkout", (): void => { scope.post("/orders/cancel") .reply(200, orderCancelResponse); - const response: ICheckout.CheckoutCancelOrderResponse = await checkout.orders.cancel.post({ + const response: ICheckout.CheckoutCancelOrderResponse = await checkout.ordersCancel({ order: { orderData: createOrderResponse.orderData, pspReference: createOrderResponse.pspReference! diff --git a/src/__tests__/httpClient.spec.ts b/src/__tests__/httpClient.spec.ts index fb8f231..c399272 100644 --- a/src/__tests__/httpClient.spec.ts +++ b/src/__tests__/httpClient.spec.ts @@ -41,7 +41,7 @@ const getResponse = async ({apiKey , environment }: { apiKey: string; environmen const ErrorException = errorType === "ApiException" ? ApiException : HttpClientException; try { - await checkout.payments.post(createPaymentsCheckoutRequest()); + await checkout.payments(createPaymentsCheckoutRequest()); fail("request should fail"); } catch (e) { expect(e instanceof ErrorException).toBeTruthy(); diff --git a/src/__tests__/payout.spec.ts b/src/__tests__/payout.spec.ts index 3a59a7f..072fbba 100644 --- a/src/__tests__/payout.spec.ts +++ b/src/__tests__/payout.spec.ts @@ -19,7 +19,7 @@ import nock from "nock"; import { createClient } from "../__mocks__/base"; -import Payouts from "../services/payouts"; +import Payout from "../services/payout"; import Client from "../client"; import StoreDetailRequest = IPayouts.StoreDetailRequest; import { ApiConstants } from "../constants/apiConstants"; @@ -102,7 +102,7 @@ const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT! let client: Client; let clientStore: Client; let clientReview: Client; -let payouts: Payouts; +let payout: Payout; let scope: nock.Scope; beforeEach((): void => { @@ -113,7 +113,7 @@ beforeEach((): void => { clientStore = createClient(process.env.ADYEN_STOREPAYOUT_APIKEY); clientReview = createClient(process.env.ADYEN_REVIEWPAYOUT_APIKEY); scope = nock(`${client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}`); - payouts = new Payouts(client); + payout = new Payout(client); }); afterEach((): void => { @@ -123,21 +123,21 @@ afterEach((): void => { describe("PayoutTest", function (): void { test.each([isCI, true])("should succeed on store detail and submit third party, isMock: %p", async function (isMock): Promise { !isMock && nock.restore(); - payouts = new Payouts(clientStore); + payout = new Payout(clientStore); const request: IPayouts.StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest(); scope.post("/storeDetailAndSubmitThirdParty").reply(200, storeDetailAndSubmitThirdParty); - const result = await payouts.storeDetailAndSubmitThirdParty.post(request); + const result = await payout.storeDetailAndSubmitThirdParty(request); expect(result.resultCode).toEqual("[payout-submit-received]"); expect(result.pspReference).toBeTruthy(); }); test.each([false, true])("should succeed on store detail, isMock: %p", async function (isMock): Promise { !isMock && nock.restore(); - payouts = new Payouts(clientStore); + payout = new Payout(clientStore); scope.post("/storeDetail").reply(200, storeDetail); const request: StoreDetailRequest = mockStoreDetailRequest(); - const result = await payouts.storeDetail.post(request); + const result = await payout.storeDetail(request); expect("Success").toEqual(result.resultCode); expect(result.pspReference).toBeTruthy(); @@ -146,12 +146,12 @@ describe("PayoutTest", function (): void { test.each([isCI, true])("should succeed on confirm third party, isMock: %p", async function (isMock): Promise { !isMock && nock.restore(); - payouts = new Payouts(clientStore); + payout = new Payout(clientStore); scope.post("/storeDetail").reply(200, storeDetail); const storeRequest: StoreDetailRequest = mockStoreDetailRequest(); - const storeResult = await payouts.storeDetail.post(storeRequest); + const storeResult = await payout.storeDetail(storeRequest); - payouts = new Payouts(clientReview); + payout = new Payout(clientReview); scope.post("/confirmThirdParty") .reply(200, { pspReference: "8815131762537886", @@ -162,7 +162,7 @@ describe("PayoutTest", function (): void { merchantAccount: process.env.ADYEN_MERCHANT!, originalReference: storeResult.pspReference }; - const result = await payouts.confirmThirdParty.post(request); + const result = await payout.confirmThirdParty(request); expect(result.response).toEqual("[payout-confirm-received]"); expect(result.pspReference).toBeTruthy(); @@ -170,11 +170,11 @@ describe("PayoutTest", function (): void { test.each([isCI, true])("should succeed on submit third party, isMock: %p", async function (isMock): Promise { !isMock && nock.restore(); - payouts = new Payouts(clientStore); + payout = new Payout(clientStore); scope.post("/submitThirdParty").reply(200, storeDetailAndSubmitThirdParty); const request: IPayouts.SubmitRequest = mockSubmitRequest(); - const result = await payouts.submitThirdParty.post(request); + const result = await payout.submitThirdparty(request); expect(result.resultCode).toEqual("[payout-submit-received]"); expect(result.pspReference).toBeTruthy(); @@ -187,12 +187,12 @@ describe("PayoutTest", function (): void { test.each([false, true])("should succeed on decline third party, isMock: %p", async function (isMock): Promise { !isMock && nock.restore(); - payouts = new Payouts(clientStore); + payout = new Payout(clientStore); scope.post("/storeDetail").reply(200, storeDetail); const storeRequest: StoreDetailRequest = mockStoreDetailRequest(); - const storeResult = await payouts.storeDetail.post(storeRequest); + const storeResult = await payout.storeDetail(storeRequest); - payouts = new Payouts(clientReview); + payout = new Payout(clientReview); const request: IPayouts.ModifyRequest = { merchantAccount: process.env.ADYEN_MERCHANT!, originalReference: storeResult.pspReference @@ -202,7 +202,7 @@ describe("PayoutTest", function (): void { pspReference: "8815131762537886", response: "[payout-decline-received]" }); - const result = await payouts.declineThirdParty.post(request); + const result = await payout.declineThirdParty(request); expect(result.response).toEqual("[payout-decline-received]"); expect(result.pspReference).toBeTruthy(); @@ -216,9 +216,9 @@ describe("PayoutTest", function (): void { }); const request = mockPayoutRequest(); - const result = await payouts.payout.post(request); + const result = await payout.payout(request); expect(result.resultCode).toEqual("Received"); expect(result.pspReference).toBeTruthy(); }); -}); +}); \ No newline at end of file diff --git a/src/__tests__/platforms.spec.ts b/src/__tests__/platforms.spec.ts index 7978c39..c88b23b 100644 --- a/src/__tests__/platforms.spec.ts +++ b/src/__tests__/platforms.spec.ts @@ -121,7 +121,7 @@ describe("Platforms Test", function () { async (...args) => { const service = platforms.Account; scope.post(`/Account/${Client.MARKETPAY_ACCOUNT_API_VERSION}//${args[0]}`).reply(200, args[2]); - const result = await service[args[0] as string].post(args[1] as never); + const result = await service[args[0] as string](args[1] as never); expect(result).toMatchObject(args[2]); } ); @@ -144,7 +144,7 @@ describe("Platforms Test", function () { const fund = platforms.Fund; scope.post(`/Fund/${Client.MARKETPAY_FUND_API_VERSION}//${args[0]}`).reply(200, args[2]); - const result = await fund[args[0] as string].post(args[1] as never); + const result = await fund[args[0] as string](args[1] as never); expect(result).toMatchObject(args[2]); } ); @@ -166,7 +166,7 @@ describe("Platforms Test", function () { const notificationConfiguration = platforms.NotificationConfiguration; scope.post(`/Notification/${Client.MARKETPAY_NOTIFICATION_CONFIGURATION_API_VERSION}//${args[0]}`).reply(200, args[2]); - const result = await notificationConfiguration[args[0] as string].post(args[1] as never); + const result = await notificationConfiguration[args[0] as string](args[1] as never); expect(result).toMatchObject(args[2]); } ); @@ -182,7 +182,7 @@ describe("Platforms Test", function () { const hostedOnboardingPage = platforms.HostedOnboardingPage; scope.post(`/Hop/${Client.MARKETPAY_HOP_API_VERSION}//${args[0]}`).reply(200, args[2]); - const result = await hostedOnboardingPage[args[0] as string].post(args[1] as never); + const result = await hostedOnboardingPage[args[0] as string](args[1] as never); expect(result).toMatchObject(args[2]); } ); @@ -191,46 +191,46 @@ describe("Platforms Test", function () { describe.skip("Platforms Test E2E", function(): void { beforeAll(async (done) => { - accountHolder = await platforms.Account.createAccountHolder.post({ + accountHolder = await platforms.Account.createAccountHolder({ accountHolderCode: generateRandomCode(), accountHolderDetails, legalEntity: "Individual", }); - account = await platforms.Account.createAccount.post({ + account = await platforms.Account.createAccount({ accountHolderCode: generateRandomCode(), description: "This is a new account", metadata: {meta: "data"}, payoutSchedule: "WEEKLY" }); - accountHolderToSuspend = await platforms.Account.createAccountHolder.post({ + accountHolderToSuspend = await platforms.Account.createAccountHolder({ accountHolderCode: generateRandomCode(), accountHolderDetails, legalEntity: "Individual" }); - accountToClose = await platforms.Account.createAccount.post({ + accountToClose = await platforms.Account.createAccount({ accountHolderCode: generateRandomCode(), description: "This is a new account", metadata: {meta: "data"}, payoutSchedule: "WEEKLY" }); - accountHolderToUnSuspend = await platforms.Account.createAccountHolder.post({ + accountHolderToUnSuspend = await platforms.Account.createAccountHolder({ accountHolderCode: generateRandomCode(), accountHolderDetails, legalEntity: "Individual" }); - await platforms.Account.suspendAccountHolder.post({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode}); + await platforms.Account.suspendAccountHolder({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode}); - accountHolderToClose = await platforms.Account.createAccountHolder.post({ + accountHolderToClose = await platforms.Account.createAccountHolder({ accountHolderCode: generateRandomCode(), accountHolderDetails, legalEntity: "Individual" }); - notificationConfigurationToRetrieve = await platforms.NotificationConfiguration.createNotificationConfiguration.post({ + notificationConfigurationToRetrieve = await platforms.NotificationConfiguration.createNotificationConfiguration({ configurationDetails: { ...notificationConfigurationDetails, description: `${generateRandomCode()}` @@ -252,7 +252,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should get account holder", async function() { nock.restore(); try { - const result = await platforms.Account.getAccountHolder.post({ + const result = await platforms.Account.getAccountHolder({ accountHolderCode: accountHolder.accountHolderCode, }); expect(result.accountHolderDetails.email).toEqual("random_email@example.com"); @@ -264,7 +264,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should update account holder", async function() { nock.restore(); try { - const result = await platforms.Account.updateAccountHolder.post({ + const result = await platforms.Account.updateAccountHolder({ accountHolderCode: accountHolder.accountHolderCode, accountHolderDetails: { ...accountHolderDetails, @@ -282,7 +282,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should check account holder", async function() { nock.restore(); try { - const result = await platforms.Account.checkAccountHolder.post({ + const result = await platforms.Account.checkAccountHolder({ accountHolderCode: accountHolder.accountHolderCode, accountStateType: "Processing", tier: 2 @@ -305,7 +305,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should upload verification document", async function() { nock.restore(); try { - const result = await platforms.Account.uploadDocument.post({ + const result = await platforms.Account.uploadDocument({ documentContent, documentDetail: { accountHolderCode: account.accountHolderCode, @@ -323,7 +323,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should get uploaded verification documents", async function() { nock.restore(); try { - await platforms.Account.uploadDocument.post({ + await platforms.Account.uploadDocument({ documentContent, documentDetail: { accountHolderCode: account.accountHolderCode, @@ -332,7 +332,7 @@ describe.skip("Platforms Test E2E", function(): void { filename: "IDCardFront.png" } }); - const result = await platforms.Account.getUploadedDocuments.post({ + const result = await platforms.Account.getUploadedDocuments({ accountHolderCode: account.accountHolderCode, }); expect(result.documentDetails![0].filename).toEqual("IDCardFront.png"); @@ -344,7 +344,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should close account", async function() { nock.restore(); try { - const result = await platforms.Account.closeAccount.post({ + const result = await platforms.Account.closeAccount({ accountCode: accountToClose.accountCode }); expect(result.status).toEqual("Closed"); @@ -356,7 +356,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should suspend account holder", async function() { nock.restore(); try { - const result = await platforms.Account.suspendAccountHolder.post({ + const result = await platforms.Account.suspendAccountHolder({ accountHolderCode: accountHolderToSuspend.accountHolderCode, }); expect(result.pspReference).toBeDefined(); @@ -368,7 +368,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should unsuspend account holder", async function() { nock.restore(); try { - const result = await platforms.Account.unSuspendAccountHolder.post({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode }); + const result = await platforms.Account.unSuspendAccountHolder({ accountHolderCode: accountHolderToUnSuspend.accountHolderCode }); expect(result.pspReference).toBeDefined(); } catch (e) { assertError(e); @@ -378,7 +378,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should update account holder state", async function() { nock.restore(); try { - const result = await platforms.Account.updateAccountHolderState.post({ + const result = await platforms.Account.updateAccountHolderState({ accountHolderCode: accountHolder.accountHolderCode, disable: false, stateType: "Payout" @@ -392,7 +392,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should close account holder", async function() { nock.restore(); try { - const result = await platforms.Account.closeAccountHolder.post({ + const result = await platforms.Account.closeAccountHolder({ accountHolderCode: accountHolderToClose.accountHolderCode }); expect(result.pspReference).toBeDefined(); @@ -408,7 +408,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should retrieve the balance of an account holder", async function() { nock.restore(); try { - const result = await platforms.Fund.accountHolderBalance.post({ + const result = await platforms.Fund.accountHolderBalance({ accountHolderCode: generateRandomCode() }); expect(result.balancePerAccount![0].detailBalance).toBeDefined(); @@ -420,7 +420,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should retrieve a list of transaction for an account holder's accounts", async function() { nock.restore(); try { - const result = await platforms.Fund.accountHolderTransactionList.post({ + const result = await platforms.Fund.accountHolderTransactionList({ accountHolderCode: generateRandomCode() }); expect(result.accountTransactionLists![0].transactions).toBeDefined(); @@ -432,7 +432,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should transfer funds between two accounts", async function() { nock.restore(); try { - const result = await platforms.Fund.transferFunds.post({ + const result = await platforms.Fund.transferFunds({ sourceAccountCode: "8515883280985939", destinationAccountCode: "8815883278206345", amount: { @@ -454,7 +454,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should retrieve all Notification Configurations", async function() { nock.restore(); try { - const result = await platforms.NotificationConfiguration.getNotificationConfigurationList.post({}); + const result = await platforms.NotificationConfiguration.getNotificationConfigurationList({}); const resultStr = JSON.stringify(result); expect(resultStr.includes("pspReference")).toBeTruthy(); } catch (e) { @@ -465,7 +465,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should create a Notification Configuration", async function() { nock.restore(); try { - const result = await platforms.NotificationConfiguration.createNotificationConfiguration.post({ + const result = await platforms.NotificationConfiguration.createNotificationConfiguration({ configurationDetails: { ...notificationConfigurationDetails, description: `${generateRandomCode()}` @@ -481,7 +481,7 @@ describe.skip("Platforms Test E2E", function(): void { nock.restore(); try { configurationID = notificationConfigurationToRetrieve.configurationDetails.notificationId!; - const result = await platforms.NotificationConfiguration.getNotificationConfiguration.post({ + const result = await platforms.NotificationConfiguration.getNotificationConfiguration({ notificationId: configurationID }); expect(result.configurationDetails.notifyURL).toEqual("https://www.adyen.com/notification-handler"); @@ -493,7 +493,7 @@ describe.skip("Platforms Test E2E", function(): void { it("should update a Notification Configuration", async function() { nock.restore(); try { - const result = await platforms.NotificationConfiguration.updateNotificationConfiguration.post({ + const result = await platforms.NotificationConfiguration.updateNotificationConfiguration({ configurationDetails: { eventConfigs: [ { @@ -521,7 +521,7 @@ describe.skip("Platforms Test E2E", function(): void { const notificationIds = []; notificationIds.push(configurationID); try { - const result = await platforms.NotificationConfiguration.deleteNotificationConfigurations.post({notificationIds}); + const result = await platforms.NotificationConfiguration.deleteNotificationConfigurations({notificationIds}); expect(result.pspReference).toBeDefined(); } catch (e) { assertError(e); @@ -529,4 +529,4 @@ describe.skip("Platforms Test E2E", function(): void { }); }); -}); +}); \ No newline at end of file diff --git a/src/__tests__/recurring.spec.ts b/src/__tests__/recurring.spec.ts index 0da8144..5803cbe 100644 --- a/src/__tests__/recurring.spec.ts +++ b/src/__tests__/recurring.spec.ts @@ -63,7 +63,7 @@ describe("Recurring", (): void => { const request = createRecurringDetailsRequest(); try { - const result = await recurring.listRecurringDetails.post(request); + const result = await recurring.listRecurringDetails(request); expect(result).toBeTruthy(); } catch (e) { fail(e.message); @@ -76,7 +76,7 @@ describe("Recurring", (): void => { .reply(200, paymentsSuccess); const paymentsRequest: ICheckout.PaymentRequest = createPaymentsCheckoutRequest(); - const res = await checkout.payments.post(paymentsRequest); + const res = await checkout.payments(paymentsRequest); scope.post("/disable") .reply(200, disableSuccess); @@ -88,7 +88,7 @@ describe("Recurring", (): void => { }; try { - const result = await recurring.disable.post(request); + const result = await recurring.disable(request); expect(result).toBeTruthy(); } catch (e) { fail(e.message); @@ -119,7 +119,7 @@ describe("Recurring", (): void => { }; try { - const result = await recurring.scheduleAccountUpdater.post(request); + const result = await recurring.scheduleAccountUpdater(request); expect(result).toBeTruthy(); } catch (e) { fail(e.message); diff --git a/src/helpers/getJsonResponse.ts b/src/helpers/getJsonResponse.ts index eecbe48..c8e8ca6 100644 --- a/src/helpers/getJsonResponse.ts +++ b/src/helpers/getJsonResponse.ts @@ -22,16 +22,16 @@ import HttpClientException from "../httpClient/httpClientException"; import ApiException from "../services/exception/apiException"; import { IRequest } from "../typings/requestOptions"; -async function getJsonResponse(this: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise; -async function getJsonResponse(this: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise; +async function getJsonResponse(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise; +async function getJsonResponse(resource: Resource, jsonRequest: T | string, requestOptions?: IRequest.Options): Promise; -async function getJsonResponse ( - this: Resource, +async function getJsonResponse( + resource: Resource, jsonRequest: T | string, requestOptions: IRequest.Options = {}, ): Promise { const request = typeof jsonRequest === "string" ? jsonRequest : JSON.stringify(jsonRequest); - const response = await this.request(request, requestOptions); + const response = await resource.request(request, requestOptions); try { return typeof response === "string" ? JSON.parse(response) : response; } catch (e) { diff --git a/src/httpClient/clientInterface.ts b/src/httpClient/clientInterface.ts index 275a4e9..0bf05d4 100644 --- a/src/httpClient/clientInterface.ts +++ b/src/httpClient/clientInterface.ts @@ -26,6 +26,7 @@ interface ClientInterface { request( endpoint: string, json: string, config: Config, isApiKeyRequired: boolean, requestOptions?: IRequest.Options, ): Promise; + post(endpoint: string, postParameters: [string, string][], config: Config): Promise; proxy?: AgentOptions; } diff --git a/src/httpClient/httpURLConnectionClient.ts b/src/httpClient/httpURLConnectionClient.ts index 9cdbefd..efa7b84 100644 --- a/src/httpClient/httpURLConnectionClient.ts +++ b/src/httpClient/httpURLConnectionClient.ts @@ -70,18 +70,22 @@ class HttpURLConnectionClient implements ClientInterface { return this.doPostRequest(httpConnection, json); } + public post(endpoint: string, postParameters: [string, string][], config: Config): Promise { + const postQuery: string = this.getQuery(postParameters); + const connectionRequest: ClientRequest = this.createRequest(endpoint, {}, config.applicationName); + return this.doPostRequest(connectionRequest, postQuery); + } + private createRequest(endpoint: string, requestOptions: IRequest.Options, applicationName?: string): ClientRequest { if (!requestOptions.headers) { requestOptions.headers = {}; } const url = new URL(endpoint); - const additionalPathname = requestOptions.id ? `/${requestOptions.id}` : ""; - const pathname = `${url.pathname}${additionalPathname}` requestOptions.hostname = url.hostname; requestOptions.protocol = url.protocol; requestOptions.port = url.port; - requestOptions.path = pathname; + requestOptions.path = url.pathname; if (requestOptions && requestOptions.idempotencyKey) { requestOptions.headers[ApiConstants.IDEMPOTENCY_KEY] = requestOptions.idempotencyKey; @@ -107,6 +111,10 @@ class HttpURLConnectionClient implements ClientInterface { return httpsRequest(requestOptions); } + private getQuery(params: [string, string][]): string { + return params.map(([key, value]): string => `${key}=${value}`).join("&"); + } + private doPostRequest(connectionRequest: ClientRequest, json: string): Promise { return new Promise((resolve, reject): void => { connectionRequest.flushHeaders(); diff --git a/src/services/binLookup.ts b/src/services/binLookup.ts index 1e97a12..438b640 100644 --- a/src/services/binLookup.ts +++ b/src/services/binLookup.ts @@ -20,15 +20,30 @@ import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService"; import Client from "../client"; import GetCostEstimate from "./resource/binLookup/getCostEstimate"; import Get3dsAvailability from "./resource/binLookup/get3dsAvailability"; +import getJsonResponse from "../helpers/getJsonResponse"; class BinLookup extends ApiKeyAuthenticatedService { - public readonly get3dsAvailability: Get3dsAvailability; - public readonly getCostEstimate: GetCostEstimate; + private readonly _get3dsAvailability: Get3dsAvailability; + private readonly _getCostEstimate: GetCostEstimate; public constructor(client: Client) { super(client); - this.get3dsAvailability = new Get3dsAvailability(this); - this.getCostEstimate = new GetCostEstimate(this); + this._get3dsAvailability = new Get3dsAvailability(this); + this._getCostEstimate = new GetCostEstimate(this); + } + + public get3dsAvailability(request: IBinLookup.ThreeDSAvailabilityRequest): Promise { + return getJsonResponse( + this._get3dsAvailability, + request + ); + } + + public getCostEstimate(request: IBinLookup.CostEstimateRequest): Promise { + return getJsonResponse( + this._getCostEstimate, + request + ); } } diff --git a/src/services/checkout.ts b/src/services/checkout.ts index 7a97d5e..9ce2219 100644 --- a/src/services/checkout.ts +++ b/src/services/checkout.ts @@ -19,31 +19,142 @@ import ApiKeyAuthenticatedService from "../apiKeyAuthenticatedService"; import Client from "../client"; +import getJsonResponse from "../helpers/getJsonResponse"; import PaymentMethods from "./resource/checkout/paymentMethods"; import Payments from "./resource/checkout/payments"; +import PaymentsDetails from "./resource/checkout/paymentsDetails"; import PaymentSession from "./resource/checkout/paymentSession"; +import PaymentsResult from "./resource/checkout/paymentsResult"; import PaymentLinks from "./resource/checkout/paymentLinks"; import OriginKeys from "./resource/checkout/originKeys"; +import setApplicationInfo from "../helpers/setApplicationInfo"; +import { IRequest } from "../typings/requestOptions"; +import PaymentLinksId from "./resource/checkout/paymentLinksId"; +import PaymentMethodsBalance from "./resource/checkout/paymentMethodsBalance"; import Orders from "./resource/checkout/orders"; +import OrdersCancel from "./resource/checkout/ordersCancel"; class Checkout extends ApiKeyAuthenticatedService { - public readonly payments: Payments; - public readonly paymentMethods: PaymentMethods; - public readonly paymentSession: PaymentSession; - public readonly paymentLinks: PaymentLinks; - public readonly originKeys: OriginKeys; - public readonly orders: Orders; + private readonly _payments: Payments; + private readonly _paymentMethods: PaymentMethods; + private readonly _paymentsDetails: PaymentsDetails; + private readonly _paymentSession: PaymentSession; + private readonly _paymentsResult: PaymentsResult; + private readonly _paymentLinks: PaymentLinks; + private readonly _paymentLinksId: PaymentLinksId; + private readonly _originKeys: OriginKeys; + private readonly _paymentMethodsBalance: PaymentMethodsBalance; + private readonly _orders: Orders; + private readonly _ordersCancel: OrdersCancel; public constructor(client: Client) { super(client); - this.payments = new Payments(this); - this.paymentMethods = new PaymentMethods(this); - this.paymentSession = new PaymentSession(this); - this.paymentLinks = new PaymentLinks(this); - this.originKeys = new OriginKeys(this); - this.orders = new Orders(this); + this._payments = new Payments(this); + this._paymentMethods = new PaymentMethods(this); + this._paymentsDetails = new PaymentsDetails(this); + this._paymentSession = new PaymentSession(this); + this._paymentsResult = new PaymentsResult(this); + this._paymentLinks = new PaymentLinks(this); + this._paymentLinksId = new PaymentLinksId(this); + this._originKeys = new OriginKeys(this); + this._paymentMethodsBalance = new PaymentMethodsBalance(this); + this._orders = new Orders(this); + this._ordersCancel = new OrdersCancel(this); } + public payments(paymentsRequest: ICheckout.PaymentRequest, requestOptions?: IRequest.Options): Promise { + return getJsonResponse( + this._payments, + setApplicationInfo(paymentsRequest), + requestOptions, + ); + } + + public paymentMethods(paymentMethodsRequest: ICheckout.PaymentMethodsRequest): Promise { + return getJsonResponse( + this._paymentMethods, + paymentMethodsRequest, + ); + } + + public paymentLinks(paymentLinkRequest: ICheckout.CreatePaymentLinkRequest): Promise { + return getJsonResponse( + this._paymentLinks, + paymentLinkRequest + ); + } + + public getPaymentLinks(linkId: string): Promise { + this._paymentLinksId.id = linkId; + return getJsonResponse<{}, ICheckout.PaymentLinkResource>( + this._paymentLinksId, + {}, + { method: "GET" } + ); + } + + public updatePaymentLinks(linkId: string, status: "expired"): Promise { + this._paymentLinksId.id = linkId; + return getJsonResponse<{}, ICheckout.PaymentLinkResource>( + this._paymentLinksId, + { status }, + { method: "PATCH" } + ); + } + + public paymentsDetails(paymentsDetailsRequest: ICheckout.DetailsRequest, requestOptions?: IRequest.Options): Promise { + return getJsonResponse( + this._paymentsDetails, + paymentsDetailsRequest, + requestOptions + ); + } + + public paymentSession( + paymentSessionRequest: ICheckout.PaymentSetupRequest, + requestOptions?: IRequest.Options, + ): Promise { + return getJsonResponse( + this._paymentSession, + paymentSessionRequest, + requestOptions, + ); + } + + public paymentResult(paymentResultRequest: ICheckout.PaymentVerificationRequest): Promise { + return getJsonResponse( + this._paymentsResult, + paymentResultRequest, + ); + } + + public originKeys(originKeysRequest: ICheckout.CheckoutUtilityRequest): Promise { + return getJsonResponse( + this._originKeys, + originKeysRequest, + ); + } + + public paymentMethodsBalance(paymentMethodsBalanceRequest: ICheckout.CheckoutBalanceCheckRequest): Promise { + return getJsonResponse( + this._paymentMethodsBalance, + paymentMethodsBalanceRequest, + ); + } + + public orders(ordersRequest: ICheckout.CheckoutCreateOrderRequest): Promise { + return getJsonResponse( + this._orders, + ordersRequest, + ); + } + + public ordersCancel(ordersCancelRequest: ICheckout.CheckoutCancelOrderRequest): Promise { + return getJsonResponse( + this._ordersCancel, + ordersCancelRequest, + ); + } } export default Checkout; diff --git a/src/services/index.ts b/src/services/index.ts index 0a38055..808ae33 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -23,5 +23,5 @@ export { default as CheckoutAPI } from "./checkout"; export { default as Recurring } from "./recurring"; export { default as Modification } from "./modification"; export { default as BinLookup } from "./binLookup"; -export { default as Payouts } from "./payouts"; +export { default as Payout } from "./payout"; export { default as Platforms } from "./platforms"; diff --git a/src/services/modification.ts b/src/services/modification.ts index 357f5a5..fb6c8f4 100644 --- a/src/services/modification.ts +++ b/src/services/modification.ts @@ -17,6 +17,7 @@ * See the LICENSE file for more info. */ import Client from "../client"; +import getJsonResponse from "../helpers/getJsonResponse"; import Service from "../service"; import AdjustAuthorisation from "./resource/modification/adjustAuthorisation"; import Cancel from "./resource/modification/cancel"; @@ -24,25 +25,96 @@ import CancelOrRefund from "./resource/modification/cancelOrRefund"; import Capture from "./resource/modification/capture"; import Refund from "./resource/modification/refund"; import TechnicalCancel from "./resource/modification/technicalCancel"; +import setApplicationInfo from "../helpers/setApplicationInfo"; +import { ApplicationInfo } from "../typings/applicationInfo"; +import { IRequest } from "../typings/requestOptions"; + +interface AppInfo { applicationInfo?: ApplicationInfo } +type GenericRequest = T & AppInfo; class Modification extends Service { - public readonly cancelOrRefund: CancelOrRefund; - public readonly cancel: Cancel; - public readonly capture: Capture; - public readonly refund: Refund; - public readonly adjustAuthorisation: AdjustAuthorisation; - public readonly technicalCancel: TechnicalCancel; + private readonly _cancelOrRefund: CancelOrRefund; + private readonly _cancel: Cancel; + private readonly _capture: Capture; + private readonly _refund: Refund; + private readonly _adjustAuthorisation: AdjustAuthorisation; + private readonly _technicalCancel: TechnicalCancel; public constructor(client: Client) { super(client); - this.capture = new Capture(this); - this.cancelOrRefund = new CancelOrRefund(this); - this.cancel = new Cancel(this); - this.refund = new Refund(this); - this.adjustAuthorisation = new AdjustAuthorisation(this); - this.technicalCancel = new TechnicalCancel(this); + this._capture = new Capture(this); + this._cancelOrRefund = new CancelOrRefund(this); + this._cancel = new Cancel(this); + this._refund = new Refund(this); + this._adjustAuthorisation = new AdjustAuthorisation(this); + this._technicalCancel = new TechnicalCancel(this); } + public capture( + captureRequest: GenericRequest, + requestOptions?: IRequest.Options, + ): Promise { + return getJsonResponse( + this._capture, + setApplicationInfo(captureRequest), + requestOptions, + ); + } + + public cancelOrRefund( + cancelOrRefundRequest: GenericRequest, + requestOptions?: IRequest.Options, + ): Promise { + return getJsonResponse( + this._cancelOrRefund, + setApplicationInfo(cancelOrRefundRequest), + requestOptions, + ); + } + + public refund( + refundRequest: GenericRequest, + requestOptions?: IRequest.Options, + ): Promise { + return getJsonResponse( + this._refund, + setApplicationInfo(refundRequest), + requestOptions, + ); + } + + public cancel( + cancelRequest: GenericRequest, + requestOptions?: IRequest.Options, + ): Promise { + return getJsonResponse( + this._cancel, + setApplicationInfo(cancelRequest), + requestOptions, + ); + } + + public technicalCancel( + technicalCancelRequest: GenericRequest, + requestOptions?: IRequest.Options, + ): Promise { + return getJsonResponse( + this._technicalCancel, + setApplicationInfo(technicalCancelRequest), + requestOptions, + ); + } + + public adjustAuthorisation( + adjustAuthorisationRequest: GenericRequest, + requestOptions?: IRequest.Options, + ): Promise { + return getJsonResponse( + this._adjustAuthorisation, + setApplicationInfo(adjustAuthorisationRequest), + requestOptions, + ); + } } export default Modification; diff --git a/src/services/payout.ts b/src/services/payout.ts new file mode 100644 index 0000000..0ea7024 --- /dev/null +++ b/src/services/payout.ts @@ -0,0 +1,91 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * Adyen NodeJS API Library + * Copyright (c) 2020 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ +import Client from "../client"; +import Service from "../service"; +import DeclineThirdParty from "./resource/payout/declineThirdParty"; +import StoreDetail from "./resource/payout/storeDetail"; +import SubmitThirdParty from "./resource/payout/submitThirdParty"; +import ConfirmThirdParty from "./resource/payout/confirmThirdParty"; +import PayoutResource from "./resource/payout/payout"; +import StoreDetailAndSubmitThirdParty from "./resource/payout/storeDetailAndSubmitThirdParty"; +import getJsonResponse from "../helpers/getJsonResponse"; + +class Payout extends Service { + private readonly _storeDetailAndSubmitThirdParty: StoreDetailAndSubmitThirdParty; + private readonly _confirmThirdParty: ConfirmThirdParty; + private readonly _declineThirdParty: DeclineThirdParty; + private readonly _storeDetail: StoreDetail; + private readonly _submitThirdParty: SubmitThirdParty; + private readonly _payout: PayoutResource; + + public constructor(client: Client) { + super(client); + + this._storeDetailAndSubmitThirdParty = new StoreDetailAndSubmitThirdParty(this); + this._confirmThirdParty = new ConfirmThirdParty(this); + this._declineThirdParty = new DeclineThirdParty(this); + this._storeDetail = new StoreDetail(this); + this._submitThirdParty = new SubmitThirdParty(this); + this._payout = new PayoutResource(this); + } + + public storeDetailAndSubmitThirdParty(request: IPayouts.StoreDetailAndSubmitRequest): Promise { + return getJsonResponse( + this._storeDetailAndSubmitThirdParty, + request + ); + } + + public confirmThirdParty(request: IPayouts.ModifyRequest): Promise { + return getJsonResponse( + this._confirmThirdParty, + request + ); + } + + public declineThirdParty(request: IPayouts.ModifyRequest): Promise { + return getJsonResponse( + this._declineThirdParty, + request + ); + } + + public storeDetail(request: IPayouts.StoreDetailRequest): Promise { + return getJsonResponse( + this._storeDetail, + request + ); + } + + public submitThirdparty(request: IPayouts.SubmitRequest): Promise { + return getJsonResponse( + this._submitThirdParty, + request + ); + } + + public payout(request: IPayouts.PayoutRequest): Promise { + return getJsonResponse( + this._payout, + request + ); + } +} + +export default Payout; \ No newline at end of file diff --git a/src/services/payouts.ts b/src/services/payouts.ts deleted file mode 100644 index f4a44e3..0000000 --- a/src/services/payouts.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * Adyen NodeJS API Library - * Copyright (c) 2020 Adyen B.V. - * This file is open source and available under the MIT license. - * See the LICENSE file for more info. - */ -import Client from "../client"; -import Service from "../service"; -import DeclineThirdParty from "./resource/payout/declineThirdParty"; -import StoreDetail from "./resource/payout/storeDetail"; -import SubmitThirdParty from "./resource/payout/submitThirdParty"; -import ConfirmThirdParty from "./resource/payout/confirmThirdParty"; -import PayoutResource from "./resource/payout/payout"; -import StoreDetailAndSubmitThirdParty from "./resource/payout/storeDetailAndSubmitThirdParty"; - -class Payouts extends Service { - public readonly storeDetailAndSubmitThirdParty: StoreDetailAndSubmitThirdParty; - public readonly confirmThirdParty: ConfirmThirdParty; - public readonly declineThirdParty: DeclineThirdParty; - public readonly storeDetail: StoreDetail; - public readonly submitThirdParty: SubmitThirdParty; - public readonly payout: PayoutResource; - - public constructor(client: Client) { - super(client); - - this.storeDetailAndSubmitThirdParty = new StoreDetailAndSubmitThirdParty(this); - this.confirmThirdParty = new ConfirmThirdParty(this); - this.declineThirdParty = new DeclineThirdParty(this); - this.storeDetail = new StoreDetail(this); - this.submitThirdParty = new SubmitThirdParty(this); - this.payout = new PayoutResource(this); - } -} - -export default Payouts; diff --git a/src/services/platforms.ts b/src/services/platforms.ts index 06ec3ea..e564fd1 100644 --- a/src/services/platforms.ts +++ b/src/services/platforms.ts @@ -34,133 +34,132 @@ type AccountsAccount = PlatformsAccount; type AccountsVerification = PlatformsAccount; type AccountsAccountHolders = PlatformsAccount; type PlatformsTypes = AccountsAccount | AccountsVerification | AccountsAccountHolders | PlatformsFund | PlatformsHostedOnboardingPage; -type PostRequest = { post: (request: T) => Promise }; class Platforms extends Service { /* PlatformsAccount */ // Accounts - public readonly closeAccount: PlatformsAccount; - public readonly updateAccount: PlatformsAccount; - public readonly createAccount: PlatformsAccount; + private readonly _closeAccount: PlatformsAccount; + private readonly _updateAccount: PlatformsAccount; + private readonly _createAccount: PlatformsAccount; // Verification - public readonly uploadDocument: PlatformsAccount; - public readonly getUploadedDocuments: PlatformsAccount; - public readonly deleteBankAccounts: PlatformsAccount; - public readonly deletePayoutMethods: PlatformsAccount; - public readonly deleteShareholders: PlatformsAccount; - public readonly checkAccountHolder: PlatformsAccount; + private readonly _uploadDocument: PlatformsAccount; + private readonly _getUploadedDocuments: PlatformsAccount; + private readonly _deleteBankAccounts: PlatformsAccount; + private readonly _deletePayoutMethods: PlatformsAccount; + private readonly _deleteShareholders: PlatformsAccount; + private readonly _checkAccountHolder: PlatformsAccount; // Account Holders - public readonly createAccountHolder: PlatformsAccount; - public readonly getAccountHolder: PlatformsAccount; - public readonly updateAccountHolder: PlatformsAccount; - public readonly updateAccountHolderState: PlatformsAccount; - public readonly suspendAccountHolder: PlatformsAccount; - public readonly unSuspendAccountHolder: PlatformsAccount; - public readonly closeAccountHolder: PlatformsAccount; + private readonly _createAccountHolder: PlatformsAccount; + private readonly _getAccountHolder: PlatformsAccount; + private readonly _updateAccountHolder: PlatformsAccount; + private readonly _updateAccountHolderState: PlatformsAccount; + private readonly _suspendAccountHolder: PlatformsAccount; + private readonly _unSuspendAccountHolder: PlatformsAccount; + private readonly _closeAccountHolder: PlatformsAccount; /* PlatformsFund */ - public readonly accountHolderBalance: PlatformsFund; - public readonly accountHolderTransactionList: PlatformsFund; - public readonly payoutAccountHolder: PlatformsFund; - public readonly transferFunds: PlatformsFund; - public readonly refundFundsTransfer: PlatformsFund; - public readonly setupBeneficiary: PlatformsFund; - public readonly refundNotPaidOutTransfers: PlatformsFund; + private readonly _accountHolderBalance: PlatformsFund; + private readonly _accountHolderTransactionList: PlatformsFund; + private readonly _payoutAccountHolder: PlatformsFund; + private readonly _transferFunds: PlatformsFund; + private readonly _refundFundsTransfer: PlatformsFund; + private readonly _setupBeneficiary: PlatformsFund; + private readonly _refundNotPaidOutTransfers: PlatformsFund; /* HOP */ - public readonly getOnboardingUrl: PlatformsHostedOnboardingPage; + private readonly _getOnboardingUrl: PlatformsHostedOnboardingPage; /* Notification Configuration */ - public readonly createNotificationConfiguration: PlatformsNotificationConfiguration; - public readonly getNotificationConfiguration: PlatformsNotificationConfiguration; - public readonly getNotificationConfigurationList: PlatformsNotificationConfiguration; - public readonly testNotificationConfiguration: PlatformsNotificationConfiguration; - public readonly updateNotificationConfiguration: PlatformsNotificationConfiguration; - public readonly deleteNotificationConfiguration: PlatformsNotificationConfiguration; + private readonly _createNotificationConfiguration: PlatformsNotificationConfiguration; + private readonly _getNotificationConfiguration: PlatformsNotificationConfiguration; + private readonly _getNotificationConfigurationList: PlatformsNotificationConfiguration; + private readonly _testNotificationConfiguration: PlatformsNotificationConfiguration; + private readonly _updateNotificationConfiguration: PlatformsNotificationConfiguration; + private readonly _deleteNotificationConfiguration: PlatformsNotificationConfiguration; public constructor(client: Client) { super(client); // Account - this.closeAccount = new PlatformsAccount(this, "/closeAccount"); - this.updateAccount = new PlatformsAccount(this, "/updateAccount"); - this.createAccount = new PlatformsAccount(this, "/createAccount"); - this.uploadDocument = new PlatformsAccount(this, "/uploadDocument"); - this.getUploadedDocuments = new PlatformsAccount(this, "/getUploadedDocuments"); - this.deleteBankAccounts = new PlatformsAccount(this, "/deleteBankAccounts"); - this.deletePayoutMethods = new PlatformsAccount(this, "/deletePayoutMethods"); - this.deleteShareholders = new PlatformsAccount(this, "/deleteShareholders"); - this.checkAccountHolder = new PlatformsAccount(this, "/checkAccountHolder"); - this.createAccountHolder = new PlatformsAccount(this, "/createAccountHolder"); - this.getAccountHolder = new PlatformsAccount(this, "/getAccountHolder"); - this.updateAccountHolder = new PlatformsAccount(this, "/updateAccountHolder"); - this.updateAccountHolderState = new PlatformsAccount(this, "/updateAccountHolderState"); - this.suspendAccountHolder = new PlatformsAccount(this, "/suspendAccountHolder"); - this.unSuspendAccountHolder = new PlatformsAccount(this, "/unSuspendAccountHolder"); - this.closeAccountHolder = new PlatformsAccount(this, "/closeAccountHolder"); + this._closeAccount = new PlatformsAccount(this, "/closeAccount"); + this._updateAccount = new PlatformsAccount(this, "/updateAccount"); + this._createAccount = new PlatformsAccount(this, "/createAccount"); + this._uploadDocument = new PlatformsAccount(this, "/uploadDocument"); + this._getUploadedDocuments = new PlatformsAccount(this, "/getUploadedDocuments"); + this._deleteBankAccounts = new PlatformsAccount(this, "/deleteBankAccounts"); + this._deletePayoutMethods = new PlatformsAccount(this, "/deletePayoutMethods"); + this._deleteShareholders = new PlatformsAccount(this, "/deleteShareholders"); + this._checkAccountHolder = new PlatformsAccount(this, "/checkAccountHolder"); + this._createAccountHolder = new PlatformsAccount(this, "/createAccountHolder"); + this._getAccountHolder = new PlatformsAccount(this, "/getAccountHolder"); + this._updateAccountHolder = new PlatformsAccount(this, "/updateAccountHolder"); + this._updateAccountHolderState = new PlatformsAccount(this, "/updateAccountHolderState"); + this._suspendAccountHolder = new PlatformsAccount(this, "/suspendAccountHolder"); + this._unSuspendAccountHolder = new PlatformsAccount(this, "/unSuspendAccountHolder"); + this._closeAccountHolder = new PlatformsAccount(this, "/closeAccountHolder"); // Fund - this.accountHolderBalance = new PlatformsFund(this, "/accountHolderBalance"); - this.accountHolderTransactionList = new PlatformsFund(this, "/accountHolderTransactionList"); - this.payoutAccountHolder = new PlatformsFund(this, "/payoutAccountHolder"); - this.transferFunds = new PlatformsFund(this, "/transferFunds"); - this.refundFundsTransfer = new PlatformsFund(this, "/refundFundsTransfer"); - this.setupBeneficiary = new PlatformsFund(this, "/setupBeneficiary"); - this.refundNotPaidOutTransfers = new PlatformsFund(this, "/refundNotPaidOutTransfers"); + this._accountHolderBalance = new PlatformsFund(this, "/accountHolderBalance"); + this._accountHolderTransactionList = new PlatformsFund(this, "/accountHolderTransactionList"); + this._payoutAccountHolder = new PlatformsFund(this, "/payoutAccountHolder"); + this._transferFunds = new PlatformsFund(this, "/transferFunds"); + this._refundFundsTransfer = new PlatformsFund(this, "/refundFundsTransfer"); + this._setupBeneficiary = new PlatformsFund(this, "/setupBeneficiary"); + this._refundNotPaidOutTransfers = new PlatformsFund(this, "/refundNotPaidOutTransfers"); // HOP - this.getOnboardingUrl = new PlatformsHostedOnboardingPage(this, "/getOnboardingUrl"); + this._getOnboardingUrl = new PlatformsHostedOnboardingPage(this, "/getOnboardingUrl"); // Notification Configuration - this.createNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/createNotificationConfiguration"); - this.getNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/getNotificationConfiguration"); - this.getNotificationConfigurationList = new PlatformsNotificationConfiguration(this, "/getNotificationConfigurationList"); - this.testNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/testNotificationConfiguration"); - this.updateNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/updateNotificationConfiguration"); - this.deleteNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/deleteNotificationConfigurations"); + this._createNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/createNotificationConfiguration"); + this._getNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/getNotificationConfiguration"); + this._getNotificationConfigurationList = new PlatformsNotificationConfiguration(this, "/getNotificationConfigurationList"); + this._testNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/testNotificationConfiguration"); + this._updateNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/updateNotificationConfiguration"); + this._deleteNotificationConfiguration = new PlatformsNotificationConfiguration(this, "/deleteNotificationConfigurations"); } - createPostRequest = (service: T): PostRequest => { - return { post: (request: U): Promise => getJsonResponse.call>(service, request) }; + createRequest = (service: T) => { + return (request: U): Promise => getJsonResponse(service, request); } public get Account(): { - getAccountHolder: PostRequest; - getUploadedDocuments: PostRequest; - createAccountHolder: PostRequest; - closeAccountHolder: PostRequest; - createAccount: PostRequest; - deleteBankAccounts: PostRequest; - deletePayoutMethods: PostRequest; - updateAccount: PostRequest; - uploadDocument: PostRequest; - unSuspendAccountHolder: PostRequest; - closeAccount: PostRequest; - suspendAccountHolder: PostRequest; - updateAccountHolder: PostRequest; - deleteShareholders: PostRequest; - checkAccountHolder: PostRequest; - updateAccountHolderState: PostRequest; + getAccountHolder: (request: IPlatformsAccount.GetAccountHolderRequest) => Promise; + getUploadedDocuments: (request: IPlatformsAccount.GetUploadedDocumentsRequest) => Promise; + createAccountHolder: (request: IPlatformsAccount.CreateAccountHolderRequest) => Promise; + closeAccountHolder: (request: IPlatformsAccount.CloseAccountHolderRequest) => Promise; + createAccount: (request: IPlatformsAccount.CreateAccountRequest) => Promise; + deleteBankAccounts: (request: IPlatformsAccount.DeleteBankAccountRequest) => Promise; + deletePayoutMethods: (request: IPlatformsAccount.DeletePayoutMethodRequest) => Promise; + updateAccount: (request: IPlatformsAccount.UpdateAccountRequest) => Promise; + uploadDocument: (request: IPlatformsAccount.UploadDocumentRequest) => Promise; + unSuspendAccountHolder: (request: IPlatformsAccount.UnSuspendAccountHolderRequest) => Promise; + closeAccount: (request: IPlatformsAccount.CloseAccountRequest) => Promise; + suspendAccountHolder: (request: IPlatformsAccount.SuspendAccountHolderRequest) => Promise; + updateAccountHolder: (request: IPlatformsAccount.UpdateAccountHolderRequest) => Promise; + deleteShareholders: (request: IPlatformsAccount.DeleteShareholderRequest) => Promise; + checkAccountHolder: (request: IPlatformsAccount.PerformVerificationRequest) => Promise; + updateAccountHolderState: (request: IPlatformsAccount.UpdateAccountHolderStateRequest) => Promise; } { - const closeAccount = this.createPostRequest(this.closeAccount); - const updateAccount = this.createPostRequest(this.updateAccount); - const createAccount = this.createPostRequest(this.createAccount); + const closeAccount = this.createRequest(this._closeAccount); + const updateAccount = this.createRequest(this._updateAccount); + const createAccount = this.createRequest(this._createAccount); - const uploadDocument = this.createPostRequest(this.uploadDocument); - const getUploadedDocuments = this.createPostRequest(this.getUploadedDocuments); - const deleteBankAccounts = this.createPostRequest(this.deleteBankAccounts); - const deletePayoutMethods = this.createPostRequest(this.deletePayoutMethods); - const deleteShareholders = this.createPostRequest(this.deleteShareholders); + const uploadDocument = this.createRequest(this._uploadDocument); + const getUploadedDocuments = this.createRequest(this._getUploadedDocuments); + const deleteBankAccounts = this.createRequest(this._deleteBankAccounts); + const deletePayoutMethods = this.createRequest(this._deletePayoutMethods); + const deleteShareholders = this.createRequest(this._deleteShareholders); - const createAccountHolder = this.createPostRequest(this.createAccountHolder); - const getAccountHolder = this.createPostRequest(this.getAccountHolder); - const updateAccountHolder = this.createPostRequest(this.updateAccountHolder); - const updateAccountHolderState = this.createPostRequest(this.updateAccountHolderState); - const suspendAccountHolder = this.createPostRequest(this.suspendAccountHolder); - const unSuspendAccountHolder = this.createPostRequest(this.unSuspendAccountHolder); - const closeAccountHolder = this.createPostRequest(this.closeAccountHolder); - const checkAccountHolder = this.createPostRequest(this.checkAccountHolder); + const createAccountHolder = this.createRequest(this._createAccountHolder); + const getAccountHolder = this.createRequest(this._getAccountHolder); + const updateAccountHolder = this.createRequest(this._updateAccountHolder); + const updateAccountHolderState = this.createRequest(this._updateAccountHolderState); + const suspendAccountHolder = this.createRequest(this._suspendAccountHolder); + const unSuspendAccountHolder = this.createRequest(this._unSuspendAccountHolder); + const closeAccountHolder = this.createRequest(this._closeAccountHolder); + const checkAccountHolder = this.createRequest(this._checkAccountHolder); const accounts = { closeAccount, updateAccount, createAccount }; const verification = { uploadDocument, getUploadedDocuments, deleteBankAccounts, deletePayoutMethods, deleteShareholders, checkAccountHolder }; @@ -170,45 +169,45 @@ class Platforms extends Service { } public get Fund(): { - refundNotPaidOutTransfers: PostRequest; - accountHolderTransactionList: PostRequest; - setupBeneficiary: PostRequest; - transferFunds: PostRequest; - refundFundsTransfer: PostRequest; - payoutAccountHolder: PostRequest; - accountHolderBalance: PostRequest; + refundNotPaidOutTransfers: (request: IPlatformsFund.RefundNotPaidOutTransfersRequest) => Promise; + accountHolderTransactionList: (request: IPlatformsFund.AccountHolderTransactionListRequest) => Promise; + setupBeneficiary: (request: IPlatformsFund.SetupBeneficiaryRequest) => Promise; + transferFunds: (request: IPlatformsFund.TransferFundsRequest) => Promise; + refundFundsTransfer: (request: IPlatformsFund.RefundFundsTransferRequest) => Promise; + payoutAccountHolder: (request: IPlatformsFund.PayoutAccountHolderRequest) => Promise; + accountHolderBalance: (request: IPlatformsFund.AccountHolderBalanceRequest) => Promise; } { - const accountHolderBalance = this.createPostRequest(this.accountHolderBalance); - const accountHolderTransactionList = this.createPostRequest(this.accountHolderTransactionList); - const payoutAccountHolder = this.createPostRequest(this.payoutAccountHolder); - const transferFunds = this.createPostRequest(this.transferFunds); - const refundFundsTransfer = this.createPostRequest(this.refundFundsTransfer); - const setupBeneficiary = this.createPostRequest(this.setupBeneficiary); - const refundNotPaidOutTransfers = this.createPostRequest(this.refundNotPaidOutTransfers); + const accountHolderBalance = this.createRequest(this._accountHolderBalance); + const accountHolderTransactionList = this.createRequest(this._accountHolderTransactionList); + const payoutAccountHolder = this.createRequest(this._payoutAccountHolder); + const transferFunds = this.createRequest(this._transferFunds); + const refundFundsTransfer = this.createRequest(this._refundFundsTransfer); + const setupBeneficiary = this.createRequest(this._setupBeneficiary); + const refundNotPaidOutTransfers = this.createRequest(this._refundNotPaidOutTransfers); return { accountHolderBalance, accountHolderTransactionList, payoutAccountHolder, refundFundsTransfer, transferFunds, setupBeneficiary, refundNotPaidOutTransfers }; } - public get HostedOnboardingPage(): { getOnboardingUrl: PostRequest } { - const getOnboardingUrl = this.createPostRequest(this.getOnboardingUrl); + public get HostedOnboardingPage(): { getOnboardingUrl: (request: IPlatformsHostedOnboardingPage.GetOnboardingUrlRequest) => Promise } { + const getOnboardingUrl = this.createRequest(this._getOnboardingUrl); return { getOnboardingUrl }; } public get NotificationConfiguration(): { - createNotificationConfiguration: PostRequest; - updateNotificationConfiguration: PostRequest; - getNotificationConfiguration: PostRequest; - testNotificationConfiguration: PostRequest; - getNotificationConfigurationList: PostRequest<{}, IPlatformsNotificationConfiguration.GetNotificationConfigurationListResponse>; - deleteNotificationConfigurations: PostRequest; + createNotificationConfiguration: (request: IPlatformsNotificationConfiguration.CreateNotificationConfigurationRequest) => Promise; + updateNotificationConfiguration: (request: IPlatformsNotificationConfiguration.UpdateNotificationConfigurationRequest) => Promise; + getNotificationConfiguration: (request: IPlatformsNotificationConfiguration.GetNotificationConfigurationRequest) => Promise; + testNotificationConfiguration: (request: IPlatformsNotificationConfiguration.TestNotificationConfigurationRequest) => Promise; + getNotificationConfigurationList: (request: {}) => Promise; + deleteNotificationConfigurations: (request: IPlatformsNotificationConfiguration.DeleteNotificationConfigurationRequest) => Promise; } { - const createNotificationConfiguration = this.createPostRequest(this.createNotificationConfiguration); - const getNotificationConfiguration = this.createPostRequest(this.getNotificationConfiguration); - const getNotificationConfigurationList = this.createPostRequest(this.getNotificationConfigurationList); - const testNotificationConfiguration = this.createPostRequest(this.testNotificationConfiguration); - const updateNotificationConfiguration = this.createPostRequest(this.updateNotificationConfiguration); - const deleteNotificationConfigurations = this.createPostRequest(this.deleteNotificationConfiguration); + const createNotificationConfiguration = this.createRequest(this._createNotificationConfiguration); + const getNotificationConfiguration = this.createRequest(this._getNotificationConfiguration); + const getNotificationConfigurationList = this.createRequest(this._getNotificationConfigurationList); + const testNotificationConfiguration = this.createRequest(this._testNotificationConfiguration); + const updateNotificationConfiguration = this.createRequest(this._updateNotificationConfiguration); + const deleteNotificationConfigurations = this.createRequest(this._deleteNotificationConfiguration); return { createNotificationConfiguration, getNotificationConfiguration, getNotificationConfigurationList, testNotificationConfiguration, updateNotificationConfiguration, deleteNotificationConfigurations }; } diff --git a/src/services/recurring.ts b/src/services/recurring.ts index 08136c5..9671922 100644 --- a/src/services/recurring.ts +++ b/src/services/recurring.ts @@ -18,21 +18,43 @@ */ import Client from "../client"; +import getJsonResponse from "../helpers/getJsonResponse"; import Service from "../service"; import Disable from "./resource/recurring/disable"; import ListRecurringDetails from "./resource/recurring/listRecurringDetails"; import ScheduleAccountUpdater from "./resource/recurring/scheduleAccountUpdater"; class Recurring extends Service { - public readonly listRecurringDetails: ListRecurringDetails; - public readonly disable: Disable; - public readonly scheduleAccountUpdater: ScheduleAccountUpdater; + private readonly _listRecurringDetails: ListRecurringDetails; + private readonly _disable: Disable; + private readonly _scheduleAccountUpdater: ScheduleAccountUpdater; public constructor(client: Client) { super(client); - this.listRecurringDetails = new ListRecurringDetails(this); - this.disable = new Disable(this); - this.scheduleAccountUpdater = new ScheduleAccountUpdater(this); + this._listRecurringDetails = new ListRecurringDetails(this); + this._disable = new Disable(this); + this._scheduleAccountUpdater = new ScheduleAccountUpdater(this); + } + + public listRecurringDetails(request: IRecurring.RecurringDetailsRequest): Promise { + return getJsonResponse( + this._listRecurringDetails, + request, + ); + } + + public disable(request: IRecurring.DisableRequest): Promise { + return getJsonResponse( + this._disable, + request, + ); + } + + public scheduleAccountUpdater(request: IRecurring.ScheduleAccountUpdaterRequest): Promise { + return getJsonResponse( + this._scheduleAccountUpdater, + request, + ); } } diff --git a/src/services/resource.ts b/src/services/resource.ts index 8e1fbd1..97505cb 100644 --- a/src/services/resource.ts +++ b/src/services/resource.ts @@ -24,15 +24,8 @@ import ApiException from "./exception/apiException"; import ClientInterface from "../httpClient/clientInterface"; import { IRequest } from "../typings/requestOptions"; -type Req = { [key: string]: any }; -type ReqWithId = { id?: string } & Req; - abstract class Resource { protected endpoint: string; - protected post?(req: Req, requestOptions?: IRequest.Options): Promise<{}>; - protected patch?(req?: ReqWithId, requestOptions?: IRequest.Options): Promise<{}>; - protected get?(req?: ReqWithId, requestOptions?: IRequest.Options): Promise<{}>; - protected delete?(req?: ReqWithId, requestOptions?: IRequest.Options): Promise<{}>; private service: Service; protected constructor(service: Service, endpoint: string) { @@ -40,7 +33,7 @@ abstract class Resource { this.endpoint = endpoint; } - protected request(json: string, requestOptions?: IRequest.Options): Promise { + public request(json: string, requestOptions?: IRequest.Options): Promise { const clientInterface: ClientInterface = this.service.client.httpClient; const config: Config = this.service.client.config; diff --git a/src/services/resource/binLookup/get3dsAvailability.ts b/src/services/resource/binLookup/get3dsAvailability.ts index 1d0c47a..de5400f 100644 --- a/src/services/resource/binLookup/get3dsAvailability.ts +++ b/src/services/resource/binLookup/get3dsAvailability.ts @@ -20,7 +20,6 @@ import Resource from "../../resource"; import Service from "../../../service"; import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class Get3dsAvailability extends Resource { public constructor(service: Service) { @@ -29,13 +28,6 @@ class Get3dsAvailability extends Resource { `${service.client.config.endpoint}${Client.BIN_LOOKUP_PAL_SUFFIX}${Client.BIN_LOOKUP_API_VERSION}/get3dsAvailability` ); } - - public post(request: IBinLookup.ThreeDSAvailabilityRequest): Promise { - return getJsonResponse.call>( - this, - request - ); - } } export default Get3dsAvailability; diff --git a/src/services/resource/binLookup/getCostEstimate.ts b/src/services/resource/binLookup/getCostEstimate.ts index 4dbb3c6..c64f568 100644 --- a/src/services/resource/binLookup/getCostEstimate.ts +++ b/src/services/resource/binLookup/getCostEstimate.ts @@ -20,7 +20,6 @@ import Resource from "../../resource"; import Service from "../../../service"; import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class GetCostEstimate extends Resource { public constructor(service: Service) { @@ -29,13 +28,6 @@ class GetCostEstimate extends Resource { `${service.client.config.endpoint}${Client.BIN_LOOKUP_PAL_SUFFIX}${Client.BIN_LOOKUP_API_VERSION}/getCostEstimate` ); } - - public post(request: IBinLookup.CostEstimateRequest): Promise { - return getJsonResponse.call>( - this, - request - ); - } } export default GetCostEstimate; diff --git a/src/services/resource/checkout/orders.ts b/src/services/resource/checkout/orders.ts index 30ae0f0..090790a 100644 --- a/src/services/resource/checkout/orders.ts +++ b/src/services/resource/checkout/orders.ts @@ -18,30 +18,16 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; import Service from "../../../service"; import Resource from "../../resource"; -import OrdersCancel from "./ordersCancel"; class Orders extends Resource { - public readonly cancel: OrdersCancel; - public constructor(service: Service) { super( service, `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/orders`, ); - - this.cancel = new OrdersCancel(service); } - - public post(ordersRequest: ICheckout.CheckoutCreateOrderRequest): Promise { - return getJsonResponse.call>( - this, - ordersRequest, - ); - } - } export default Orders; diff --git a/src/services/resource/checkout/ordersCancel.ts b/src/services/resource/checkout/ordersCancel.ts index 6f9013d..83bc809 100644 --- a/src/services/resource/checkout/ordersCancel.ts +++ b/src/services/resource/checkout/ordersCancel.ts @@ -18,7 +18,6 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; import Service from "../../../service"; import Resource from "../../resource"; @@ -29,13 +28,6 @@ class OrdersCancel extends Resource { `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/orders/cancel`, ); } - - public post(ordersCancelRequest: ICheckout.CheckoutCancelOrderRequest): Promise { - return getJsonResponse.call>( - this, - ordersCancelRequest, - ); - } } export default OrdersCancel; diff --git a/src/services/resource/checkout/originKeys.ts b/src/services/resource/checkout/originKeys.ts index 347d826..8426a46 100644 --- a/src/services/resource/checkout/originKeys.ts +++ b/src/services/resource/checkout/originKeys.ts @@ -18,7 +18,6 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; import Service from "../../../service"; import Resource from "../../resource"; @@ -29,14 +28,6 @@ class OriginKeys extends Resource { `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/originKeys`, ); } - - public post(originKeysRequest: ICheckout.CheckoutUtilityRequest): Promise { - return getJsonResponse.call>( - this, - originKeysRequest, - ); - } - } export default OriginKeys; diff --git a/src/services/resource/checkout/paymentLinks.ts b/src/services/resource/checkout/paymentLinks.ts index 899b0a4..e460cfd 100644 --- a/src/services/resource/checkout/paymentLinks.ts +++ b/src/services/resource/checkout/paymentLinks.ts @@ -18,11 +18,8 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; import Service from "../../../service"; import Resource from "../../resource"; -import { HTTPMethod } from "../../../typings/HTTPMethod"; -import { IRequest } from "../../../typings/requestOptions"; class PaymentLinks extends Resource { public constructor(service: Service) { @@ -31,29 +28,6 @@ class PaymentLinks extends Resource { `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentLinks`, ); } - - public post(paymentLinkRequest: ICheckout.CreatePaymentLinkRequest): Promise { - return getJsonResponse.call>( - this, - paymentLinkRequest - ); - } - - public get({ id }: { id: string }): Promise { - return getJsonResponse.call>( - this, - {}, - { id, method: HTTPMethod.GET } - ); - } - - public patch({ id, status }: { id: string, status: "expired" }): Promise { - return getJsonResponse.call>( - this, - { status }, - { id, method: HTTPMethod.PATCH } - ); - } } export default PaymentLinks; diff --git a/src/services/resource/checkout/paymentLinksId.ts b/src/services/resource/checkout/paymentLinksId.ts new file mode 100644 index 0000000..eb644de --- /dev/null +++ b/src/services/resource/checkout/paymentLinksId.ts @@ -0,0 +1,40 @@ +/* + * ###### + * ###### + * ############ ####( ###### #####. ###### ############ ############ + * ############# #####( ###### #####. ###### ############# ############# + * ###### #####( ###### #####. ###### ##### ###### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### + * ###### ###### #####( ###### #####. ###### ##### ##### ###### + * ############# ############# ############# ############# ##### ###### + * ############ ############ ############# ############ ##### ###### + * ###### + * ############# + * ############ + * Adyen NodeJS API Library + * Copyright (c) 2020 Adyen B.V. + * This file is open source and available under the MIT license. + * See the LICENSE file for more info. + */ + +import Client from "../../../client"; +import Service from "../../../service"; +import Resource from "../../resource"; + +class PaymentLinksId extends Resource { + static _id: string; + + public constructor(service: Service) { + super( + service, + `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentLinks`, + ); + } + + public set id(id: string) { + PaymentLinksId._id = id; + this.endpoint = `${this.endpoint}/${PaymentLinksId._id}`; + } +} + +export default PaymentLinksId; diff --git a/src/services/resource/checkout/paymentMethods.ts b/src/services/resource/checkout/paymentMethods.ts index 07e1fd7..a45fa02 100644 --- a/src/services/resource/checkout/paymentMethods.ts +++ b/src/services/resource/checkout/paymentMethods.ts @@ -18,30 +18,16 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; import Service from "../../../service"; import Resource from "../../resource"; -import PaymentMethodsBalance from "./paymentMethodsBalance"; class PaymentMethods extends Resource { - public readonly balance: PaymentMethodsBalance; - public constructor(service: Service) { super( service, `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentMethods`, ); - - this.balance = new PaymentMethodsBalance(service); } - - public post(paymentMethodsRequest: ICheckout.PaymentMethodsRequest): Promise { - return getJsonResponse.call>( - this, - paymentMethodsRequest, - ); - } - } export default PaymentMethods; diff --git a/src/services/resource/checkout/paymentMethodsBalance.ts b/src/services/resource/checkout/paymentMethodsBalance.ts index d58b65b..8996c25 100644 --- a/src/services/resource/checkout/paymentMethodsBalance.ts +++ b/src/services/resource/checkout/paymentMethodsBalance.ts @@ -18,7 +18,6 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; import Service from "../../../service"; import Resource from "../../resource"; @@ -29,14 +28,6 @@ class PaymentMethodsBalance extends Resource { `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentMethods/balance`, ); } - - public post(paymentMethodsBalanceRequest: ICheckout.CheckoutBalanceCheckRequest): Promise { - return getJsonResponse.call>( - this, - paymentMethodsBalanceRequest, - ); - } - } export default PaymentMethodsBalance; diff --git a/src/services/resource/checkout/paymentSession.ts b/src/services/resource/checkout/paymentSession.ts index 9689ec6..f4f4093 100644 --- a/src/services/resource/checkout/paymentSession.ts +++ b/src/services/resource/checkout/paymentSession.ts @@ -18,9 +18,7 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; import Service from "../../../service"; -import { IRequest } from "../../../typings/requestOptions"; import Resource from "../../resource"; class PaymentSession extends Resource { @@ -30,17 +28,6 @@ class PaymentSession extends Resource { `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/paymentSession`, ); } - - public post( - paymentSessionRequest: ICheckout.PaymentSetupRequest, - requestOptions?: IRequest.Options, - ): Promise { - return getJsonResponse.call>( - this, - paymentSessionRequest, - requestOptions, - ); - } } export default PaymentSession; diff --git a/src/services/resource/checkout/payments.ts b/src/services/resource/checkout/payments.ts index 920f54f..2243cf8 100644 --- a/src/services/resource/checkout/payments.ts +++ b/src/services/resource/checkout/payments.ts @@ -18,34 +18,15 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; -import setApplicationInfo from "../../../helpers/setApplicationInfo"; import Service from "../../../service"; -import { IRequest } from "../../../typings/requestOptions"; import Resource from "../../resource"; -import PaymentsDetails from "./paymentsDetails"; -import PaymentsResult from "./paymentsResult"; class Payments extends Resource { - public readonly details: PaymentsDetails; - public readonly result: PaymentsResult; - public constructor(service: Service) { super( service, `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/payments`, ); - - this.details = new PaymentsDetails(service); - this.result = new PaymentsResult(service); - } - - public post(paymentsRequest: ICheckout.PaymentRequest, requestOptions?: IRequest.Options): Promise { - return getJsonResponse.call>( - this, - setApplicationInfo(paymentsRequest), - requestOptions, - ); } } diff --git a/src/services/resource/checkout/paymentsDetails.ts b/src/services/resource/checkout/paymentsDetails.ts index fab1ebe..46f29bd 100644 --- a/src/services/resource/checkout/paymentsDetails.ts +++ b/src/services/resource/checkout/paymentsDetails.ts @@ -18,9 +18,7 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; import Service from "../../../service"; -import { IRequest } from "../../../typings/requestOptions"; import Resource from "../../resource"; class PaymentsDetails extends Resource { @@ -30,15 +28,6 @@ class PaymentsDetails extends Resource { `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/payments/details`, ); } - - public post(paymentsDetailsRequest: ICheckout.DetailsRequest, requestOptions?: IRequest.Options): Promise { - return getJsonResponse.call>( - this, - paymentsDetailsRequest, - requestOptions - ); - } - } export default PaymentsDetails; diff --git a/src/services/resource/checkout/paymentsResult.ts b/src/services/resource/checkout/paymentsResult.ts index fbb8c2c..f3bb007 100644 --- a/src/services/resource/checkout/paymentsResult.ts +++ b/src/services/resource/checkout/paymentsResult.ts @@ -18,7 +18,6 @@ */ import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; import Service from "../../../service"; import Resource from "../../resource"; @@ -29,14 +28,6 @@ class PaymentsResult extends Resource { `${service.client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}/payments/result`, ); } - - public post(paymentResultRequest: ICheckout.PaymentVerificationRequest): Promise { - return getJsonResponse.call>( - this, - paymentResultRequest, - ); - } - } export default PaymentsResult; diff --git a/src/services/resource/modification/adjustAuthorisation.ts b/src/services/resource/modification/adjustAuthorisation.ts index 0bb2f7d..5037b6c 100644 --- a/src/services/resource/modification/adjustAuthorisation.ts +++ b/src/services/resource/modification/adjustAuthorisation.ts @@ -19,10 +19,6 @@ import Client from "../../../client"; import Service from "../../../service"; import Resource from "../../resource"; -import { GenericRequest } from "../../../typings/genericRequest"; -import { IRequest } from "../../../typings/requestOptions"; -import getJsonResponse from "../../../helpers/getJsonResponse"; -import setApplicationInfo from "../../../helpers/setApplicationInfo"; class AdjustAuthorisation extends Resource { public constructor(service: Service) { @@ -31,17 +27,6 @@ class AdjustAuthorisation extends Resource { `${service.client.config.endpoint}/pal/servlet/Payment/${Client.API_VERSION}/adjustAuthorisation`, ); } - - public post( - adjustAuthorisationRequest: GenericRequest, - requestOptions?: IRequest.Options, - ): Promise { - return getJsonResponse.call>( - this, - setApplicationInfo(adjustAuthorisationRequest), - requestOptions, - ); - } } export default AdjustAuthorisation; diff --git a/src/services/resource/modification/cancel.ts b/src/services/resource/modification/cancel.ts index 2453d4b..c91e5ac 100644 --- a/src/services/resource/modification/cancel.ts +++ b/src/services/resource/modification/cancel.ts @@ -19,10 +19,6 @@ import Client from "../../../client"; import Service from "../../../service"; import Resource from "../../resource"; -import { GenericRequest } from "../../../typings/genericRequest"; -import { IRequest } from "../../../typings/requestOptions"; -import getJsonResponse from "../../../helpers/getJsonResponse"; -import setApplicationInfo from "../../../helpers/setApplicationInfo"; class Cancel extends Resource { public constructor(service: Service) { @@ -31,17 +27,6 @@ class Cancel extends Resource { `${service.client.config.endpoint}/pal/servlet/Payment/${Client.API_VERSION}/cancel`, ); } - - public post( - cancelRequest: GenericRequest, - requestOptions?: IRequest.Options, - ): Promise { - return getJsonResponse.call>( - this, - setApplicationInfo(cancelRequest), - requestOptions, - ); - } } export default Cancel; diff --git a/src/services/resource/modification/cancelOrRefund.ts b/src/services/resource/modification/cancelOrRefund.ts index 87eac9a..7197182 100644 --- a/src/services/resource/modification/cancelOrRefund.ts +++ b/src/services/resource/modification/cancelOrRefund.ts @@ -19,10 +19,6 @@ import Client from "../../../client"; import Service from "../../../service"; import Resource from "../../resource"; -import getJsonResponse from "../../../helpers/getJsonResponse"; -import { IRequest } from "../../../typings/requestOptions"; -import { GenericRequest } from "../../../typings/genericRequest"; -import setApplicationInfo from "../../../helpers/setApplicationInfo"; class CancelOrRefund extends Resource { public constructor(service: Service) { @@ -31,18 +27,6 @@ class CancelOrRefund extends Resource { `${service.client.config.endpoint}/pal/servlet/Payment/${Client.API_VERSION}/cancelOrRefund`, ); } - - public post( - cancelOrRefundRequest: GenericRequest, - requestOptions?: IRequest.Options, - ): Promise { - return getJsonResponse.call>( - this, - setApplicationInfo(cancelOrRefundRequest), - requestOptions, - ); - } - } export default CancelOrRefund; diff --git a/src/services/resource/modification/capture.ts b/src/services/resource/modification/capture.ts index c3ef513..03afe8a 100644 --- a/src/services/resource/modification/capture.ts +++ b/src/services/resource/modification/capture.ts @@ -19,10 +19,6 @@ import Client from "../../../client"; import Service from "../../../service"; import Resource from "../../resource"; -import { GenericRequest } from "../../../typings/genericRequest"; -import { IRequest } from "../../../typings/requestOptions"; -import getJsonResponse from "../../../helpers/getJsonResponse"; -import setApplicationInfo from "../../../helpers/setApplicationInfo"; class Capture extends Resource { public constructor(service: Service) { @@ -31,17 +27,6 @@ class Capture extends Resource { `${service.client.config.endpoint}/pal/servlet/Payment/${Client.API_VERSION}/capture`, ); } - - public post( - captureRequest: GenericRequest, - requestOptions?: IRequest.Options, - ): Promise { - return getJsonResponse.call>( - this, - setApplicationInfo(captureRequest), - requestOptions, - ); - } } export default Capture; diff --git a/src/services/resource/modification/refund.ts b/src/services/resource/modification/refund.ts index 16a61b1..bb22c43 100644 --- a/src/services/resource/modification/refund.ts +++ b/src/services/resource/modification/refund.ts @@ -19,10 +19,6 @@ import Client from "../../../client"; import Service from "../../../service"; import Resource from "../../resource"; -import { GenericRequest } from "../../../typings/genericRequest"; -import { IRequest } from "../../../typings/requestOptions"; -import getJsonResponse from "../../../helpers/getJsonResponse"; -import setApplicationInfo from "../../../helpers/setApplicationInfo"; class Refund extends Resource { public constructor(service: Service) { @@ -31,17 +27,6 @@ class Refund extends Resource { `${service.client.config.endpoint}/pal/servlet/Payment/${Client.API_VERSION}/refund`, ); } - - public post( - refundRequest: GenericRequest, - requestOptions?: IRequest.Options, - ): Promise { - return getJsonResponse.call>( - this, - setApplicationInfo(refundRequest), - requestOptions, - ); - } } export default Refund; diff --git a/src/services/resource/modification/technicalCancel.ts b/src/services/resource/modification/technicalCancel.ts index 01e2fa1..e276ae7 100644 --- a/src/services/resource/modification/technicalCancel.ts +++ b/src/services/resource/modification/technicalCancel.ts @@ -19,10 +19,6 @@ import Resource from "../../resource"; import Client from "../../../client"; import Service from "../../../service"; -import { GenericRequest } from "../../../typings/genericRequest"; -import { IRequest } from "../../../typings/requestOptions"; -import getJsonResponse from "../../../helpers/getJsonResponse"; -import setApplicationInfo from "../../../helpers/setApplicationInfo"; class TechnicalCancel extends Resource { public constructor(service: Service) { @@ -31,17 +27,6 @@ class TechnicalCancel extends Resource { `${service.client.config.endpoint}/pal/servlet/Payment/${Client.API_VERSION}/technicalCancel`, ); } - - public post( - technicalCancelRequest: GenericRequest, - requestOptions?: IRequest.Options, - ): Promise { - return getJsonResponse.call>( - this, - setApplicationInfo(technicalCancelRequest), - requestOptions, - ); - } } export default TechnicalCancel; diff --git a/src/services/resource/payout/confirmThirdParty.ts b/src/services/resource/payout/confirmThirdParty.ts index d6f9589..9084d36 100644 --- a/src/services/resource/payout/confirmThirdParty.ts +++ b/src/services/resource/payout/confirmThirdParty.ts @@ -19,7 +19,6 @@ import Resource from "../../resource"; import Service from "../../../service"; import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class ConfirmThirdParty extends Resource { public constructor(service: Service) { @@ -28,13 +27,6 @@ class ConfirmThirdParty extends Resource { `${service.client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}/confirmThirdParty` ); } - - public post(request: IPayouts.ModifyRequest): Promise { - return getJsonResponse.call>( - this, - request - ); - } } export default ConfirmThirdParty; diff --git a/src/services/resource/payout/declineThirdParty.ts b/src/services/resource/payout/declineThirdParty.ts index 89e3c1a..3e2a81b 100644 --- a/src/services/resource/payout/declineThirdParty.ts +++ b/src/services/resource/payout/declineThirdParty.ts @@ -19,7 +19,6 @@ import Resource from "../../resource"; import Service from "../../../service"; import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class DeclineThirdParty extends Resource { public constructor(service: Service) { @@ -28,13 +27,6 @@ class DeclineThirdParty extends Resource { `${service.client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}/declineThirdParty` ); } - - public post(request: IPayouts.ModifyRequest): Promise { - return getJsonResponse.call>( - this, - request - ); - } } export default DeclineThirdParty; diff --git a/src/services/resource/payout/payout.ts b/src/services/resource/payout/payout.ts index 097ab68..e3893f0 100644 --- a/src/services/resource/payout/payout.ts +++ b/src/services/resource/payout/payout.ts @@ -19,7 +19,6 @@ import Resource from "../../resource"; import Service from "../../../service"; import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class Payout extends Resource { public constructor(service: Service) { @@ -28,13 +27,6 @@ class Payout extends Resource { `${service.client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}/payout` ); } - - public post(request: IPayouts.PayoutRequest): Promise { - return getJsonResponse.call>( - this, - request - ); - } } export default Payout; diff --git a/src/services/resource/payout/storeDetail.ts b/src/services/resource/payout/storeDetail.ts index c729df2..3f90df2 100644 --- a/src/services/resource/payout/storeDetail.ts +++ b/src/services/resource/payout/storeDetail.ts @@ -19,7 +19,6 @@ import Resource from "../../resource"; import Service from "../../../service"; import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class StoreDetail extends Resource { public constructor(service: Service) { @@ -28,14 +27,6 @@ class StoreDetail extends Resource { `${service.client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}/storeDetail` ); } - - public post(request: IPayouts.StoreDetailRequest): Promise { - return getJsonResponse.call>( - this, - request - ); - } - } export default StoreDetail; diff --git a/src/services/resource/payout/storeDetailAndSubmitThirdParty.ts b/src/services/resource/payout/storeDetailAndSubmitThirdParty.ts index bf7c695..8d2a01c 100644 --- a/src/services/resource/payout/storeDetailAndSubmitThirdParty.ts +++ b/src/services/resource/payout/storeDetailAndSubmitThirdParty.ts @@ -19,7 +19,6 @@ import Resource from "../../resource"; import Service from "../../../service"; import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class StoreDetailAndSubmitThirdParty extends Resource { public constructor(service: Service) { @@ -28,14 +27,6 @@ class StoreDetailAndSubmitThirdParty extends Resource { `${service.client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}/storeDetailAndSubmitThirdParty` ); } - - public post(request: IPayouts.StoreDetailAndSubmitRequest): Promise { - return getJsonResponse.call>( - this, - request - ); - } - } export default StoreDetailAndSubmitThirdParty; diff --git a/src/services/resource/payout/submitThirdParty.ts b/src/services/resource/payout/submitThirdParty.ts index 4ae0d07..b011621 100644 --- a/src/services/resource/payout/submitThirdParty.ts +++ b/src/services/resource/payout/submitThirdParty.ts @@ -19,7 +19,6 @@ import Resource from "../../resource"; import Service from "../../../service"; import Client from "../../../client"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class SubmitThirdParty extends Resource { public constructor(service: Service) { @@ -28,13 +27,6 @@ class SubmitThirdParty extends Resource { `${service.client.config.endpoint}/pal/servlet/Payout/${Client.API_VERSION}/submitThirdParty` ); } - - public post(request: IPayouts.SubmitRequest): Promise { - return getJsonResponse.call>( - this, - request - ); - } } export default SubmitThirdParty; diff --git a/src/services/resource/recurring/disable.ts b/src/services/resource/recurring/disable.ts index 2fe2ad2..0f49705 100644 --- a/src/services/resource/recurring/disable.ts +++ b/src/services/resource/recurring/disable.ts @@ -20,7 +20,6 @@ import Client from "../../../client"; import Service from "../../../service"; import Resource from "../../resource"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class Disable extends Resource { public constructor(service: Service) { @@ -29,14 +28,6 @@ class Disable extends Resource { `${service.client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}/disable`, ); } - - public post(request: IRecurring.DisableRequest): Promise { - return getJsonResponse.call>( - this, - request, - ); - } - } export default Disable; diff --git a/src/services/resource/recurring/listRecurringDetails.ts b/src/services/resource/recurring/listRecurringDetails.ts index 2c79f64..d7aaac4 100644 --- a/src/services/resource/recurring/listRecurringDetails.ts +++ b/src/services/resource/recurring/listRecurringDetails.ts @@ -20,7 +20,6 @@ import Client from "../../../client"; import Service from "../../../service"; import Resource from "../../resource"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class ListRecurringDetails extends Resource { public constructor(service: Service) { @@ -29,14 +28,6 @@ class ListRecurringDetails extends Resource { `${service.client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}/listRecurringDetails`, ); } - - public post(request: IRecurring.RecurringDetailsRequest): Promise { - return getJsonResponse.call>( - this, - request, - ); - } - } export default ListRecurringDetails; diff --git a/src/services/resource/recurring/scheduleAccountUpdater.ts b/src/services/resource/recurring/scheduleAccountUpdater.ts index 9972810..11fa87a 100644 --- a/src/services/resource/recurring/scheduleAccountUpdater.ts +++ b/src/services/resource/recurring/scheduleAccountUpdater.ts @@ -20,7 +20,6 @@ import Client from "../../../client"; import Service from "../../../service"; import Resource from "../../resource"; -import getJsonResponse from "../../../helpers/getJsonResponse"; class ScheduleAccountUpdater extends Resource { public constructor(service: Service) { @@ -29,13 +28,6 @@ class ScheduleAccountUpdater extends Resource { `${service.client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}/scheduleAccountUpdater`, ); } - - public post(request: IRecurring.ScheduleAccountUpdaterRequest): Promise { - return getJsonResponse.call>( - this, - request, - ); - } } export default ScheduleAccountUpdater; diff --git a/src/services/terminalCloudAPI.ts b/src/services/terminalCloudAPI.ts index 845ed88..08c55fa 100644 --- a/src/services/terminalCloudAPI.ts +++ b/src/services/terminalCloudAPI.ts @@ -61,12 +61,12 @@ class TerminalCloudAPI extends ApiKeyAuthenticatedService { public async(terminalApiRequest: TerminalApiRequest): Promise { const request = TerminalCloudAPI.setApplicationInfo(terminalApiRequest); - return getJsonResponse.call>(this.terminalApiAsync, request); + return getJsonResponse(this.terminalApiAsync, request); } public async sync(terminalApiRequest: TerminalApiRequest): Promise { const request = TerminalCloudAPI.setApplicationInfo(terminalApiRequest); - const response = await getJsonResponse.call>( + const response = await getJsonResponse( this.terminalApiSync, request, ); diff --git a/src/services/terminalLocalAPI.ts b/src/services/terminalLocalAPI.ts index 86481cc..b13e45b 100644 --- a/src/services/terminalLocalAPI.ts +++ b/src/services/terminalLocalAPI.ts @@ -63,7 +63,7 @@ class TerminalLocalAPI extends ApiKeyAuthenticatedService { saleToPOIRequest: saleToPoiSecuredMessage, }, "TerminalApiSecuredRequest"); - const jsonResponse = await getJsonResponse.call>( + const jsonResponse = await getJsonResponse( this.localRequest, securedPaymentRequest ); diff --git a/src/typings/HTTPMethod.ts b/src/typings/HTTPMethod.ts deleted file mode 100644 index 5f6eb44..0000000 --- a/src/typings/HTTPMethod.ts +++ /dev/null @@ -1,53 +0,0 @@ -export enum HTTPMethod { - /** - * The `CONNECT` method establishes a tunnel to the server identified by the - * target resource. - */ - CONNECT = 'CONNECT', - - /** - * The `DELETE` method deletes the specified resource. - */ - DELETE = 'DELETE', - - /** - * The `GET` method requests a representation of the specified resource. - * Requests using GET should only retrieve data. - */ - GET = 'GET', - - /** - * The `HEAD` method asks for a response identical to that of a GET request, - * but without the response body. - */ - HEAD = 'HEAD', - - /** - * The `OPTIONS` method is used to describe the communication options for the - * target resource. - */ - OPTIONS = 'OPTIONS', - - /** - * The PATCH method is used to apply partial modifications to a resource. - */ - PATCH = 'PATCH', - - /** - * The `POST` method is used to submit an entity to the specified resource, - * often causing a change in state or side effects on the server. - */ - POST = 'POST', - - /** - * The `PUT` method replaces all current representations of the target - * resource with the request payload. - */ - PUT = 'PUT', - - /** - * The `TRACE` method performs a message loop-back test along the path to the - * target resource. - */ - TRACE = 'TRACE' -} diff --git a/src/typings/genericRequest.ts b/src/typings/genericRequest.ts deleted file mode 100644 index e0afee6..0000000 --- a/src/typings/genericRequest.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ApplicationInfo } from "./applicationInfo"; - -interface AppInfo { applicationInfo?: ApplicationInfo } -export type GenericRequest = T & AppInfo; diff --git a/src/typings/requestOptions.ts b/src/typings/requestOptions.ts index 300a88c..69b2550 100644 --- a/src/typings/requestOptions.ts +++ b/src/typings/requestOptions.ts @@ -25,7 +25,6 @@ import * as https from "https"; export namespace IRequest { export type Options = https.RequestOptions & { - id?: string; idempotencyKey?: string; }; } From c5d4a200c875f88aeb15015931b25bfa47724810 Mon Sep 17 00:00:00 2001 From: wouterboe Date: Tue, 20 Apr 2021 15:36:43 +0200 Subject: [PATCH 2/2] updated github checkout action to v2 to fix coveralls parallel action --- .github/workflows/coveralls.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index abb0aef..f205237 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Use Node.js 12.x uses: actions/setup-node@v1