diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index e262076ae..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "04:00" - open-pull-requests-limit: 10 - reviewers: - - "zaiddreakh" - - "maassenbas" - - "AlexandrosMor" - - "peterojo" - - "wboereboom" \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 871cc82d5..a32cbed7a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 225f56999..fb3a1280c 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js 16.x - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: 16.x diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index fa7c536cd..f065995f7 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -12,9 +12,9 @@ jobs: node-version: [12.x, 14.x, 16.x] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: npm install, lint and test diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml index f1b5a18c4..24c8d87ec 100644 --- a/.github/workflows/npmpublish.yml +++ b/.github/workflows/npmpublish.yml @@ -9,8 +9,8 @@ jobs: publish-npm: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: 14 registry-url: https://registry.npmjs.org/ diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index bfa73fd2f..b669c2605 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # Disabling shallow clone to improve relevancy of SonarCloud reporting fetch-depth: 0 diff --git a/.npmignore b/.npmignore index 115871f47..51e99be2c 100644 --- a/.npmignore +++ b/.npmignore @@ -1,11 +1,16 @@ src/ -.babelrc .eslintignore -.eslintrc.json +.eslintrc.js .gitignore -.travis.yml +.release-it.json +CODE_OF_CONDUCT.md +CONTRIBUTING.md +Makefile +config.ts +renovate.json tsconfig.json jest.config.js tslint.json -webpack.config.js .github +/**/__mocks__/ +/**/__tests__/ diff --git a/Makefile b/Makefile index 2acd12e77..85f938fef 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,24 @@ generator:=typescript-node -openapi-generator-cli:=docker run --user $(shell id -u):$(shell id -g) --rm -v ${PWD}:/local -w /local openapitools/openapi-generator-cli:v5.4.0 -services:=binlookup checkout storedValue terminalManagement payments recurring payouts management legalEntityManagement balancePlatform platformsAccount platformsFund platformsNotificationConfiguration platformsHostedOnboardingPage transfer +openapi-generator-version:=5.4.0 +openapi-generator-url:=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/$(openapi-generator-version)/openapi-generator-cli-$(openapi-generator-version).jar +openapi-generator-jar:=build/openapi-generator-cli.jar +openapi-generator-cli:=java -jar $(openapi-generator-jar) +services:=balancePlatform binlookup checkout dataProtection legalEntityManagement management payments payouts platformsAccount platformsFund platformsHostedOnboardingPage platformsNotificationConfiguration recurring storedValue terminalManagement transfer # Generate models (for each service) models: $(services) binlookup: spec=BinLookupService-v52 checkout: spec=CheckoutService-v69 +dataProtection: spec=DataProtectionService-v1 storedValue: spec=StoredValueService-v46 terminalManagement: spec=TfmAPIService-v1 payments: spec=PaymentService-v68 recurring: spec=RecurringService-v68 payouts: spec=PayoutService-v68 management: spec=ManagementService-v1 +managementapi: spec=ManagementService-v1 +managementapi: service=management legalEntityManagement: spec=LegalEntityService-v2 balancePlatform: spec=BalancePlatformService-v2 platformsAccount: spec=AccountService-v6 @@ -21,28 +27,48 @@ platformsNotificationConfiguration: spec=NotificationConfigurationService-v6 platformsHostedOnboardingPage: spec=HopService-v6 transfer: spec=TransferService-v3 -$(services): build/spec +$(services): build/spec $(openapi-generator-jar) rm -rf src/typings/$@ build/model $(openapi-generator-cli) generate \ -i build/spec/json/$(spec).json \ -g $(generator) \ -t templates/typescript \ -o build \ - --global-property models,supportingFiles + --global-property models,supportingFiles \ + --additional-properties=serviceName=$@ mv build/model src/typings/$@ +# Service +managementapi: build/spec $(openapi-generator-jar) + $(openapi-generator-cli) generate \ + -i build/spec/json/$(spec).json \ + -g $(generator) \ + -t templates/typescript \ + -o build \ + --api-package $(service) \ + --model-package typings/$(service) \ + --global-property apis \ + --additional-properties=serviceName=$(service) + cp build/$(service)/* src/services/$(service) + sed -i.bak '/RestServiceError/d' src/services/$(service)/* + rm src/services/$(service)/*.bak + # Checkout spec (and patch version) build/spec: git clone https://github.com/Adyen/adyen-openapi.git build/spec - sed -i 's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json + perl -i -pe's/"openapi" : "3.[0-9].[0-9]"/"openapi" : "3.0.0"/' build/spec/json/*.json # Extract templates (copy them for modifications) -templates: +templates: $(openapi-generator-jar) $(openapi-generator-cli) author template -g $(generator) -o build/templates/typescript +# Download the generator +$(openapi-generator-jar): + wget --quiet -o /dev/null $(openapi-generator-url) -O $(openapi-generator-jar) + # Discard generated artifacts and changed models clean: - git checkout src/typings - git clean -f -d src/typings + git checkout src/typings src/services/management + git clean -f -d src/typings src/services/management .PHONY: templates models $(services) diff --git a/README.md b/README.md index c932dd168..8530be45b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ + +![Node js](https://user-images.githubusercontent.com/62436079/207373079-9cf9377f-f530-4b02-a515-9b64ef7b06e7.png) + # Adyen Node.js API Library ![Node.js CI](https://github.com/Adyen/adyen-node-api-library/workflows/Node.js%20CI/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/Adyen/adyen-node-api-library/badge.svg?branch=main)](https://coveralls.io/github/Adyen/adyen-node-api-library?branch=main) @@ -5,39 +8,38 @@ ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@adyen/api-library.svg) [![Version](https://img.shields.io/npm/v/@adyen/api-library.svg)](https://www.npmjs.com/package/@adyen/api-library) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Adyen_adyen-node-api-library&metric=alert_status)](https://sonarcloud.io/dashboard?id=Adyen_adyen-node-api-library) -[![Total alerts](https://img.shields.io/lgtm/alerts/g/Adyen/adyen-node-api-library.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Adyen/adyen-node-api-library/alerts/) -[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Adyen/adyen-node-api-library.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Adyen/adyen-node-api-library/context:javascript) This is the officially supported NodeJS library for using Adyen's APIs. -## Integration +## Supported API versions The Library supports all APIs under the following services: - -* [BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v52/overview): The BIN Lookup API provides endpoints for retrieving information based on a given BIN. Current supported version: **v52** -* [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v69/overview): Our latest integration for accepting online payments. Current supported version: **v69** -* [Configuration API](https://docs.adyen.com/api-explorer/#/balanceplatform/v2/overview): The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. Current supported verison: **v2** -* [Legal Entity Management API](https://docs.adyen.com/api-explorer/#/legalentity/v2/overview): Manage legal entities that contain information required for verification. Current supported version: **v2** -* [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference): Our point-of-sale integration. -* [Management API](https://docs.adyen.com/api-explorer/#/ManagementService/v1/overview): Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. Current supported version **v1** -* [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v68/overview): Our classic integration for online payments. Current supported version: **v68** -* [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v68/overview): Endpoints for sending funds to your customers. Current supported version: **v68** -* [Platforms APIs](https://docs.adyen.com/platforms/api): Set of APIs when using Adyen for Platforms. This API is used for the classic integration. - * [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) Current supported version: **v6** - * [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) Current supported version: **v6** - * [Hosted onboarding API](https://docs.adyen.com/api-explorer/#/Hop/v6/overview): Current supported version: **v6** - * [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) Current supported version: **v6** -* [Platforms Notifications Webhooks](https://docs.adyen.com/api-explorer/#/NotificationService/v6/overview) Current supported version: **v6** -* [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview): Endpoints for managing your point-of-sale payment terminals. Current supported version **v1** -* [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v68/overview): Endpoints for managing saved payment details. Current supported version: **v68** -* [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api): Manage both online and point-of-sale gift cards and other stored-value cards. Current supported version: **v46** -* [Transfers API](https://docs.adyen.com/api-explorer/transfers/3/overview) The Transfers API provides endpoints that you can use to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. **v3** - - +| API | Description | Service Name | Supported version | +| --- | ----------- | ------------ | ----------------- | +|[BIN lookup API](https://docs.adyen.com/api-explorer/#/BinLookup/v52/overview) | The BIN Lookup API provides endpoints for retrieving information based on a given BIN. | BinLookup | **v52** | +| [Checkout API](https://docs.adyen.com/api-explorer/#/CheckoutService/v69/overview)| Our latest integration for accepting online payments. | CheckoutAPI | **v69** | +| [Configuration API](https://docs.adyen.com/api-explorer/#/balanceplatform/v2/overview)| The Configuration API enables you to create a platform where you can onboard your users as account holders and create balance accounts, cards, and business accounts. | BalancePlatform | **v2** | +| [DataProtection API](https://docs.adyen.com/development-resources/data-protection-api) | Adyen Data Protection API provides a way for you to process [Subject Erasure Requests](https://gdpr-info.eu/art-17-gdpr/) as mandated in GDPR. Use our API to submit a request to delete shopper's data, including payment details and other related information (for example, delivery address or shopper email) | DataProtection | **v1** | +| [Legal Entity Management API](https://docs.adyen.com/api-explorer/#/legalentity/v2/overview)| Manage legal entities that contain information required for verification. | LegalEntityManagement | **v2** | +| [Local/Cloud-based Terminal API](https://docs.adyen.com/point-of-sale/terminal-api-reference)| Our point-of-sale integration. | TerminalLocalAPI or TerminalCloudAPI | - | +| [Management API](https://docs.adyen.com/api-explorer/#/ManagementService/v1/overview)| Configure and manage your Adyen company and merchant accounts, stores, and payment terminals. | Management | **v1** | +| [Payments API](https://docs.adyen.com/api-explorer/#/Payment/v68/overview)| Our classic integration for online payments. | ClassicIntegrationAPI | **v68** | +| [Payouts API](https://docs.adyen.com/api-explorer/#/Payout/v68/overview)| Endpoints for sending funds to your customers. | Payout | **v68** | +| [Platforms APIs](https://docs.adyen.com/platforms/api)| Set of APIs when using Adyen for Platforms. This API is used for the classic integration. | Platforms | - | + | [Account API](https://docs.adyen.com/api-explorer/#/Account/v6/overview) | *Platforms subclass* | Account | **v6** | + | [Fund API](https://docs.adyen.com/api-explorer/#/Fund/v6/overview) | *Platforms subclass* | Fund | **v6** | + | [Hosted onboarding API](https://docs.adyen.com/api-explorer/#/Hop/v6/overview)| *Platforms subclass* | HostedOnboardingPage | **v6** | + | [Notification Configuration API](https://docs.adyen.com/api-explorer/#/NotificationConfigurationService/v6/overview) | *Platforms subclass* | NotificationConfiguration | **v6** | +| [Platforms Notifications Webhooks](https://docs.adyen.com/api-explorer/#/NotificationService/v6/overview) || *Models only* | **v6** | +| [POS Terminal Management API](https://docs.adyen.com/api-explorer/#/postfmapi/v1/overview)| Endpoints for managing your point-of-sale payment terminals. | TerminalManagement | **v1** | +| [Recurring API](https://docs.adyen.com/api-explorer/#/Recurring/v68/overview)| Endpoints for managing saved payment details. | Recurring | **v68** | +| [Stored Value API](https://docs.adyen.com/payment-methods/gift-cards/stored-value-api) | Manage both online and point-of-sale gift cards and other stored-value cards. | StoredValue | **v46** | +| [Transfers API](https://docs.adyen.com/api-explorer/transfers/3/overview) | The Transfers API provides endpoints that can be used to get information about all your transactions, move funds within your balance platform or send funds from your balance platform to a transfer instrument. | Transfers | **v3** | +| [Webhooks](https://docs.adyen.com/api-explorer/Webhooks/1/overview) | Adyen uses webhooks to send notifications about payment status updates, newly available reports, and other events that can be subscribed to. For more information, refer to our [documentation](https://docs.adyen.com/development-resources/webhooks). | *Models only* | **v1** | For more information, refer to our [documentation](https://docs.adyen.com/) or the [API Explorer](https://docs.adyen.com/api-explorer/). ## Prerequisites -- [Adyen test account](https://docs.adyen.com/get-started-with-adyen) +- [Adyen test account](https://docs.adyen.com/get-started-with-adyen). To start using Adyen APIs, you will need a Merchant Account. - [API key](https://docs.adyen.com/development-resources/api-credentials#generate-api-key). For testing, your API credential needs to have the [API PCI Payments role](https://docs.adyen.com/development-resources/api-credentials#roles). - Node 12 or higher @@ -56,21 +58,93 @@ Alternatively, you can download the [release on GitHub](https://github.com/Adyen ## Using the library -### General use with API key +### Client initialisation +#### General use with API key Set up the client as a singleton resource; you can then use it to create service objects for the API calls that you make to Adyen: ```typescript - const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"}); + const { Client } = require('@adyen/api-library'); + const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"}); ``` -### General use with API key for live environment +#### General use with API key for live environment ```typescript - const client = new Client({apiKey: "YOUR_API_KEY", environment: "LIVE"}); + const { Client } = require('@adyen/api-library'); + const client = new Client({apiKey: "YOUR_API_KEY", environment: "LIVE"}); ``` -### General use with basic auth +#### General use with basic auth ```typescript - const client = new Client({username: "YOUR_USERNAME", password: "YOUR_PASSWORD", environment: "TEST"}); + const { Client } = require('@adyen/api-library'); + const client = new Client({username: "YOUR_USERNAME", password: "YOUR_PASSWORD", environment: "TEST"}); ``` + +### Consuming Services +Every API the library supports is represented by a service object. The name of the service matching the corresponding API is listed in the [Integrations](#supported-api-versions) section of this document. +```javascript + const { Client, CheckoutAPI } = require('@adyen/api-library'); + const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"}); + + const paymentRequest = { + amount: { + currency: "USD", + value: 1000 // value in minor units + }, + reference: "Your order number", + paymentMethod: { + type: "scheme", + encryptedCardNumber: "test_4111111111111111", + encryptedExpiryMonth: "test_03", + encryptedExpiryYear: "test_2030", + encryptedSecurityCode: "test_737" + }, + shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j", + storePaymentMethod: true, + shopperInteraction: "Ecommerce", + recurringProcessingModel: "CardOnFile", + returnUrl: "https://your-company.com/...", + merchantAccount: "YOUR_MERCHANT_ACCOUNT" + }; + const checkoutAPI = new CheckoutAPI(client); + checkoutAPI.payments(paymentRequest) + .then( paymentResponse => console.log(paymentResponse.pspReference)) + .catch(error => console.log(error)); +``` + +Alternatively you can make use of the Types included in this library using Typescript, and/or use the async syntax: +```typescript + const { Client, CheckoutAPI } = require('@adyen/api-library'); + const client = new Client({apiKey: "YOUR_API_KEY", environment: "TEST"}); + + import { Types } from '@adyen/api-library'; + + const doPaymentsRequest = async () => { + const paymentRequest : Types.checkout.PaymentRequest = { + amount: { + currency: "USD", + value: 1000 // value in minor units + }, + reference: "Your order number", + paymentMethod: { + type: Types.checkout.CardDetails.TypeEnum.Scheme, + encryptedCardNumber: "test_4111111111111111", + encryptedExpiryMonth: "test_03", + encryptedExpiryYear: "test_2030", + encryptedSecurityCode: "test_737" + }, + shopperReference: "YOUR_UNIQUE_SHOPPER_ID_IOfW3k9G2PvXFu2j", + storePaymentMethod: true, + shopperInteraction: Types.checkout.PaymentRequest.ShopperInteractionEnum.Ecommerce, + recurringProcessingModel: Types.checkout.PaymentRequest.RecurringProcessingModelEnum.CardOnFile, + returnUrl: "https://your-company.com/...", + merchantAccount: "YOUR_MERCHANT_ACCOUNT" + }; + const checkoutAPI = new CheckoutAPI(client); + const paymentResponse : Types.checkout.PaymentResponse = await checkoutAPI.payments(paymentRequest); + console.log(paymentResponse.pspReference); + } + + doPaymentsRequest(); +``` ### Custom HTTP Client Configuration By default, NodeJS [https](https://nodejs.org/api/https.html) will be used to submit requests to the API. But you can change that by injecting your own HttpClient on your client instance. In the example below, we use `axios`: diff --git a/package.json b/package.json index d558398eb..fc70d913d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adyen/api-library", - "version": "12.1.0", + "version": "12.2.0", "description": "The Adyen API Library for NodeJS enables you to work with Adyen APIs.", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", @@ -35,30 +35,30 @@ "author": "Ricardo Ambrogi", "license": "MIT", "devDependencies": { - "@types/jest": "27.5.0", + "@types/jest": "27.5.2", "@types/nock": "11.1.0", - "@typescript-eslint/eslint-plugin": "5.41.0", - "@typescript-eslint/parser": "5.41.0", + "@typescript-eslint/eslint-plugin": "5.43.0", + "@typescript-eslint/parser": "5.45.0", "acorn": "^8.0.1", "coveralls": "3.1.1", "dotenv": "^16.0.0", - "eslint": "8.26.0", + "eslint": "8.28.0", "jest": "^27.0.6", "jest-ts-auto-mock": "^2.0.0", "kind-of": "^6.0.3", "minimist": ">=1.2.3", - "nock": "13.2.9", + "nock": "13.3.0", "release-it": "15.5.0", "ts-auto-mock": "^3.3.5", "ts-jest": "^27.0.4", - "ts-loader": "8.0.10", + "ts-loader": "9.4.2", "ttypescript": "^1.5.10", - "typescript": "4.8.4" + "typescript": "4.9.4" }, "dependencies": { "https-proxy-agent": "5.0.1" }, "optionalDependencies": { - "@types/node": "14.0.9" + "@types/node": "14.18.36" } } diff --git a/renovate.json b/renovate.json new file mode 100644 index 000000000..39a2b6e9a --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ] +} diff --git a/src/__mocks__/base.ts b/src/__mocks__/base.ts index b2d47e2ce..105342d9a 100644 --- a/src/__mocks__/base.ts +++ b/src/__mocks__/base.ts @@ -50,7 +50,8 @@ export const createClient = (apiKey = process.env.ADYEN_API_KEY): Client => { config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_TEST; config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_TEST; config.legalEntityManagementEndpoint = Client.LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_TEST; - config.transfersEndpoint = Client.TRANSFERS_API_VERSION_TEST; + config.transfersEndpoint = Client.TRANSFERS_API_ENDPOINT_TEST; + config.dataProtectionEndpoint = Client.DATA_PROTECTION_API_ENDPOINT_TEST; return new Client({ config }); }; diff --git a/src/__tests__/balancePlatform.spec.ts b/src/__tests__/balancePlatform.spec.ts index e52a70a61..e86eb182f 100644 --- a/src/__tests__/balancePlatform.spec.ts +++ b/src/__tests__/balancePlatform.spec.ts @@ -2,13 +2,13 @@ import nock from "nock"; import Client from "../client"; import { createClient } from "../__mocks__/base"; import BalancePlatform from "../services/balancePlatform"; -import * as models from "../typings/balancePlatform/models"; +import { balancePlatform } from "../typings"; import { AccountHolderUpdate } from "../services/balancePlaftform/accountHolders"; import { SweepConfigurationV2Create, SweepConfigurationV2Update } from "../services/balancePlaftform/balanceAccounts"; import { TransactionRuleInfoUpdate } from "../services/balancePlaftform/transactionRules"; let client: Client; -let balancePlatform: BalancePlatform; +let balancePlatformService: BalancePlatform; let scope: nock.Scope; beforeEach((): void => { @@ -17,7 +17,7 @@ beforeEach((): void => { } client = createClient(); scope = nock(`${client.config.balancePlatformEndpoint}/${Client.BALANCE_PLATFORM_API_VERSION}`); - balancePlatform = new BalancePlatform(client); + balancePlatformService = new BalancePlatform(client); }); afterEach(() => { @@ -55,7 +55,7 @@ describe("Balance Platform", (): void => { "id": "AH3227C223222B5CMD2SXFKGT", "status": "active" }); - const request: models.AccountHolderInfo = { + const request: balancePlatform.AccountHolderInfo = { "balancePlatform": "YOUR_BALANCE_PLATFORM", "description": "S.Hopper - Staff 123", "legalEntityId": "LE322KT223222D5FJ7THR293F", @@ -63,7 +63,7 @@ describe("Balance Platform", (): void => { "email": "s.hopper@example.com", "phone": { "number": "+315551231234", - "type": models.Phone.TypeEnum.Mobile + "type": balancePlatform.Phone.TypeEnum.Mobile }, "address": { "city": "Amsterdam", @@ -75,7 +75,7 @@ describe("Balance Platform", (): void => { } }; - const response: models.AccountHolder = await balancePlatform.AccountHolders.create(request); + const response: balancePlatform.AccountHolder = await balancePlatformService.AccountHolders.create(request); expect(response.id).toBe("AH3227C223222B5CMD2SXFKGT"); expect(response.legalEntityId).toBe("LE322KT223222D5FJ7THR293F"); @@ -104,7 +104,7 @@ describe("Balance Platform", (): void => { "status": "Active" }); - const response: models.AccountHolder = await balancePlatform.AccountHolders.retrieve("AH32272223222B5CM4MWJ892H"); + const response: balancePlatform.AccountHolder = await balancePlatformService.AccountHolders.retrieve("AH32272223222B5CM4MWJ892H"); expect(response.id).toBe("AH32272223222B5CM4MWJ892H"); expect(response.balancePlatform).toBe("YOUR_BALANCE_PLATFORM"); @@ -133,11 +133,11 @@ describe("Balance Platform", (): void => { "status": "Suspended" }); const request: AccountHolderUpdate = { - status: models.AccountHolder.StatusEnum.Suspended, + status: balancePlatform.AccountHolder.StatusEnum.Suspended, legalEntityId: "LE322KT223222D5FJ7THR293F", }; - const response: models.AccountHolder = await balancePlatform.AccountHolders.update("AH32272223222B5CM4MWJ892H", request); + const response: balancePlatform.AccountHolder = await balancePlatformService.AccountHolders.update("AH32272223222B5CM4MWJ892H", request); expect(response.status).toBe("Suspended"); }); @@ -169,7 +169,7 @@ describe("Balance Platform", (): void => { "hasPrevious": false }); - const response: models.PaginatedBalanceAccountsResponse = await balancePlatform.AccountHolders.listBalanceAccounts("AH32272223222B5CM4MWJ892H", { + const response: balancePlatform.PaginatedBalanceAccountsResponse = await balancePlatformService.AccountHolders.listBalanceAccounts("AH32272223222B5CM4MWJ892H", { params: { "limit": "5", "offset": "10" @@ -198,12 +198,12 @@ describe("Balance Platform", (): void => { "id": balanceAccountId, "status": "active" }); - const request: models.BalanceAccountInfo = { + const request: balancePlatform.BalanceAccountInfo = { "accountHolderId": "AH32272223222B59K6ZKBBFNQ", "description": "S.Hopper - Main balance account" }; - const response: models.BalanceAccount = await balancePlatform.BalanceAccounts.create(request); + const response: balancePlatform.BalanceAccount = await balancePlatformService.BalanceAccounts.create(request); expect(response.id).toBe(balanceAccountId); }); @@ -237,7 +237,7 @@ describe("Balance Platform", (): void => { ] }); - const response: models.BalanceSweepConfigurationsResponse = await balancePlatform.BalanceAccounts.listSweeps(balanceAccountId, { + const response: balancePlatform.BalanceSweepConfigurationsResponse = await balancePlatformService.BalanceAccounts.listSweeps(balanceAccountId, { params: { "limit": "5", "offset": "10" @@ -276,13 +276,13 @@ describe("Balance Platform", (): void => { }, "currency": "EUR", "schedule": { - "type": models.SweepSchedule.TypeEnum.Balance + "type": balancePlatform.SweepSchedule.TypeEnum.Balance }, - "type": models.SweepConfigurationV2.TypeEnum.Pull, - "status": models.SweepConfigurationV2.StatusEnum.Active + "type": balancePlatform.SweepConfigurationV2.TypeEnum.Pull, + "status": balancePlatform.SweepConfigurationV2.StatusEnum.Active }; - const response: models.SweepConfigurationV2 = await balancePlatform.BalanceAccounts.createSweep(balanceAccountId, request); + const response: balancePlatform.SweepConfigurationV2 = await balancePlatformService.BalanceAccounts.createSweep(balanceAccountId, request); expect(response.id).toBe(sweepId); expect(response.triggerAmount!.value).toBe(50000); @@ -291,7 +291,7 @@ describe("Balance Platform", (): void => { it("should support DELETE /balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", async (): Promise => { scope.delete(`/balanceAccounts/${balanceAccountId}/sweeps/${sweepId}`).reply(204); - await balancePlatform.BalanceAccounts.deleteSweep(balanceAccountId, sweepId); + await balancePlatformService.BalanceAccounts.deleteSweep(balanceAccountId, sweepId); }); it("should support GET /balanceAccounts/{balanceAccountId}/sweeps/{sweepId}", async (): Promise => { @@ -317,7 +317,7 @@ describe("Balance Platform", (): void => { "currency": "EUR" }); - const response: models.SweepConfigurationV2 = await balancePlatform.BalanceAccounts.retrieveSweep(balanceAccountId, sweepId); + const response: balancePlatform.SweepConfigurationV2 = await balancePlatformService.BalanceAccounts.retrieveSweep(balanceAccountId, sweepId); expect(response.id).toBe(sweepId); expect(response.status).toBe("active"); @@ -342,10 +342,10 @@ describe("Balance Platform", (): void => { "status": "inactive" }); const request: SweepConfigurationV2Update = { - "status": models.SweepConfigurationV2.StatusEnum.Inactive + "status": balancePlatform.SweepConfigurationV2.StatusEnum.Inactive }; - const response: models.SweepConfigurationV2 = await balancePlatform.BalanceAccounts.updateSweep(balanceAccountId, sweepId, request); + const response: balancePlatform.SweepConfigurationV2 = await balancePlatformService.BalanceAccounts.updateSweep(balanceAccountId, sweepId, request); expect(response.status).toBe("inactive"); }); @@ -367,7 +367,7 @@ describe("Balance Platform", (): void => { "status": "Active" }); - const response: models.BalanceAccount = await balancePlatform.BalanceAccounts.retrieve(balanceAccountId); + const response: balancePlatform.BalanceAccount = await balancePlatformService.BalanceAccounts.retrieve(balanceAccountId); expect(response.id).toBe(balanceAccountId); expect(response.status).toBe("Active"); @@ -392,13 +392,13 @@ describe("Balance Platform", (): void => { "status": "active", "timeZone": "Europe/Amsterdam" }); - const request: models.BalanceAccountUpdateRequest = { + const request: balancePlatform.BalanceAccountUpdateRequest = { "description": "Testing", - "status": models.BalanceAccountUpdateRequest.StatusEnum.Active, + "status": balancePlatform.BalanceAccountUpdateRequest.StatusEnum.Active, "timeZone": "Europe/Amsterdam" }; - const response: models.BalanceAccount = await balancePlatform.BalanceAccounts.update(balanceAccountId, request); + const response: balancePlatform.BalanceAccount = await balancePlatformService.BalanceAccounts.update(balanceAccountId, request); expect(response.status).toBe("active"); expect(response.timeZone).toBe("Europe/Amsterdam"); @@ -451,7 +451,7 @@ describe("Balance Platform", (): void => { ] }); - const response: models.PaginatedPaymentInstrumentsResponse = await balancePlatform.BalanceAccounts.listPaymentInstruments(balanceAccountId, { + const response: balancePlatform.PaginatedPaymentInstrumentsResponse = await balancePlatformService.BalanceAccounts.listPaymentInstruments(balanceAccountId, { params: { limit: "3", offset: "6", @@ -471,7 +471,7 @@ describe("Balance Platform", (): void => { "status": "Active" }); - const response: models.BalancePlatform = await balancePlatform.General.retrieve(balanceAccountId); + const response: balancePlatform.BalancePlatform = await balancePlatformService.General.retrieve(balanceAccountId); expect(response.id).toBe(balanceAccountId); expect(response.status).toBe("Active"); @@ -514,7 +514,7 @@ describe("Balance Platform", (): void => { "hasPrevious": "false" }); - const response: models.PaginatedAccountHoldersResponse = await balancePlatform.General.listAccountHolders(balanceAccountId); + const response: balancePlatform.PaginatedAccountHoldersResponse = await balancePlatformService.General.listAccountHolders(balanceAccountId); expect(response.accountHolders.length).toBe(2); expect(response.accountHolders[0].id).toBe("AH32272223222B59DDWSCCMP7"); @@ -545,13 +545,13 @@ describe("Balance Platform", (): void => { }, "id": paymentInstrumentId }); - const request: models.PaymentInstrumentInfo = { - "type": models.PaymentInstrumentInfo.TypeEnum.Card, + const request: balancePlatform.PaymentInstrumentInfo = { + "type": balancePlatform.PaymentInstrumentInfo.TypeEnum.Card, "issuingCountryCode": "NL", "balanceAccountId": balanceAccountId, - "status": models.PaymentInstrumentInfo.StatusEnum.Inactive, + "status": balancePlatform.PaymentInstrumentInfo.StatusEnum.Inactive, "card": { - "formFactor": models.CardInfo.FormFactorEnum.Physical, + "formFactor": balancePlatform.CardInfo.FormFactorEnum.Physical, "brand": "mc", "brandVariant": "mcdebit", "cardholderName": "Sam Hopper", @@ -576,7 +576,7 @@ describe("Balance Platform", (): void => { "description": "S.Hopper - Main card" }; - const response: models.PaymentInstrument = await balancePlatform.PaymentInstruments.create(request); + const response: balancePlatform.PaymentInstrument = await balancePlatformService.PaymentInstruments.create(request); expect(response.id).toBe(paymentInstrumentId); expect(response.balanceAccountId).toBe(balanceAccountId); @@ -606,7 +606,7 @@ describe("Balance Platform", (): void => { "id": paymentInstrumentId }); - const response: models.PaymentInstrument = await balancePlatform.PaymentInstruments.retrieve(paymentInstrumentId); + const response: balancePlatform.PaymentInstrument = await balancePlatformService.PaymentInstruments.retrieve(paymentInstrumentId); expect(response.id).toBe(paymentInstrumentId); expect(response.status).toBe("active"); @@ -635,11 +635,11 @@ describe("Balance Platform", (): void => { }, "id": paymentInstrumentId }); - const request: models.PaymentInstrumentUpdateRequest = { + const request: balancePlatform.PaymentInstrumentUpdateRequest = { "balanceAccountId": "BA32272223222B5CM82WL892M" }; - const response: models.PaymentInstrument = await balancePlatform.PaymentInstruments.update(paymentInstrumentId, request); + const response: balancePlatform.PaymentInstrument = await balancePlatformService.PaymentInstruments.update(paymentInstrumentId, request); expect(response.id).toBe(paymentInstrumentId); expect(response.balanceAccountId).toBe("BA32272223222B5CM82WL892M"); @@ -681,7 +681,7 @@ describe("Balance Platform", (): void => { ] }); - const response: models.TransactionRulesResponse = await balancePlatform.PaymentInstruments.listTransactionRules(paymentInstrumentId); + const response: balancePlatform.TransactionRulesResponse = await balancePlatformService.PaymentInstruments.listTransactionRules(paymentInstrumentId); expect(response.transactionRules!.length).toBe(2); expect(response.transactionRules![0].id).toBe("TR32272223222B5CMDGMC9F4F"); @@ -696,12 +696,12 @@ describe("Balance Platform", (): void => { "txVariant": "mc", "id": paymentInstrumentGroupId }); - const request: models.PaymentInstrumentGroupInfo = { + const request: balancePlatform.PaymentInstrumentGroupInfo = { "balancePlatform": "YOUR_BALANCE_PLATFORM", "txVariant": "mc" }; - const response: models.PaymentInstrumentGroup = await balancePlatform.PaymentInstrumentGroups.create(request); + const response: balancePlatform.PaymentInstrumentGroup = await balancePlatformService.PaymentInstrumentGroups.create(request); expect(response.id).toBe(paymentInstrumentGroupId); expect(response.txVariant).toBe("mc"); @@ -715,7 +715,7 @@ describe("Balance Platform", (): void => { "id": paymentInstrumentGroupId }); - const response: models.PaymentInstrumentGroup = await balancePlatform.PaymentInstrumentGroups.retrieve(paymentInstrumentGroupId); + const response: balancePlatform.PaymentInstrumentGroup = await balancePlatformService.PaymentInstrumentGroups.retrieve(paymentInstrumentGroupId); expect(response.id).toBe(paymentInstrumentGroupId); expect(response.txVariant).toBe("mc"); @@ -757,7 +757,7 @@ describe("Balance Platform", (): void => { ] }); - const response: models.TransactionRulesResponse = await balancePlatform.PaymentInstrumentGroups.listTransactionRules(paymentInstrumentGroupId); + const response: balancePlatform.TransactionRulesResponse = await balancePlatformService.PaymentInstrumentGroups.listTransactionRules(paymentInstrumentGroupId); expect(response.transactionRules!.length).toBe(2); expect(response.transactionRules![0].id).toBe("TR32272223222B5CMDGMC9F4F"); @@ -793,29 +793,29 @@ describe("Balance Platform", (): void => { "type": "blockList", "id": transactionRuleId }); - const request: models.TransactionRuleInfo = { + const request: balancePlatform.TransactionRuleInfo = { "description": "Allow only point-of-sale transactions", "reference": "YOUR_REFERENCE_4F7346", "entityKey": { "entityType": "paymentInstrument", "entityReference": "PI3227C223222B5BPCMFXD2XG" }, - "status": models.TransactionRuleInfo.StatusEnum.Active, + "status": balancePlatform.TransactionRuleInfo.StatusEnum.Active, "interval": { - "type": models.TransactionRuleInterval.TypeEnum.PerTransaction + "type": balancePlatform.TransactionRuleInterval.TypeEnum.PerTransaction }, "ruleRestrictions": { "processingTypes": { "operation": "noneMatch", "value": [ - models.ProcessingTypesRestriction.ValueEnum.Pos + balancePlatform.ProcessingTypesRestriction.ValueEnum.Pos ] } }, - "type": models.TransactionRuleInfo.TypeEnum.BlockList + "type": balancePlatform.TransactionRuleInfo.TypeEnum.BlockList }; - const response: models.TransactionRule = await balancePlatform.TransactionRules.create(request); + const response: balancePlatform.TransactionRule = await balancePlatformService.TransactionRules.create(request); expect(response.id).toBe(transactionRuleId); expect(response.status).toBe("active"); @@ -839,7 +839,7 @@ describe("Balance Platform", (): void => { } }); - const response: models.TransactionRuleResponse = await balancePlatform.TransactionRules.retrieve(transactionRuleId); + const response: balancePlatform.TransactionRuleResponse = await balancePlatformService.TransactionRules.retrieve(transactionRuleId); expect(response.transactionRule!.id).toBe(transactionRuleId); expect(response.transactionRule!.type).toBe("velocity"); @@ -859,10 +859,10 @@ describe("Balance Platform", (): void => { "id": transactionRuleId }); const request: TransactionRuleInfoUpdate = { - "status": models.TransactionRuleInfo.StatusEnum.Inactive + "status": balancePlatform.TransactionRuleInfo.StatusEnum.Inactive }; - const response: models.TransactionRule = await balancePlatform.TransactionRules.update(transactionRuleId, request); + const response: balancePlatform.TransactionRule = await balancePlatformService.TransactionRules.update(transactionRuleId, request); expect(response.status).toBe("inactive"); expect(response.reference).toBe("myRule12345"); @@ -886,7 +886,7 @@ describe("Balance Platform", (): void => { "id": transactionRuleId }); - const response: models.TransactionRule = await balancePlatform.TransactionRules.delete(transactionRuleId); + const response: balancePlatform.TransactionRule = await balancePlatformService.TransactionRules.delete(transactionRuleId); expect(response.id).toBe(transactionRuleId); }); diff --git a/src/__tests__/binLookup.spec.ts b/src/__tests__/binLookup.spec.ts index b7db218bf..f55a5fdf5 100644 --- a/src/__tests__/binLookup.spec.ts +++ b/src/__tests__/binLookup.spec.ts @@ -3,11 +3,7 @@ import { createClient } from "../__mocks__/base"; import BinLookup from "../services/binLookup"; import Client from "../client"; import HttpClientException from "../httpClient/httpClientException"; -import { - ThreeDSAvailabilityRequest, - ThreeDSAvailabilityResponse, - CostEstimateRequest, -} from "../typings/binlookup/models"; +import { binlookup } from "../typings"; const threeDSAvailabilitySuccess = { binDetails: { @@ -19,7 +15,7 @@ const threeDSAvailabilitySuccess = { }; let client: Client; -let binLookup: BinLookup; +let binLookupService: BinLookup; let scope: nock.Scope; beforeEach((): void => { @@ -27,7 +23,7 @@ beforeEach((): void => { nock.activate(); } client = createClient(); - binLookup = new BinLookup(client); + binLookupService = new BinLookup(client); scope = nock(`${client.config.endpoint}${Client.BIN_LOOKUP_PAL_SUFFIX}${Client.BIN_LOOKUP_API_VERSION}`); }); @@ -37,7 +33,7 @@ afterEach((): void => { describe("Bin Lookup", function (): void { test("should succeed on get 3ds availability", async function (): Promise { - const threeDSAvailabilityRequest: ThreeDSAvailabilityRequest = { + const threeDSAvailabilityRequest: binlookup.ThreeDSAvailabilityRequest = { merchantAccount: process.env.ADYEN_MERCHANT!, brands: ["randomBrand"], cardNumber: "4111111111111111" @@ -46,13 +42,12 @@ describe("Bin Lookup", function (): void { scope.post("/get3dsAvailability") .reply(200, threeDSAvailabilitySuccess); - const response = await binLookup.get3dsAvailability(threeDSAvailabilityRequest); + const response = await binLookupService.get3dsAvailability(threeDSAvailabilityRequest); - expect(response).toEqual(threeDSAvailabilitySuccess); + expect(response).toEqual< binlookup.ThreeDSAvailabilityResponse>(threeDSAvailabilitySuccess); }); - test.each([false, true])("should fail with invalid merchant. isMock: %p", async function (isMock): Promise { - !isMock && nock.restore(); + test("should fail with invalid merchant", async function (): Promise { const threeDSAvailabilityRequest: { [key: string]: undefined|string|[] } = { merchantAccount: undefined, cardNumber: "4111111111111", @@ -63,15 +58,14 @@ describe("Bin Lookup", function (): void { .reply(403, JSON.stringify({status: 403, message: "fail", errorCode: "171"})); try { - await binLookup.get3dsAvailability(threeDSAvailabilityRequest as unknown as ThreeDSAvailabilityRequest); + await binLookupService.get3dsAvailability(threeDSAvailabilityRequest as unknown as binlookup.ThreeDSAvailabilityRequest); fail("Expected request to fail"); } catch (e) { expect(e instanceof HttpClientException).toBeTruthy(); } }); - test.each([false, true])("should succeed on get cost estimate. isMock: %p", async function (isMock): Promise { - !isMock && nock.restore(); + test("should succeed on get cost estimate", async function (): Promise { const expected = { cardBin: { bin: "", @@ -89,7 +83,7 @@ describe("Bin Lookup", function (): void { resultCode: "Unsupported", surchargeType: "ZERO" }; - const costEstimateRequest: CostEstimateRequest = { + const costEstimateRequest: binlookup.CostEstimateRequest = { amount: { currency: "EUR", value: 1000 }, assumptions: { assumeLevel3Data: true, @@ -102,13 +96,13 @@ describe("Bin Lookup", function (): void { mcc: "7411", enrolledIn3DSecure: true }, - shopperInteraction: CostEstimateRequest.ShopperInteractionEnum.Ecommerce, + shopperInteraction: binlookup.CostEstimateRequest.ShopperInteractionEnum.Ecommerce, }; scope.post("/getCostEstimate") .reply(200, expected); - const response = await binLookup.getCostEstimate(costEstimateRequest); + const response = await binLookupService.getCostEstimate(costEstimateRequest); expect(response).toEqual(expected); }); diff --git a/src/__tests__/checkServerIdentity.spec.ts b/src/__tests__/checkServerIdentity.spec.ts index f93ac28dc..fe4d898d4 100644 --- a/src/__tests__/checkServerIdentity.spec.ts +++ b/src/__tests__/checkServerIdentity.spec.ts @@ -1,22 +1,3 @@ -/* - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * 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. - */ - /* eslint-disable @typescript-eslint/naming-convention */ import checkServerIdentity from "../helpers/checkServerIdentity"; import { PeerCertificate } from "tls"; diff --git a/src/__tests__/checkout.spec.ts b/src/__tests__/checkout.spec.ts index d2404fbf6..f09e2b1ef 100644 --- a/src/__tests__/checkout.spec.ts +++ b/src/__tests__/checkout.spec.ts @@ -11,41 +11,19 @@ import {sessionsSuccess} from "../__mocks__/checkout/sessionsSuccess"; import Client from "../client"; import Checkout from "../services/checkout"; import HttpClientException from "../httpClient/httpClientException"; -import { - Amount, - CardDetails, - CheckoutBalanceCheckRequest, - CheckoutBalanceCheckResponse, - CheckoutCancelOrderResponse, - CheckoutCreateOrderRequest, - CheckoutCreateOrderResponse, - CheckoutUtilityRequest, - CreatePaymentLinkRequest, - DetailsRequest, - PaymentLinkResponse, - PaymentMethodsRequest, - PaymentRequest, - PaymentResponse, - PaymentSetupRequest, - PaymentVerificationRequest, - CreateCheckoutSessionRequest, - CreateCheckoutSessionResponse, - CardDetailsRequest, - CardDetailsResponse -} from "../typings/checkout/models"; +import { checkout } from "../typings"; const merchantAccount = process.env.ADYEN_MERCHANT!; const reference = "Your order number"; -const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI); -function createAmountObject(currency: string, value: number): Amount { +function createAmountObject(currency: string, value: number): checkout.Amount { return { currency, value, }; } -function createPaymentsDetailsRequest(): DetailsRequest { +function createPaymentsDetailsRequest(): checkout.DetailsRequest { return { details: { mD: "mdValue", @@ -55,9 +33,9 @@ function createPaymentsDetailsRequest(): DetailsRequest { }; } -export function createPaymentsCheckoutRequest(): PaymentRequest { +export function createPaymentsCheckoutRequest(): checkout.PaymentRequest { const paymentMethodDetails = { - type: CardDetails.TypeEnum.Scheme, + type: checkout.CardDetails.TypeEnum.Scheme, encryptedCardNumber: "test_4111111111111111", encryptedExpiryMonth: "test_03", encryptedExpiryYear: "test_2030", @@ -75,18 +53,18 @@ export function createPaymentsCheckoutRequest(): PaymentRequest { }; } -function createPaymentSessionRequest(): PaymentSetupRequest { +function createPaymentSessionRequest(): checkout.PaymentSetupRequest { return { amount: createAmountObject("USD", 1000), countryCode: "NL", merchantAccount, reference, returnUrl: "https://your-company.com/...", - channel: PaymentSetupRequest.ChannelEnum.Web, + channel: checkout.PaymentSetupRequest.ChannelEnum.Web, sdkVersion: "3.7.0" }; } -function getPaymentLinkSuccess(expiresAt: string): PaymentLinkResponse { +function getPaymentLinkSuccess(expiresAt: string): checkout.PaymentLinkResponse { return { amount: createAmountObject("USD", 1000), expiresAt, @@ -94,11 +72,11 @@ function getPaymentLinkSuccess(expiresAt: string): PaymentLinkResponse { url: "PaymentLinkResponse.url", id: "mocked_id", merchantAccount, - status: PaymentLinkResponse.StatusEnum.Active + status: checkout.PaymentLinkResponse.StatusEnum.Active }; } -function createPaymentLinkRequest(): CreatePaymentLinkRequest { +function createPaymentLinkRequest(): checkout.CreatePaymentLinkRequest { return { allowedPaymentMethods: ["scheme", "boletobancario"], amount: createAmountObject("USD", 1000), @@ -127,7 +105,7 @@ function createPaymentLinkRequest(): CreatePaymentLinkRequest { }; } -function createSessionRequest(): CreateCheckoutSessionRequest { +function createSessionRequest(): checkout.CreateCheckoutSessionRequest { return { amount: createAmountObject("USD", 1000), countryCode: "NL", @@ -138,7 +116,7 @@ function createSessionRequest(): CreateCheckoutSessionRequest { } let client: Client; -let checkout: Checkout; +let checkoutService: Checkout; let scope: nock.Scope; beforeEach((): void => { @@ -147,7 +125,7 @@ beforeEach((): void => { } client = createClient(); scope = nock(`${client.config.checkoutEndpoint}/${Client.CHECKOUT_API_VERSION}`); - checkout = new Checkout(client); + checkoutService = new Checkout(client); }); afterEach(() => { @@ -156,55 +134,55 @@ afterEach(() => { describe("Checkout", (): void => { test("should add idempotency key to request headers", async (): Promise => { - const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest(); + const paymentsRequest: checkout.PaymentRequest = createPaymentsCheckoutRequest(); scope.post("/payments") .reply(200, paymentsSuccess) .matchHeader("Idempotency-Key", "testKey"); - await checkout.payments(paymentsRequest, {idempotencyKey: "testKey"}); + await checkoutService.payments(paymentsRequest, {idempotencyKey: "testKey"}); - const paymentMethodsRequest: PaymentMethodsRequest = {merchantAccount}; + const paymentMethodsRequest: checkout.PaymentMethodsRequest = {merchantAccount}; scope.post("/paymentMethods") .reply(200, paymentMethodsSuccess) .matchHeader("Idempotency-Key", "testKey"); - await checkout.paymentMethods(paymentMethodsRequest, {idempotencyKey: "testKey"}); + await checkoutService.paymentMethods(paymentMethodsRequest, {idempotencyKey: "testKey"}); const expiresAt = "2019-12-17T10:05:29Z"; - const paymentLinkSuccess: PaymentLinkResponse = getPaymentLinkSuccess(expiresAt); + const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(expiresAt); scope.post("/paymentLinks") .reply(200, paymentLinkSuccess) .matchHeader("Idempotency-Key", "testKey"); - await checkout.paymentLinks(createPaymentLinkRequest(), {idempotencyKey: "testKey"}); + await checkoutService.paymentLinks(createPaymentLinkRequest(), {idempotencyKey: "testKey"}); scope.patch("/paymentLinks/321") .reply(200, { ...paymentLinkSuccess, status: "expired" }) .matchHeader("Idempotency-Key", "testKey"); - await checkout.updatePaymentLinks("321", "expired", {idempotencyKey: "testKey"}); + await checkoutService.updatePaymentLinks("321", "expired", {idempotencyKey: "testKey"}); scope.get("/paymentLinks/123") .reply(200, paymentLinkSuccess) .matchHeader("Idempotency-Key", "testKey"); - await checkout.getPaymentLinks("123", {idempotencyKey: "testKey"}); + await checkoutService.getPaymentLinks("123", {idempotencyKey: "testKey"}); scope.post("/payments/details") .reply(200, paymentDetailsSuccess) .matchHeader("Idempotency-Key", "testKey"); - await checkout.paymentsDetails(createPaymentsDetailsRequest(), {idempotencyKey: "testKey"}); + await checkoutService.paymentsDetails(createPaymentsDetailsRequest(), {idempotencyKey: "testKey"}); scope.post("/paymentSession") .reply(200, paymentSessionSuccess) .matchHeader("Idempotency-Key", "testKey"); - const paymentSessionRequest: PaymentSetupRequest = createPaymentSessionRequest(); - await checkout.paymentSession(paymentSessionRequest, {idempotencyKey: "testKey"}); + const paymentSessionRequest: checkout.PaymentSetupRequest = createPaymentSessionRequest(); + await checkoutService.paymentSession(paymentSessionRequest, {idempotencyKey: "testKey"}); scope.post("/payments/result") .reply(200, paymentsResultSuccess) .matchHeader("Idempotency-Key", "testKey"); - const paymentResultRequest: PaymentVerificationRequest = { + const paymentResultRequest: checkout.PaymentVerificationRequest = { payload: "This is a test payload", }; - await checkout.paymentResult(paymentResultRequest, {idempotencyKey: "testKey"}); + await checkoutService.paymentResult(paymentResultRequest, {idempotencyKey: "testKey"}); - const orderRequest: CheckoutCreateOrderRequest = { + const orderRequest: checkout.CheckoutCreateOrderRequest = { amount: createAmountObject("USD", 1000), merchantAccount, reference @@ -212,12 +190,12 @@ describe("Checkout", (): void => { scope.post("/orders") .reply(200, {}) .matchHeader("Idempotency-Key", "testKey"); - await checkout.orders(orderRequest, {idempotencyKey: "testKey"}); + await checkoutService.orders(orderRequest, {idempotencyKey: "testKey"}); scope.post("/orders/cancel") .reply(200, {}) .matchHeader("Idempotency-Key", "testKey"); - await checkout.ordersCancel({ + await checkoutService.ordersCancel({ order: { orderData: "mock_data", pspReference: "mock_pspref" @@ -229,43 +207,52 @@ describe("Checkout", (): void => { .reply(200, sessionsSuccess) .matchHeader("Idempotency-Key", "testKey"); - const sessionsRequest: CreateCheckoutSessionRequest = createSessionRequest(); - await checkout.sessions(sessionsRequest, {idempotencyKey: "testKey"}); + const sessionsRequest: checkout.CreateCheckoutSessionRequest = createSessionRequest(); + await checkoutService.sessions(sessionsRequest, {idempotencyKey: "testKey"}); }); - test.each([false, true])("should make a payment. isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should make a payment.", async (): Promise => { scope.post("/payments") .reply(200, paymentsSuccess); - const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest(); - const paymentsResponse: PaymentResponse = await checkout.payments(paymentsRequest); + const paymentsRequest: checkout.PaymentRequest = createPaymentsCheckoutRequest(); + const paymentsResponse: checkout.PaymentResponse = await checkoutService.payments(paymentsRequest); expect(paymentsResponse.pspReference).toBeTruthy(); }); - test.each([false, true])("should return correct Exception, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("Should properly handle error responses from API", async (): Promise => { try { scope.post("/payments") - .reply(401); - - const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest(); - await checkout.payments(paymentsRequest); - } catch (e) { - expect(e instanceof HttpClientException).toBeTruthy(); + .reply(422, { + "status": 422, + "errorCode": "200", + "message": "Field 'countryCode' is not valid.", + "errorType": "validation", + "pspReference": "DMB552CV6JHKGK82", + }); + + const paymentsRequest: checkout.PaymentRequest = createPaymentsCheckoutRequest(); + await checkoutService.payments(paymentsRequest); + fail("No exception was thrown"); + } catch (error) { + expect(error instanceof HttpClientException).toBeTruthy(); + if(error instanceof HttpClientException && error.responseBody) { + expect(JSON.parse(error.responseBody).errorType).toBe("validation"); + } else { + fail("Error did not contain the expected data"); + } } }); - test.each([false, true])("should have valid payment methods, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); - const paymentMethodsRequest: PaymentMethodsRequest = {merchantAccount}; + test("should have valid payment methods", async (): Promise => { + const paymentMethodsRequest: checkout.PaymentMethodsRequest = {merchantAccount}; scope.post("/paymentMethods") .reply(200, paymentMethodsSuccess); - const paymentMethodsResponse = await checkout.paymentMethods(paymentMethodsRequest); + const paymentMethodsResponse = await checkoutService.paymentMethods(paymentMethodsRequest); if (paymentMethodsResponse && paymentMethodsResponse.paymentMethods) { expect(paymentMethodsResponse.paymentMethods.length).toBeGreaterThan(0); } else { @@ -273,76 +260,69 @@ describe("Checkout", (): void => { } }); - test.each([false, true])("should have valid payment link, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should have valid payment link", async (): Promise => { const expiresAt = "2019-12-17T10:05:29Z"; - const paymentLinkSuccess: PaymentLinkResponse = getPaymentLinkSuccess(expiresAt); + const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(expiresAt); scope.post("/paymentLinks").reply(200, paymentLinkSuccess); - const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest()); + const paymentSuccessLinkResponse = await checkoutService.paymentLinks(createPaymentLinkRequest()); expect(paymentSuccessLinkResponse).toBeTruthy(); }); - test.each([isCI, true])("should get payment link, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should get payment link", async (): Promise => { const expiresAt = "2019-12-17T10:05:29Z"; - const paymentLinkSuccess: PaymentLinkResponse = getPaymentLinkSuccess(expiresAt); + const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(expiresAt); scope.post("/paymentLinks").reply(200, paymentLinkSuccess); - const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest()); + const paymentSuccessLinkResponse = await checkoutService.paymentLinks(createPaymentLinkRequest()); scope.get(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, paymentLinkSuccess); - const paymentLink = await checkout.getPaymentLinks(paymentSuccessLinkResponse.id); + const paymentLink = await checkoutService.getPaymentLinks(paymentSuccessLinkResponse.id); expect(paymentLink).toBeTruthy(); }); - test.each([isCI, true])("should patch payment link, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should patch payment link", async (): Promise => { const expiresAt = "2019-12-17T10:05:29Z"; - const paymentLinkSuccess: PaymentLinkResponse = getPaymentLinkSuccess(expiresAt); + const paymentLinkSuccess: checkout.PaymentLinkResponse = getPaymentLinkSuccess(expiresAt); scope.post("/paymentLinks").reply(200, paymentLinkSuccess); - const paymentSuccessLinkResponse = await checkout.paymentLinks(createPaymentLinkRequest()); + const paymentSuccessLinkResponse = await checkoutService.paymentLinks(createPaymentLinkRequest()); scope.patch(`/paymentLinks/${paymentSuccessLinkResponse.id}`).reply(200, { ...paymentLinkSuccess, status: "expired" }); - const paymentLink = await checkout.updatePaymentLinks(paymentSuccessLinkResponse.id, "expired"); + const paymentLink = await checkoutService.updatePaymentLinks(paymentSuccessLinkResponse.id, "expired"); expect(paymentLink.status).toEqual("expired"); }); - test.each([isCI, true])("should have payment details, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should have payment details", async (): Promise => { scope.post("/payments/details") .reply(200, paymentDetailsSuccess); - const paymentsResponse = await checkout.paymentsDetails(createPaymentsDetailsRequest()); + const paymentsResponse = await checkoutService.paymentsDetails(createPaymentsDetailsRequest()); expect(paymentsResponse.resultCode).toEqual("Authorised"); }); - test.each([false, true])("should have payment session success, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should have payment session success", async (): Promise => { scope.post("/paymentSession") .reply(200, paymentSessionSuccess); - const paymentSessionRequest: PaymentSetupRequest = createPaymentSessionRequest(); - const paymentSessionResponse = await checkout.paymentSession(paymentSessionRequest); + const paymentSessionRequest: checkout.PaymentSetupRequest = createPaymentSessionRequest(); + const paymentSessionResponse = await checkoutService.paymentSession(paymentSessionRequest); expect(paymentSessionResponse.paymentSession).not.toBeUndefined(); }); - test.each([isCI, true])("should have payments result, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should have payments result", async (): Promise => { scope.post("/payments/result") .reply(200, paymentsResultSuccess); - const paymentResultRequest: PaymentVerificationRequest = { + const paymentResultRequest: checkout.PaymentVerificationRequest = { payload: "This is a test payload", }; - const paymentResultResponse = await checkout.paymentResult(paymentResultRequest); + const paymentResultResponse = await checkoutService.paymentResult(paymentResultRequest); expect(paymentResultResponse.resultCode).toEqual("Authorised"); }); - test.each([false, true])("should have missing identifier on live, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should have missing identifier on live", async (): Promise => { client.setEnvironment("LIVE"); try { new Checkout(client); @@ -358,22 +338,20 @@ describe("Checkout", (): void => { }); - test.each([false, true])("should succeed on multibanco payment, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should succeed on multibanco payment", async (): Promise => { scope.post("/payments") .reply(200, paymentsResultMultibancoSuccess); - const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest(); - const paymentsResponse: PaymentResponse = await checkout.payments(paymentsRequest); + const paymentsRequest: checkout.PaymentRequest = createPaymentsCheckoutRequest(); + const paymentsResponse: checkout.PaymentResponse = await checkoutService.payments(paymentsRequest); expect(paymentsResponse.pspReference).toBeTruthy(); expect(paymentsResponse.additionalData).toBeTruthy(); }); - test.each([false, true])("should get origin keys. isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should get origin keys", async (): Promise => { const checkoutUtility = new Checkout(client); - const originKeysRequest: CheckoutUtilityRequest = { + const originKeysRequest: checkout.CheckoutUtilityRequest = { originDomains: ["https://www.your-domain.com"], }; @@ -389,78 +367,75 @@ describe("Checkout", (): void => { }); // TODO: add gift card to PaymentMethod and unmock test - test.each([true, true])("should get payment methods balance", async (isMock): Promise => { - !isMock && nock.restore(); - const paymentMethodsRequest: CheckoutBalanceCheckRequest = { + test("should get payment methods balance", async (): Promise => { + const paymentMethodsRequest: checkout.CheckoutBalanceCheckRequest = { merchantAccount, amount: createAmountObject("USD", 1000), paymentMethod: { }, reference: "mocked_reference" }; - const paymentMethodsBalanceResponse: CheckoutBalanceCheckResponse = { + const paymentMethodsBalanceResponse: checkout.CheckoutBalanceCheckResponse = { balance: {currency: "USD", value: 1000}, - resultCode: CheckoutBalanceCheckResponse.ResultCodeEnum.Success + resultCode: checkout.CheckoutBalanceCheckResponse.ResultCodeEnum.Success }; scope.post("/paymentMethods/balance") .reply(200, paymentMethodsBalanceResponse); - const paymentsResponse: CheckoutBalanceCheckResponse = await checkout.paymentMethodsBalance(paymentMethodsRequest); + const paymentsResponse: checkout.CheckoutBalanceCheckResponse = await checkoutService.paymentMethodsBalance(paymentMethodsRequest); expect(paymentsResponse.balance.value).toEqual(1000); }); - test.each([false, true])("should create order", async (isMock): Promise => { - !isMock && nock.restore(); + test("should create order", async (): Promise => { const expiresAt = "2019-12-17T10:05:29Z"; - const orderRequest: CheckoutCreateOrderRequest = { + const orderRequest: checkout.CheckoutCreateOrderRequest = { amount: createAmountObject("USD", 1000), merchantAccount, reference }; - const orderResponse: CheckoutCreateOrderResponse = { + const orderResponse: checkout.CheckoutCreateOrderResponse = { expiresAt, amount: createAmountObject("USD", 500), orderData: "mocked_order_data", remainingAmount: {currency: "USD", value: 500} , - resultCode: CheckoutCreateOrderResponse.ResultCodeEnum.Success + resultCode: checkout.CheckoutCreateOrderResponse.ResultCodeEnum.Success }; scope.post("/orders") .reply(200, orderResponse); - const response: CheckoutCreateOrderResponse = await checkout.orders(orderRequest); + const response: checkout.CheckoutCreateOrderResponse = await checkoutService.orders(orderRequest); expect(response).toBeTruthy(); }); - test.each([false, true])("should cancel order", async (isMock): Promise => { - !isMock && nock.restore(); + test("should cancel order", async (): Promise => { const expiresAt = "2019-12-17T10:05:29Z"; - const orderRequest: CheckoutCreateOrderRequest = { + const orderRequest: checkout.CheckoutCreateOrderRequest = { amount: createAmountObject("USD", 1000), merchantAccount, reference }; - const orderResponse: CheckoutCreateOrderResponse = { + const orderResponse: checkout.CheckoutCreateOrderResponse = { expiresAt, amount: createAmountObject("USD", 500), orderData: "mocked_order_data", remainingAmount: {currency: "USD", value: 500}, - resultCode: CheckoutCreateOrderResponse.ResultCodeEnum.Success + resultCode: checkout.CheckoutCreateOrderResponse.ResultCodeEnum.Success }; scope.post("/orders") .reply(200, orderResponse); - const createOrderResponse: CheckoutCreateOrderResponse = await checkout.orders(orderRequest); + const createOrderResponse: checkout.CheckoutCreateOrderResponse = await checkoutService.orders(orderRequest); - const orderCancelResponse: CheckoutCancelOrderResponse = { + const orderCancelResponse: checkout.CheckoutCancelOrderResponse = { pspReference: "mocked_psp_ref", - resultCode: CheckoutCancelOrderResponse.ResultCodeEnum.Received + resultCode: checkout.CheckoutCancelOrderResponse.ResultCodeEnum.Received }; scope.post("/orders/cancel") .reply(200, orderCancelResponse); - const response: CheckoutCancelOrderResponse = await checkout.ordersCancel({ + const response: checkout.CheckoutCancelOrderResponse = await checkoutService.ordersCancel({ order: { orderData: createOrderResponse.orderData, pspReference: createOrderResponse.pspReference! @@ -470,13 +445,12 @@ describe("Checkout", (): void => { expect(response).toBeTruthy(); }); - test.each([false, true])("should create a session. isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should create a session.", async (): Promise => { scope.post("/sessions") .reply(200, sessionsSuccess); - const sessionsRequest: CreateCheckoutSessionRequest = createSessionRequest(); - const sessionsResponse: CreateCheckoutSessionResponse = await checkout.sessions(sessionsRequest); + const sessionsRequest: checkout.CreateCheckoutSessionRequest = createSessionRequest(); + const sessionsResponse: checkout.CreateCheckoutSessionResponse = await checkoutService.sessions(sessionsRequest); expect(sessionsResponse.sessionData).toBeTruthy(); expect(sessionsResponse.expiresAt).toBeInstanceOf(Date); expect(sessionsResponse.expiresAt.getFullYear()).toBeGreaterThan(0); @@ -493,11 +467,11 @@ describe("Checkout", (): void => { ] }); - const cardDetailsRequest: CardDetailsRequest = { + const cardDetailsRequest: checkout.CardDetailsRequest = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "cardNumber": "411111" }; - const cardDetailsReponse: CardDetailsResponse = await checkout.cardDetails(cardDetailsRequest); + const cardDetailsReponse: checkout.CardDetailsResponse = await checkoutService.cardDetails(cardDetailsRequest); expect(cardDetailsReponse?.brands?.length).toBe(1); }); }); diff --git a/src/__tests__/classicIntegration.spec.ts b/src/__tests__/classicIntegration.spec.ts index d471d51b1..14ce86e1b 100644 --- a/src/__tests__/classicIntegration.spec.ts +++ b/src/__tests__/classicIntegration.spec.ts @@ -2,23 +2,7 @@ import nock from "nock"; import {createClient} from "../__mocks__/base"; import Client from "../client"; import ClassicIntegration from "../services/classicIntegration"; -import { PaymentRequest } from "../typings/payments/paymentRequest"; -import { PaymentResult } from "../typings/payments/paymentResult"; -import { PaymentRequest3d } from "../typings/payments/paymentRequest3d"; -import { PaymentRequest3ds2 } from "../typings/payments/paymentRequest3ds2"; -import { AuthenticationResultRequest } from "../typings/payments/authenticationResultRequest"; -import { AuthenticationResultResponse } from "../typings/payments/authenticationResultResponse"; -import { ThreeDS2ResultRequest } from "../typings/payments/threeDS2ResultRequest"; -import { ThreeDS2ResultResponse } from "../typings/payments/threeDS2ResultResponse"; -import { ModificationResult } from "../typings/payments/modificationResult"; -import { CaptureRequest } from "../typings/payments/captureRequest"; -import { CancelRequest } from "../typings/payments/cancelRequest"; -import { RefundRequest } from "../typings/payments/refundRequest"; -import { CancelOrRefundRequest } from "../typings/payments/cancelOrRefundRequest"; -import { TechnicalCancelRequest } from "../typings/payments/technicalCancelRequest"; -import { AdjustAuthorisationRequest } from "../typings/payments/adjustAuthorisationRequest"; -import { DonationRequest } from "../typings/payments/donationRequest"; -import { VoidPendingRefundRequest } from "../typings/payments/voidPendingRefundRequest"; +import { payments } from "../typings"; let client: Client; let classicIntegration: ClassicIntegration; @@ -50,7 +34,7 @@ describe("Classic Integration", (): void => { "authCode": "011381" } ); - const paymentRequest: PaymentRequest = { + const paymentRequest: payments.PaymentRequest = { "card": { "number": "4111111111111111", "expiryMonth": "03", @@ -66,7 +50,7 @@ describe("Classic Integration", (): void => { "merchantAccount": "YOUR_MERCHANT_ACCOUNT" }; - const paymentResult: PaymentResult = await classicIntegration.authorise(paymentRequest); + const paymentResult: payments.PaymentResult = await classicIntegration.authorise(paymentRequest); expect(paymentResult.pspReference).toEqual("JVBXGSDM53RZNN82"); }); @@ -82,14 +66,14 @@ describe("Classic Integration", (): void => { "authCode": "011381" } ); - const paymentRequest: PaymentRequest3d = { + const paymentRequest: payments.PaymentRequest3d = { "md": "31h..........vOXek7w", "paResponse": "eNqtmF........wGVA4Ch", "shopperIP": "61.294.12.12", "merchantAccount": "YOUR_MERCHANT_ACCOUNT" }; - const paymentResult: PaymentResult = await classicIntegration.authorise3d(paymentRequest); + const paymentResult: payments.PaymentResult = await classicIntegration.authorise3d(paymentRequest); expect(paymentResult.pspReference).toEqual("JVBXGSDM53RZNN82"); }); @@ -105,7 +89,7 @@ describe("Classic Integration", (): void => { "authCode": "011381" } ); - const paymentRequest: PaymentRequest3ds2 = { + const paymentRequest: payments.PaymentRequest3ds2 = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "amount": { "value": 1500, @@ -119,7 +103,7 @@ describe("Classic Integration", (): void => { "threeDS2Token": "— - BINARY DATA - -" }; - const paymentResult: PaymentResult = await classicIntegration.authorise3ds2(paymentRequest); + const paymentResult: payments.PaymentResult = await classicIntegration.authorise3ds2(paymentRequest); expect(paymentResult.pspReference).toEqual("JVBXGSDM53RZNN82"); }); @@ -128,12 +112,12 @@ describe("Classic Integration", (): void => { "threeDS2Result": { "authenticationValue": "THREEDS2RESULT"} }); - const getAuthenticationResultrequest: AuthenticationResultRequest = { + const getAuthenticationResultrequest: payments.AuthenticationResultRequest = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "pspReference": "9935272408535455" }; - const getAuthenticationResultResponse: AuthenticationResultResponse = await classicIntegration.getAuthenticationResult(getAuthenticationResultrequest); + const getAuthenticationResultResponse: payments.AuthenticationResultResponse = await classicIntegration.getAuthenticationResult(getAuthenticationResultrequest); expect(getAuthenticationResultResponse?.threeDS2Result?.authenticationValue).toEqual("THREEDS2RESULT"); }); @@ -141,12 +125,12 @@ describe("Classic Integration", (): void => { scope.post("/retrieve3ds2Result").reply(200, { "threeDS2Result": { "authenticationValue": "THREEDS2RESULT"} }); - const retrieve3ds2ResultRequest: ThreeDS2ResultRequest = { + const retrieve3ds2ResultRequest: payments.ThreeDS2ResultRequest = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "pspReference": "9935272408535455" }; - const retrieve3ds2ResultResponse: ThreeDS2ResultResponse = await classicIntegration.retrieve3ds2Result(retrieve3ds2ResultRequest); + const retrieve3ds2ResultResponse: payments.ThreeDS2ResultResponse = await classicIntegration.retrieve3ds2Result(retrieve3ds2ResultRequest); expect(retrieve3ds2ResultResponse?.threeDS2Result?.authenticationValue).toEqual("THREEDS2RESULT"); }); @@ -157,7 +141,7 @@ describe("Classic Integration", (): void => { "response": "[capture-received]" }); - const modificationRequest: CaptureRequest = { + const modificationRequest: payments.CaptureRequest = { "originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE", "modificationAmount": { "value": 500, @@ -167,8 +151,8 @@ describe("Classic Integration", (): void => { "merchantAccount": "YOUR_MERCHANT_ACCOUNT" }; - const modificationResult: ModificationResult = await classicIntegration.capture(modificationRequest); - expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.CaptureReceived); + const modificationResult: payments.ModificationResult = await classicIntegration.capture(modificationRequest); + expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.CaptureReceived); }); test("Should succesfully send Cancel request", async (): Promise => { @@ -178,14 +162,14 @@ describe("Classic Integration", (): void => { "response": "[cancel-received]" }); - const modificationRequest: CancelRequest = { + const modificationRequest: payments.CancelRequest = { "originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE", "reference": "YourModificationReference", "merchantAccount": "YOUR_MERCHANT_ACCOUNT" }; - const modificationResult: ModificationResult = await classicIntegration.cancel(modificationRequest); - expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.CancelReceived); + const modificationResult: payments.ModificationResult = await classicIntegration.cancel(modificationRequest); + expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.CancelReceived); }); test("Should succesfully send Refund request", async (): Promise => { @@ -195,7 +179,7 @@ describe("Classic Integration", (): void => { "response": "[refund-received]" }); - const modificationRequest: RefundRequest = { + const modificationRequest: payments.RefundRequest = { "originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE", "modificationAmount": { "value": 500, @@ -205,8 +189,8 @@ describe("Classic Integration", (): void => { "merchantAccount": "YOUR_MERCHANT_ACCOUNT" }; - const modificationResult: ModificationResult = await classicIntegration.refund(modificationRequest); - expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.RefundReceived); + const modificationResult: payments.ModificationResult = await classicIntegration.refund(modificationRequest); + expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.RefundReceived); }); test("Should succesfully send CancelOrRefund request", async (): Promise => { @@ -216,14 +200,14 @@ describe("Classic Integration", (): void => { "response": "[cancelOrRefund-received]" }); - const modificationRequest: CancelOrRefundRequest = { + const modificationRequest: payments.CancelOrRefundRequest = { "originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE", "reference": "YourModificationReference", "merchantAccount": "YOUR_MERCHANT_ACCOUNT" }; - const modificationResult: ModificationResult = await classicIntegration.cancelOrRefund(modificationRequest); - expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.CancelOrRefundReceived); + const modificationResult: payments.ModificationResult = await classicIntegration.cancelOrRefund(modificationRequest); + expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.CancelOrRefundReceived); }); test("Should succesfully send TechnicalCancel request", async (): Promise => { @@ -233,7 +217,7 @@ describe("Classic Integration", (): void => { "response": "[technical-cancel-received]" }); - const modificationRequest: TechnicalCancelRequest = { + const modificationRequest: payments.TechnicalCancelRequest = { "originalMerchantReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE", "modificationAmount": { "value": 500, @@ -243,8 +227,8 @@ describe("Classic Integration", (): void => { "merchantAccount": "YOUR_MERCHANT_ACCOUNT" }; - const modificationResult: ModificationResult = await classicIntegration.technicalCancel(modificationRequest); - expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.TechnicalCancelReceived); + const modificationResult: payments.ModificationResult = await classicIntegration.technicalCancel(modificationRequest); + expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.TechnicalCancelReceived); }); test("Should succesfully send AdjustAuthorisation request", async (): Promise => { @@ -254,7 +238,7 @@ describe("Classic Integration", (): void => { "response": "[adjustAuthorisation-received]" }); - const modificationRequest: AdjustAuthorisationRequest = { + const modificationRequest: payments.AdjustAuthorisationRequest = { "originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE", "modificationAmount": { "value": 500, @@ -264,8 +248,8 @@ describe("Classic Integration", (): void => { "merchantAccount": "YOUR_MERCHANT_ACCOUNT" }; - const modificationResult: ModificationResult = await classicIntegration.adjustAuthorisation(modificationRequest); - expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.AdjustAuthorisationReceived); + const modificationResult: payments.ModificationResult = await classicIntegration.adjustAuthorisation(modificationRequest); + expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.AdjustAuthorisationReceived); }); test("Should succesfully send Donate request", async (): Promise => { @@ -275,7 +259,7 @@ describe("Classic Integration", (): void => { "response": "[donation-received]" }); - const modificationRequest: DonationRequest = { + const modificationRequest: payments.DonationRequest = { "originalReference": "COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE", "modificationAmount": { "value": 500, @@ -286,8 +270,8 @@ describe("Classic Integration", (): void => { "merchantAccount": "YOUR_MERCHANT_ACCOUNT" }; - const modificationResult: ModificationResult = await classicIntegration.donate(modificationRequest); - expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.DonationReceived); + const modificationResult: payments.ModificationResult = await classicIntegration.donate(modificationRequest); + expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.DonationReceived); }); test("Should succesfully send VoidPendingRefund request", async (): Promise => { @@ -297,13 +281,13 @@ describe("Classic Integration", (): void => { "response": "[voidPendingRefund-received]" }); - const modificationRequest: VoidPendingRefundRequest = { + const modificationRequest: payments.VoidPendingRefundRequest = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "tenderReference": "5Iw8001176969533005", "uniqueTerminalId": "VX820-123456789" }; - const modificationResult: ModificationResult = await classicIntegration.voidPendingRefund(modificationRequest); - expect(modificationResult.response).toEqual(ModificationResult.ResponseEnum.VoidPendingRefundReceived); + const modificationResult: payments.ModificationResult = await classicIntegration.voidPendingRefund(modificationRequest); + expect(modificationResult.response).toEqual(payments.ModificationResult.ResponseEnum.VoidPendingRefundReceived); }); }); \ No newline at end of file diff --git a/src/__tests__/client.spec.ts b/src/__tests__/client.spec.ts new file mode 100644 index 000000000..c83bc7925 --- /dev/null +++ b/src/__tests__/client.spec.ts @@ -0,0 +1,11 @@ +import Client from "../client"; + +describe("API Client", function (): void { + test("should be able to make a request using basic auth", async function (): Promise { + new Client({ + username: process.env.ADYEN_USER!, + password: process.env.ADYEN_PASSWORD!, + environment: "TEST" + }); + }); +}); diff --git a/src/__tests__/dataProtection.spec.ts b/src/__tests__/dataProtection.spec.ts new file mode 100644 index 000000000..9816b2c4d --- /dev/null +++ b/src/__tests__/dataProtection.spec.ts @@ -0,0 +1,59 @@ +import nock from "nock"; +import { createClient } from "../__mocks__/base"; +import { DataProtection } from "../services"; +import Client from "../client"; +import HttpClientException from "../httpClient/httpClientException"; +import { dataProtection } from "../typings"; + +let client: Client, + dataProtectionService: DataProtection, + scope: nock.Scope; + +beforeEach((): void => { + if(!nock.isActive()) { + nock.activate(); + } + client = createClient(); + dataProtectionService = new DataProtection(client); + scope = nock(`${client.config.dataProtectionEndpoint}/${Client.DATA_PROTECTION_API_VERSION}`); +}); + +afterEach(() => { + nock.cleanAll(); +}); + +describe("DataProtection", (): void => { + test("should make succesful subjectErasure call", async (): Promise => { + const requestSubjectErasureSuccess: dataProtection.SubjectErasureResponse = { + "result": dataProtection.SubjectErasureResponse.ResultEnum.Success, + }; + + const requestSubjectErasureRequest: dataProtection.SubjectErasureByPspReferenceRequest = { + "merchantAccount": "MY_MERCHANT_ACCOUNT", + "forceErasure": true, + "pspReference": "0123456789" + }; + + scope.post("/requestSubjectErasure") + .reply(200, requestSubjectErasureSuccess); + + const response: dataProtection.SubjectErasureResponse = await dataProtectionService.requestSubjectErasure(requestSubjectErasureRequest); + expect(response.result).toEqual(dataProtection.SubjectErasureResponse.ResultEnum.Success); + }); + + test("should return correct Exception", async (): Promise => { + try { + scope.post("/requestSubjectErasure") + .reply(401); + + const requestSubjectErasureRequest: dataProtection.SubjectErasureByPspReferenceRequest = { + "merchantAccount": "MY_MERCHANT_ACCOUNT", + "forceErasure": true, + "pspReference": "0123456789" + }; + await dataProtectionService.requestSubjectErasure(requestSubjectErasureRequest); + } catch (e) { + expect(e instanceof HttpClientException).toBeTruthy(); + } + }); +}); \ No newline at end of file diff --git a/src/__tests__/hmacValidator.spec.ts b/src/__tests__/hmacValidator.spec.ts index fa8f30e2d..d0f45a44f 100644 --- a/src/__tests__/hmacValidator.spec.ts +++ b/src/__tests__/hmacValidator.spec.ts @@ -1,22 +1,3 @@ -/* - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * 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 HmacValidator from "../utils/hmacValidator"; import { AdditionalData, NotificationItem, NotificationRequestItem } from "../typings/notification/models"; import { ApiConstants } from "../constants/apiConstants"; diff --git a/src/__tests__/httpClient.spec.ts b/src/__tests__/httpClient.spec.ts index f442d7f6a..aaf7d7646 100644 --- a/src/__tests__/httpClient.spec.ts +++ b/src/__tests__/httpClient.spec.ts @@ -1,22 +1,3 @@ -/* - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * 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 nock, { Interceptor } from "nock"; import Client from "../client"; import Checkout from "../services/checkout"; diff --git a/src/__tests__/management.spec.ts b/src/__tests__/management.spec.ts index 0e2ef2022..713ed7f8e 100644 --- a/src/__tests__/management.spec.ts +++ b/src/__tests__/management.spec.ts @@ -2,13 +2,13 @@ import nock from "nock"; import Client from "../client"; import { createClient } from "../__mocks__/base"; import { Management } from "../services"; -import { AllowedOrigin, AllowedOriginsResponse, MeApiCredential } from "../typings/management/models"; -import * as models from "../typings/management/models"; +import { management } from "../typings"; import * as requests from "../__mocks__/management/requests"; import * as responses from "../__mocks__/management/responses"; +import HttpClientException from "../httpClient/httpClientException"; let client: Client; -let management: Management; +let managementService: Management; let scope: nock.Scope; const merchantId = "merchantId"; @@ -26,7 +26,7 @@ beforeEach((): void => { } client = createClient(); scope = nock(`${client.config.managementEndpoint}/${Client.MANAGEMENT_API_VERSION}`); - management = new Management(client); + managementService = new Management(client); }); afterEach(() => { @@ -35,6 +35,32 @@ afterEach(() => { describe("Management", (): void => { describe("Me", (): void => { + test("Should properly handle error responses from API", async (): Promise => { + scope.post("/me/allowedOrigins") + .reply(422, { + "type": "https://docs.adyen.com/errors/not-found", + "title": "Entity was not found", + "status": 422, + "detail": "The origin id is invalid or does not exist.", + "requestId": "KQZ5LXK2VMPRMC82", + "errorCode": "30_112", + }); + try { + const createAllowedOriginRequest : management.CreateAllowedOriginRequest = { + domain: "test.com", + }; + await managementService.Me.createAllowedOrigin(createAllowedOriginRequest); + fail("No exception was thrown"); + } catch (error) { + expect(error instanceof HttpClientException).toBeTruthy(); + if(error instanceof HttpClientException && error.responseBody) { + expect(JSON.parse(error.responseBody).requestId).toBe("KQZ5LXK2VMPRMC82"); + } else { + fail("Error did not contain the expected data"); + } + } + }); + test("Should get API credential details based on the API Key used in the request", async (): Promise => { scope.get("/me") .reply(200, { @@ -63,7 +89,7 @@ describe("Management", (): void => { "companyName": "Test", "active": true, }); - const meResponse: MeApiCredential = await management.Me.retrieve(); + const meResponse: management.MeApiCredential = await managementService.Me.retrieve(); expect(meResponse.id).toEqual("S2-6262224667"); }); @@ -78,11 +104,11 @@ describe("Management", (): void => { } } }); - const allowedOriginRequest: AllowedOrigin = { + const allowedOriginRequest: management.AllowedOrigin = { "domain": "https://www.us.mystore.com" }; - const allowedOriginsResponse: AllowedOrigin = await management.Me.createAllowedOrigin(allowedOriginRequest); + const allowedOriginsResponse: management.AllowedOrigin = await managementService.Me.createAllowedOrigin(allowedOriginRequest); expect(allowedOriginsResponse.domain).toEqual("https://www.us.mystore.com"); }); @@ -102,7 +128,7 @@ describe("Management", (): void => { ] }); - const allowedOriginsResponse: AllowedOriginsResponse = await management.Me.retrieveAllowedOrigins(); + const allowedOriginsResponse: management.AllowedOriginsResponse = await managementService.Me.retrieveAllowedOrigins(); expect(allowedOriginsResponse.data?.length).toEqual(1); }); }); @@ -119,13 +145,13 @@ describe("Management", (): void => { } }); - const allowedOriginResponse: AllowedOrigin = await management.Me.retrieveAllowedOrigin("S2-123123123123123"); + const allowedOriginResponse: management.AllowedOrigin = await managementService.Me.retrieveAllowedOrigin("S2-123123123123123"); expect(allowedOriginResponse.id).toEqual("S2-123123123123123"); }); test("Should remove the allowed origin specified in the path", async () => { scope.delete("/me/allowedOrigins/S2-123123123123123").reply(204, {}); - const allowedOriginResponse: Record = await management.Me.deleteAllowerdOrigin("S2-123123123123123"); + const allowedOriginResponse: Record = await managementService.Me.deleteAllowerdOrigin("S2-123123123123123"); expect(scope.isDone()).toBe(true); expect(Object.entries(allowedOriginResponse).length).toBe(0); }); @@ -135,7 +161,7 @@ describe("Management", (): void => { scope.get("/merchants?pageNumber=1&pageSize=1") .reply(200, responses.listMerchantResponse); - const response: models.ListMerchantResponse = await management.MerchantAccount.list({ + const response: management.ListMerchantResponse = await managementService.MerchantAccount.list({ params: { "pageNumber": "1", "pageSize": "1" @@ -149,7 +175,7 @@ describe("Management", (): void => { scope.post("/merchants") .reply(200, responses.createMerchantResponse); - const response: models.CreateMerchantResponse = await management.MerchantAccount.create(requests.createMerchantRequest); + const response: management.CreateMerchantResponse = await managementService.MerchantAccount.create(requests.createMerchantRequest); expect(response).toBeTruthy(); }); @@ -158,7 +184,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}`) .reply(200, responses.merchant); - const response: models.Merchant = await management.MerchantAccount.retrieve(merchantId); + const response: management.Merchant = await managementService.MerchantAccount.retrieve(merchantId); expect(response).toBeTruthy(); }); @@ -167,7 +193,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/activate`) .reply(200, responses.requestActivationResponse); - const response: models.RequestActivationResponse = await management.MerchantAccount.activate(merchantId); + const response: management.RequestActivationResponse = await managementService.MerchantAccount.activate(merchantId); expect(response).toBeTruthy(); }); @@ -178,7 +204,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`) .reply(200, responses.allowedOriginsResponse); - const response: models.AllowedOriginsResponse = await management.MerchantAllowedOrigins.list(merchantId, apiCredentialId); + const response: management.AllowedOriginsResponse = await managementService.MerchantAllowedOrigins.list(merchantId, apiCredentialId); expect(response).toBeTruthy(); }); @@ -187,7 +213,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins`) .reply(200, responses.allowedOriginsResponse); - const response: models.AllowedOriginsResponse = await management.MerchantAllowedOrigins.create(merchantId, apiCredentialId, requests.allowedOrigin); + const response: management.AllowedOriginsResponse = await managementService.MerchantAllowedOrigins.create(merchantId, apiCredentialId, requests.allowedOrigin); expect(response).toBeTruthy(); }); @@ -196,14 +222,14 @@ describe("Management", (): void => { scope.delete(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`) .reply(204); - await management.MerchantAllowedOrigins.delete(merchantId, apiCredentialId, originId); + await managementService.MerchantAllowedOrigins.delete(merchantId, apiCredentialId, originId); }); it("should support GET /merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}", async (): Promise => { scope.get(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/allowedOrigins/${originId}`) .reply(200, responses.allowedOrigin); - const response: models.AllowedOrigin = await management.MerchantAllowedOrigins.retrieve(merchantId, apiCredentialId, originId); + const response: management.AllowedOrigin = await managementService.MerchantAllowedOrigins.retrieve(merchantId, apiCredentialId, originId); expect(response).toBeTruthy(); }); @@ -214,7 +240,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/apiCredentials?pageNumber=1&pageSize=1`) .reply(200, responses.listMerchantApiCredentialsResponse); - const response: models.ListMerchantApiCredentialsResponse = await management.MerchantApiCredentials.list(merchantId, { + const response: management.ListMerchantApiCredentialsResponse = await managementService.MerchantApiCredentials.list(merchantId, { params: { "pageNumber": "1", "pageSize": "1" @@ -228,7 +254,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/apiCredentials`) .reply(200, responses.createApiCredentialResponse); - const response: models.CreateApiCredentialResponse = await management.MerchantApiCredentials.create(merchantId, requests.createMerchantApiCredentialRequest); + const response: management.CreateApiCredentialResponse = await managementService.MerchantApiCredentials.create(merchantId, requests.createMerchantApiCredentialRequest); expect(response).toBeTruthy(); }); @@ -237,7 +263,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}`) .reply(200, responses.apiCredential); - const response: models.ApiCredential = await management.MerchantApiCredentials.retrieve(merchantId, apiCredentialId); + const response: management.ApiCredential = await managementService.MerchantApiCredentials.retrieve(merchantId, apiCredentialId); expect(response).toBeTruthy(); }); @@ -246,7 +272,7 @@ describe("Management", (): void => { scope.patch(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}`) .reply(200, responses.apiCredential); - const response: models.ApiCredential = await management.MerchantApiCredentials.update(merchantId, apiCredentialId, requests.updateMerchantApiCredentialRequest); + const response: management.ApiCredential = await managementService.MerchantApiCredentials.update(merchantId, apiCredentialId, requests.updateMerchantApiCredentialRequest); expect(response).toBeTruthy(); }); @@ -257,7 +283,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateApiKey`) .reply(200, responses.generateApiKeyResponse); - const response: models.GenerateApiKeyResponse = await management.MerchantApiKey.create(merchantId, apiCredentialId); + const response: management.GenerateApiKeyResponse = await managementService.MerchantApiKey.create(merchantId, apiCredentialId); expect(response).toBeTruthy(); }); @@ -268,7 +294,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/apiCredentials/${apiCredentialId}/generateClientKey`) .reply(200, responses.generateClientKeyResponse); - const response: models.GenerateClientKeyResponse = await management.MerchantClientKey.create(merchantId, apiCredentialId); + const response: management.GenerateClientKeyResponse = await managementService.MerchantClientKey.create(merchantId, apiCredentialId); expect(response).toBeTruthy(); }); @@ -279,7 +305,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/paymentMethodSettings?storeId=1&businessLineId=1&pageNumber=1&pageSize=1`) .reply(200, responses.paymentMethodResponse); - const response: models.PaymentMethodResponse = await management.MerchantPaymentMethods.listPaymentMethodSettings(merchantId, { + const response: management.PaymentMethodResponse = await managementService.MerchantPaymentMethods.listPaymentMethodSettings(merchantId, { params: { "storeId": "1", "businessLineId": "1", @@ -295,9 +321,9 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/paymentMethodSettings`) .reply(200, responses.paymentMethod); - const response: models.PaymentMethod = await management.MerchantPaymentMethods.create(merchantId, { + const response: management.PaymentMethod = await managementService.MerchantPaymentMethods.create(merchantId, { ...requests.paymentMethodSetupInfo, - type: models.PaymentMethodSetupInfo.TypeEnum.Ideal + type: management.PaymentMethodSetupInfo.TypeEnum.Ideal }); expect(response).toBeTruthy(); @@ -307,7 +333,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`) .reply(200, responses.paymentMethod); - const response: models.PaymentMethod = await management.MerchantPaymentMethods.retrieve(merchantId, paymentMethodId); + const response: management.PaymentMethod = await managementService.MerchantPaymentMethods.retrieve(merchantId, paymentMethodId); expect(response).toBeTruthy(); }); @@ -316,7 +342,7 @@ describe("Management", (): void => { scope.patch(`/merchants/${merchantId}/paymentMethodSettings/${paymentMethodId}`) .reply(200, responses.paymentMethod); - const response: models.PaymentMethod = await management.MerchantPaymentMethods.update(merchantId, paymentMethodId, requests.updatePaymentMethodInfo); + const response: management.PaymentMethod = await managementService.MerchantPaymentMethods.update(merchantId, paymentMethodId, requests.updatePaymentMethodInfo); expect(response).toBeTruthy(); }); @@ -327,7 +353,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/payoutSettings`) .reply(200, responses.payoutSettingsResponse); - const response: models.PayoutSettingsResponse = await management.MerchantPayoutSettings.listPayoutSettings(merchantId); + const response: management.PayoutSettingsResponse = await managementService.MerchantPayoutSettings.listPayoutSettings(merchantId); expect(response).toBeTruthy(); }); @@ -336,7 +362,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/payoutSettings`) .reply(200, responses.payoutSettings); - const response: models.PayoutSettings = await management.MerchantPayoutSettings.create(merchantId, requests.payoutSettingsRequest); + const response: management.PayoutSettings = await managementService.MerchantPayoutSettings.create(merchantId, requests.payoutSettingsRequest); expect(response).toBeTruthy(); }); @@ -345,14 +371,14 @@ describe("Management", (): void => { scope.delete(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`) .reply(200); - await management.MerchantPayoutSettings.delete(merchantId, payoutSettingsId); + await managementService.MerchantPayoutSettings.delete(merchantId, payoutSettingsId); }); it("should support GET /merchants/{merchantId}/payoutSettings/{payoutSettingsId}", async (): Promise => { scope.get(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`) .reply(200, responses.payoutSettings); - const response: models.PayoutSettings = await management.MerchantPayoutSettings.retrieve(merchantId, payoutSettingsId); + const response: management.PayoutSettings = await managementService.MerchantPayoutSettings.retrieve(merchantId, payoutSettingsId); expect(response).toBeTruthy(); }); @@ -361,7 +387,7 @@ describe("Management", (): void => { scope.patch(`/merchants/${merchantId}/payoutSettings/${payoutSettingsId}`) .reply(200, responses.payoutSettings); - const response: models.PayoutSettings = await management.MerchantPayoutSettings.update(merchantId, payoutSettingsId, requests.updatePayoutSettingsRequest); + const response: management.PayoutSettings = await managementService.MerchantPayoutSettings.update(merchantId, payoutSettingsId, requests.updatePayoutSettingsRequest); expect(response).toBeTruthy(); }); @@ -372,7 +398,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/billingEntities?name=bill`) .reply(200, responses.billingEntitiesResponse); - const response: models.BillingEntitiesResponse = await management.MerchantTerminalOrders.listBillingEntities(merchantId, { + const response: management.BillingEntitiesResponse = await managementService.MerchantTerminalOrders.listBillingEntities(merchantId, { params: { "name": "bill" } @@ -385,7 +411,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/shippingLocations?name=1&offset=1&limit=1`) .reply(200, responses.shippingLocationsResponse); - const response: models.ShippingLocationsResponse = await management.MerchantTerminalOrders.listShippingLocations(merchantId, { + const response: management.ShippingLocationsResponse = await managementService.MerchantTerminalOrders.listShippingLocations(merchantId, { params: { "name": "1", "offset": "1", @@ -400,7 +426,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/shippingLocations`) .reply(200, responses.shippingLocation); - const response: models.ShippingLocation = await management.MerchantTerminalOrders.createShippingLocation(merchantId, requests.shippingLocation); + const response: management.ShippingLocation = await managementService.MerchantTerminalOrders.createShippingLocation(merchantId, requests.shippingLocation); expect(response).toBeTruthy(); }); @@ -409,7 +435,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/terminalModels`) .reply(200, responses.terminalModelsResponse); - const response: models.TerminalModelsResponse = await management.MerchantTerminalOrders.listTerminalModels(merchantId); + const response: management.TerminalModelsResponse = await managementService.MerchantTerminalOrders.listTerminalModels(merchantId); expect(response).toBeTruthy(); }); @@ -418,7 +444,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/terminalOrders?customerOrderReference=1&status=1&offset=1&limit=1`) .reply(200, responses.terminalOrdersResponse); - const response: models.TerminalOrdersResponse = await management.MerchantTerminalOrders.listTerminalOrders(merchantId, { + const response: management.TerminalOrdersResponse = await managementService.MerchantTerminalOrders.listTerminalOrders(merchantId, { params: { "customerOrderReference": "1", "status": "1", @@ -434,7 +460,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/terminalOrders`) .reply(200, responses.terminalOrder); - const response: models.TerminalOrder = await management.MerchantTerminalOrders.create(merchantId, requests.terminalOrderRequest); + const response: management.TerminalOrder = await managementService.MerchantTerminalOrders.create(merchantId, requests.terminalOrderRequest); expect(response).toBeTruthy(); }); @@ -443,7 +469,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/terminalOrders/${orderId}`) .reply(200, responses.terminalOrder); - const response: models.TerminalOrder = await management.MerchantTerminalOrders.retrieve(merchantId, orderId); + const response: management.TerminalOrder = await managementService.MerchantTerminalOrders.retrieve(merchantId, orderId); expect(response).toBeTruthy(); }); @@ -452,7 +478,7 @@ describe("Management", (): void => { scope.patch(`/merchants/${merchantId}/terminalOrders/${orderId}`) .reply(200, responses.terminalOrder); - const response: models.TerminalOrder = await management.MerchantTerminalOrders.update(merchantId, orderId, requests.terminalOrderRequest); + const response: management.TerminalOrder = await managementService.MerchantTerminalOrders.update(merchantId, orderId, requests.terminalOrderRequest); expect(response).toBeTruthy(); }); @@ -461,7 +487,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/terminalOrders/${orderId}/cancel`) .reply(200, responses.terminalOrder); - const response: models.TerminalOrder = await management.MerchantTerminalOrders.cancel(merchantId, orderId); + const response: management.TerminalOrder = await managementService.MerchantTerminalOrders.cancel(merchantId, orderId); expect(response).toBeTruthy(); }); @@ -470,7 +496,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/terminalProducts?country=1&terminalModelId=1&offset=1&limit=1`) .reply(200, responses.terminalProductsResponse); - const response: models.TerminalProductsResponse = await management.MerchantTerminalOrders.listTerminalProducts(merchantId, { + const response: management.TerminalProductsResponse = await managementService.MerchantTerminalOrders.listTerminalProducts(merchantId, { params: { "country": "1", "terminalModelId": "1", @@ -488,7 +514,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/terminalLogos?model=1`) .reply(200, responses.logo); - const response: models.Logo = await management.MerchantTerminalSettings.retrieveLogo(merchantId, { + const response: management.Logo = await managementService.MerchantTerminalSettings.retrieveLogo(merchantId, { params: { "model": "1" } @@ -501,7 +527,7 @@ describe("Management", (): void => { scope.patch(`/merchants/${merchantId}/terminalLogos?model=1`) .reply(200, responses.logo); - const response: models.Logo = await management.MerchantTerminalSettings.updateLogo(merchantId, requests.logo, { + const response: management.Logo = await managementService.MerchantTerminalSettings.updateLogo(merchantId, requests.logo, { params: { "model": "1" } @@ -514,7 +540,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/terminalSettings`) .reply(200, responses.terminalSettings); - const response: models.TerminalSettings = await management.MerchantTerminalSettings.retrieve(merchantId); + const response: management.TerminalSettings = await managementService.MerchantTerminalSettings.retrieve(merchantId); expect(response).toBeTruthy(); }); @@ -523,7 +549,7 @@ describe("Management", (): void => { scope.patch(`/merchants/${merchantId}/terminalSettings`) .reply(200, responses.terminalSettings); - const response: models.TerminalSettings = await management.MerchantTerminalSettings.update(merchantId, requests.terminalSettings); + const response: management.TerminalSettings = await managementService.MerchantTerminalSettings.update(merchantId, requests.terminalSettings); expect(response).toBeTruthy(); }); @@ -534,7 +560,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/users?pageNumber=1&pageSize=1`) .reply(200, responses.listMerchantUsersResponse); - const response: models.ListMerchantUsersResponse = await management.MerchantUsers.list(merchantId, { + const response: management.ListMerchantUsersResponse = await managementService.MerchantUsers.list(merchantId, { params: { "pageNumber": "1", "pageSize": "1" @@ -548,7 +574,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/users`) .reply(200, responses.createUserResponse); - const response: models.CreateUserResponse = await management.MerchantUsers.create(merchantId, requests.createMerchantUserRequest); + const response: management.CreateUserResponse = await managementService.MerchantUsers.create(merchantId, requests.createMerchantUserRequest); expect(response).toBeTruthy(); }); @@ -557,7 +583,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/users/${userId}`) .reply(200, responses.user); - const response: models.User = await management.MerchantUsers.retrieve(merchantId, userId); + const response: management.User = await managementService.MerchantUsers.retrieve(merchantId, userId); expect(response).toBeTruthy(); }); @@ -566,7 +592,7 @@ describe("Management", (): void => { scope.patch(`/merchants/${merchantId}/users/${userId}`) .reply(200, responses.user); - const response: models.User = await management.MerchantUsers.update(merchantId, userId, requests.updateMerchantUserRequest); + const response: management.User = await managementService.MerchantUsers.update(merchantId, userId, requests.updateMerchantUserRequest); expect(response).toBeTruthy(); }); @@ -577,7 +603,7 @@ describe("Management", (): void => { scope.get(`/merchants/${merchantId}/webhooks?pageNumber=1&pageSize=1`) .reply(200, responses.listWebhooksResponse); - const response: models.ListWebhooksResponse = await management.MerchantWebhooks.list(merchantId, { + const response: management.ListWebhooksResponse = await managementService.MerchantWebhooks.list(merchantId, { params: { "pageNumber": "1", "pageSize": "1" @@ -591,11 +617,11 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/webhooks`) .reply(200, responses.webhook); - const response: models.Webhook = await management.MerchantWebhooks.create(merchantId, { + const response: management.Webhook = await managementService.MerchantWebhooks.create(merchantId, { ...requests.createMerchantWebhookRequest, - communicationFormat: models.CreateMerchantWebhookRequest.CommunicationFormatEnum.Json, - networkType: models.CreateMerchantWebhookRequest.NetworkTypeEnum.Public, - sslVersion: models.CreateMerchantWebhookRequest.SslVersionEnum.Tls + communicationFormat: management.CreateMerchantWebhookRequest.CommunicationFormatEnum.Json, + networkType: management.CreateMerchantWebhookRequest.NetworkTypeEnum.Public, + sslVersion: management.CreateMerchantWebhookRequest.SslVersionEnum.Tls }); expect(response).toBeTruthy(); @@ -605,14 +631,14 @@ describe("Management", (): void => { scope.delete(`/merchants/${merchantId}/webhooks/${webhookId}`) .reply(204); - await management.MerchantWebhooks.delete(merchantId, webhookId); + await managementService.MerchantWebhooks.delete(merchantId, webhookId); }); it("should support GET /merchants/{merchantId}/webhooks/{webhookId}", async (): Promise => { scope.get(`/merchants/${merchantId}/webhooks/${webhookId}`) .reply(200, responses.webhook); - const response: models.Webhook = await management.MerchantWebhooks.retrieve(merchantId, webhookId); + const response: management.Webhook = await managementService.MerchantWebhooks.retrieve(merchantId, webhookId); expect(response).toBeTruthy(); }); @@ -621,11 +647,11 @@ describe("Management", (): void => { scope.patch(`/merchants/${merchantId}/webhooks/${webhookId}`) .reply(200, responses.webhook); - const response: models.Webhook = await management.MerchantWebhooks.update(merchantId, webhookId, { + const response: management.Webhook = await managementService.MerchantWebhooks.update(merchantId, webhookId, { ...requests.updateMerchantWebhookRequest, - communicationFormat: models.CreateMerchantWebhookRequest.CommunicationFormatEnum.Soap, - networkType: models.CreateMerchantWebhookRequest.NetworkTypeEnum.Local, - sslVersion: models.CreateMerchantWebhookRequest.SslVersionEnum.Sslv3 + communicationFormat: management.CreateMerchantWebhookRequest.CommunicationFormatEnum.Soap, + networkType: management.CreateMerchantWebhookRequest.NetworkTypeEnum.Local, + sslVersion: management.CreateMerchantWebhookRequest.SslVersionEnum.Sslv3 }); expect(response).toBeTruthy(); @@ -635,7 +661,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/webhooks/${webhookId}/generateHmac`) .reply(200, responses.generateHmacKeyResponse); - const response: models.GenerateHmacKeyResponse = await management.MerchantWebhooks.generateHmac(merchantId, webhookId); + const response: management.GenerateHmacKeyResponse = await managementService.MerchantWebhooks.generateHmac(merchantId, webhookId); expect(response).toBeTruthy(); }); @@ -644,7 +670,7 @@ describe("Management", (): void => { scope.post(`/merchants/${merchantId}/webhooks/${webhookId}/test`) .reply(200, responses.testWebhookResponse); - const testWebhookRequest: models.TestWebhookRequest = { + const testWebhookRequest: management.TestWebhookRequest = { "notification": { "amount": { "currency": "string", @@ -659,9 +685,45 @@ describe("Management", (): void => { }, "types": ["string"] }; - const response: models.TestWebhookResponse = await management.MerchantWebhooks.test(merchantId, webhookId, testWebhookRequest); + const response: management.TestWebhookResponse = await managementService.MerchantWebhooks.test(merchantId, webhookId, testWebhookRequest); expect(response).toBeTruthy(); }); }); + + describe("AllowedOriginsMerchantLevelApi", (): void => { + test("Delete an allowed origin", async () => { + scope.delete("/merchants/foo/apiCredentials/BAR123/allowedOrigins/fishy%20one").reply(204); + + await managementService.AllowedOriginsMerchantLevelApi + .deleteAllowedOrigin("foo", "BAR123", "fishy one"); + }); + + test("Create an allowed origin", async () => { + const requestBody = { + "domain": "https://www.eu.mystore.com" + }; + scope.post("/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL/allowedOrigins", requestBody) + .reply(200, { + "id": "YOUR_ALLOWED_ORIGIN", + "data": [ + { + "domain": "https://www.eu.mystore.com", + } + ], + "_links": { + "self": { + "href": "https://management-test.adyen.com/v1/merchants/YOUR_MERCHANT_ACCOUNT/apiCredentials/YOUR_API_CREDENTIAL/allowedOrigins/YOUR_ALLOWED_ORIGIN" + } + } + }); + + const response: management.AllowedOriginsResponse = await managementService.AllowedOriginsMerchantLevelApi + .createAllowedOrigin("YOUR_MERCHANT_ACCOUNT", "YOUR_API_CREDENTIAL", { + domain: "https://www.eu.mystore.com", + }); + + expect(response.data![0].domain).toEqual("https://www.eu.mystore.com"); + }); + }); }); diff --git a/src/__tests__/modification.spec.ts b/src/__tests__/modification.spec.ts index 15b6ad628..c95306ca4 100644 --- a/src/__tests__/modification.spec.ts +++ b/src/__tests__/modification.spec.ts @@ -154,7 +154,6 @@ let checkout: Checkout; let scope: nock.Scope; const paymentPspReference = "863620292981235A"; const invalidPaymentPspReference = "invalid_psp_reference"; -const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI); beforeEach((): void => { if (!nock.isActive()) { @@ -170,8 +169,7 @@ afterEach(() => { }); describe("Modification", (): void => { - test.each([isCI, true])("should perform an amount update request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should perform an amount update request", async (): Promise => { const request = createAmountUpdateRequest(); scope.post(`/payments/${paymentPspReference}/amountUpdates`) .reply(200, createAmountUpdateResponse()); @@ -187,8 +185,7 @@ describe("Modification", (): void => { } }); - test.each([false, true])("should fail to perform an amount update request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should fail to perform an amount update request", async (): Promise => { expect.assertions(2); const request = createAmountUpdateRequest(); scope.post(`/payments/${invalidPaymentPspReference}/amountUpdates`) @@ -206,8 +203,7 @@ describe("Modification", (): void => { } }); - test.each([isCI, true])("should perform a cancels request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should perform a cancels request", async (): Promise => { const request = createCancelsRequest(); scope.post(`/payments/${paymentPspReference}/cancels`) .reply(200, createCancelsResponse()); @@ -223,8 +219,7 @@ describe("Modification", (): void => { } }); - test.each([false, true])("should fail to perform a cancels request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should fail to perform a cancels request", async (): Promise => { expect.assertions(2); const request = createCancelsRequest(); scope.post(`/payments/${invalidPaymentPspReference}/cancels`) @@ -241,8 +236,7 @@ describe("Modification", (): void => { } }); - test.each([isCI, true])("should perform a standalone cancels request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should perform a standalone cancels request", async (): Promise => { const request = createStandaloneCancelsRequest(); scope.post("/cancels") .reply(200, createStandaloneCancelsResponse()); @@ -258,8 +252,7 @@ describe("Modification", (): void => { } }); - test.each([isCI, true])("should perform a captures request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should perform a captures request", async (): Promise => { const request = createCapturesRequest(); scope.post(`/payments/${paymentPspReference}/captures`) .reply(200, createCapturesResponse()); @@ -275,8 +268,7 @@ describe("Modification", (): void => { } }); - test.each([false, true])("should fail to perform a captures request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should fail to perform a captures request", async (): Promise => { expect.assertions(2); const request = createCapturesRequest(); scope.post(`/payments/${invalidPaymentPspReference}/captures`) @@ -293,8 +285,7 @@ describe("Modification", (): void => { } }); - test.each([isCI, true])("should perform a refunds request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should perform a refunds request", async (): Promise => { const request = createRefundsRequest(); scope.post(`/payments/${paymentPspReference}/refunds`) .reply(200, createRefundsResponse()); @@ -310,8 +301,7 @@ describe("Modification", (): void => { } }); - test.each([false, true])("should fail to perform a refunds request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should fail to perform a refunds request", async (): Promise => { expect.assertions(2); const request = createRefundsRequest(); scope.post(`/payments/${invalidPaymentPspReference}/refunds`) @@ -328,8 +318,7 @@ describe("Modification", (): void => { } }); - test.each([isCI, true])("should perform a reversals request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should perform a reversals request", async (): Promise => { const request = createReversalsRequest(); scope.post(`/payments/${paymentPspReference}/reversals`) .reply(200, createReversalsResponse()); @@ -345,8 +334,7 @@ describe("Modification", (): void => { } }); - test.each([false, true])("should fail to perform a reversals request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should fail to perform a reversals request", async (): Promise => { expect.assertions(2); const request = createReversalsRequest(); scope.post(`/payments/${invalidPaymentPspReference}/reversals`) diff --git a/src/__tests__/notification.spec.ts b/src/__tests__/notification.spec.ts index 8b07ac29e..01418b480 100644 --- a/src/__tests__/notification.spec.ts +++ b/src/__tests__/notification.spec.ts @@ -1,22 +1,3 @@ -/* - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * 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 authorisationTrue from "../__mocks__/notification/authorisationTrue.json"; import captureTrue from "../__mocks__/notification/captureTrue.json"; import captureFalse from "../__mocks__/notification/captureFalse.json"; diff --git a/src/__tests__/payout.spec.ts b/src/__tests__/payout.spec.ts index cf560cded..3edb1cce0 100644 --- a/src/__tests__/payout.spec.ts +++ b/src/__tests__/payout.spec.ts @@ -2,17 +2,9 @@ import nock from "nock"; import { createClient } from "../__mocks__/base"; import Payout from "../services/payout"; import Client from "../client"; -import { - ModifyRequest, - PayoutRequest, - Recurring, - StoreDetailAndSubmitRequest, - StoreDetailRequest, - SubmitRequest -} from "../typings/payouts/models"; +import { payouts } from "../typings"; import { ApiConstants } from "../constants/apiConstants"; -const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI); const storeDetailAndSubmitThirdParty = JSON.stringify({ additionalData: { fraudResultType: "GREEN", @@ -44,7 +36,7 @@ const defaultData = { shopperReference: "shopperReference", }; -const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): StoreDetailRequest => ({ +const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): payouts.StoreDetailRequest => ({ ...defaultData, card: { cvc: "737", @@ -53,29 +45,29 @@ const mockStoreDetailRequest = (merchantAccount: string = process.env.ADYEN_MERC number: "4111111111111111", holderName: "John Smith" }, - entityType: StoreDetailRequest.EntityTypeEnum.Company, + entityType: payouts.StoreDetailRequest.EntityTypeEnum.Company, recurring: { - contract: Recurring.ContractEnum.Payout, + contract: payouts.Recurring.ContractEnum.Payout, }, merchantAccount, }); -const mockSubmitRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): SubmitRequest => ({ +const mockSubmitRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): payouts.SubmitRequest => ({ selectedRecurringDetailReference: "LATEST", recurring: { - contract: Recurring.ContractEnum.Payout + contract: payouts.Recurring.ContractEnum.Payout }, ...defaultData, ...amountAndReference, merchantAccount, }); -const mockStoreDetailAndSubmitRequest = (merchantAccount?: string): StoreDetailAndSubmitRequest => ({ +const mockStoreDetailAndSubmitRequest = (merchantAccount?: string): payouts.StoreDetailAndSubmitRequest => ({ ...amountAndReference, ...(mockStoreDetailRequest(merchantAccount)), }); -const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): PayoutRequest => ({ +const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT!): payouts.PayoutRequest => ({ ...amountAndReference, ...defaultData, card: { @@ -90,7 +82,7 @@ const mockPayoutRequest = (merchantAccount: string = process.env.ADYEN_MERCHANT! let client: Client; let clientStore: Client; let clientReview: Client; -let payout: Payout; +let payoutService: Payout; let scope: nock.Scope; beforeEach((): void => { @@ -101,7 +93,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}`); - payout = new Payout(client); + payoutService = new Payout(client); }); afterEach((): void => { @@ -109,60 +101,56 @@ 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(); - payout = new Payout(clientStore); - const request: StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest(); + test("should succeed on store detail and submit third party", async function (): Promise { + payoutService = new Payout(clientStore); + const request: payouts.StoreDetailAndSubmitRequest = mockStoreDetailAndSubmitRequest(); scope.post("/storeDetailAndSubmitThirdParty").reply(200, storeDetailAndSubmitThirdParty); - const result = await payout.storeDetailAndSubmitThirdParty(request); + const result = await payoutService.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(); - payout = new Payout(clientStore); + test("should succeed on store detail", async function (): Promise { + payoutService = new Payout(clientStore); scope.post("/storeDetail").reply(200, storeDetail); - const request: StoreDetailRequest = mockStoreDetailRequest(); - const result = await payout.storeDetail(request); + const request: payouts.StoreDetailRequest = mockStoreDetailRequest(); + const result = await payoutService.storeDetail(request); expect("Success").toEqual(result.resultCode); expect(result.pspReference).toBeTruthy(); expect(result.recurringDetailReference).toBeTruthy(); }); - test.each([isCI, true])("should succeed on confirm third party, isMock: %p", async function (isMock): Promise { - !isMock && nock.restore(); - payout = new Payout(clientStore); + test("should succeed on confirm third party", async function (): Promise { + payoutService = new Payout(clientStore); scope.post("/storeDetail").reply(200, storeDetail); - const storeRequest: StoreDetailRequest = mockStoreDetailRequest(); - const storeResult = await payout.storeDetail(storeRequest); + const storeRequest: payouts.StoreDetailRequest = mockStoreDetailRequest(); + const storeResult = await payoutService.storeDetail(storeRequest); - payout = new Payout(clientReview); + payoutService = new Payout(clientReview); scope.post("/confirmThirdParty") .reply(200, { pspReference: "8815131762537886", response: "[payout-confirm-received]" }); - const request: ModifyRequest = { + const request: payouts.ModifyRequest = { merchantAccount: process.env.ADYEN_MERCHANT!, originalReference: storeResult.pspReference }; - const result = await payout.confirmThirdParty(request); + const result = await payoutService.confirmThirdParty(request); expect(result.response).toEqual("[payout-confirm-received]"); expect(result.pspReference).toBeTruthy(); }); - test.each([isCI, true])("should succeed on submit third party, isMock: %p", async function (isMock): Promise { - !isMock && nock.restore(); - payout = new Payout(clientStore); + test("should succeed on submit third party", async function (): Promise { + payoutService = new Payout(clientStore); scope.post("/submitThirdParty").reply(200, storeDetailAndSubmitThirdParty); - const request: SubmitRequest = mockSubmitRequest(); - const result = await payout.submitThirdparty(request); + const request: payouts.SubmitRequest = mockSubmitRequest(); + const result = await payoutService.submitThirdparty(request); expect(result.resultCode).toEqual("[payout-submit-received]"); expect(result.pspReference).toBeTruthy(); @@ -173,15 +161,14 @@ describe("PayoutTest", function (): void { } }); - test.each([false, true])("should succeed on decline third party, isMock: %p", async function (isMock): Promise { - !isMock && nock.restore(); - payout = new Payout(clientStore); + test("should succeed on decline third party", async function (): Promise { + payoutService = new Payout(clientStore); scope.post("/storeDetail").reply(200, storeDetail); - const storeRequest: StoreDetailRequest = mockStoreDetailRequest(); - const storeResult = await payout.storeDetail(storeRequest); + const storeRequest: payouts.StoreDetailRequest = mockStoreDetailRequest(); + const storeResult = await payoutService.storeDetail(storeRequest); - payout = new Payout(clientReview); - const request: ModifyRequest = { + payoutService = new Payout(clientReview); + const request: payouts.ModifyRequest = { merchantAccount: process.env.ADYEN_MERCHANT!, originalReference: storeResult.pspReference }; @@ -190,21 +177,20 @@ describe("PayoutTest", function (): void { pspReference: "8815131762537886", response: "[payout-decline-received]" }); - const result = await payout.declineThirdParty(request); + const result = await payoutService.declineThirdParty(request); expect(result.response).toEqual("[payout-decline-received]"); expect(result.pspReference).toBeTruthy(); }); - test.each([isCI, true])("should succeed on payout, isMock: %p", async function (isMock): Promise { - !isMock && nock.restore(); + test("should succeed on payout", async function (): Promise { scope.post("/payout").reply(200, { pspReference: "8815131762537886", resultCode: "Received", }); const request = mockPayoutRequest(); - const result = await payout.payout(request); + const result = await payoutService.payout(request); expect(result.resultCode).toEqual("Received"); expect(result.pspReference).toBeTruthy(); diff --git a/src/__tests__/platforms.spec.ts b/src/__tests__/platforms.spec.ts index 27a3cbc17..16041b9ec 100644 --- a/src/__tests__/platforms.spec.ts +++ b/src/__tests__/platforms.spec.ts @@ -1,22 +1,3 @@ -/* - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * 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 nock from "nock"; import { createMock } from "ts-auto-mock"; import { createBasicAuthClient } from "../__mocks__/base"; diff --git a/src/__tests__/recurring.spec.ts b/src/__tests__/recurring.spec.ts index 3a1e429d4..3b9f24b11 100644 --- a/src/__tests__/recurring.spec.ts +++ b/src/__tests__/recurring.spec.ts @@ -5,30 +5,21 @@ import { listRecurringDetailsSuccess } from "../__mocks__/recurring/listRecurrin import { notifyShopperSuccess } from "../__mocks__/recurring/notifyShopperSuccess"; import RecurringService from "../services/recurring"; import Client from "../client"; -import { paymentsSuccess } from "../__mocks__/checkout/paymentsSuccess"; -import { createPaymentsCheckoutRequest } from "./checkout.spec"; -import Checkout from "../services/checkout"; -import { PaymentRequest } from "../typings/checkout/models"; -import { - ScheduleAccountUpdaterRequest, - ScheduleAccountUpdaterResult, - DisableRequest, - RecurringDetailsRequest, - Recurring, - NotifyShopperRequest -} from "../typings/recurring/models"; - -const createRecurringDetailsRequest = (): RecurringDetailsRequest => { +import { recurring } from "../typings"; +import {Permit} from "../typings/recurring/permit"; +import {CreatePermitRequest} from "../typings/recurring/createPermitRequest"; +import {ObjectSerializer} from "../typings/recurring/models"; + +const createRecurringDetailsRequest = (): recurring.RecurringDetailsRequest => { return { merchantAccount: process.env.ADYEN_MERCHANT!, - recurring: { contract: Recurring.ContractEnum.Recurring }, + recurring: { contract: recurring.Recurring.ContractEnum.Recurring }, shopperReference: "shopperReference", }; }; let client: Client; -let recurring: RecurringService; -let checkout: Checkout; +let recurringService: RecurringService; let scope: nock.Scope; beforeEach((): void => { @@ -36,8 +27,7 @@ beforeEach((): void => { nock.activate(); } client = createClient(); - recurring = new RecurringService(client); - checkout = new Checkout(client); + recurringService = new RecurringService(client); scope = nock(`${client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}`); }); @@ -51,30 +41,24 @@ describe("Recurring", (): void => { .reply(200, listRecurringDetailsSuccess); const request = createRecurringDetailsRequest(); - const result = await recurring.listRecurringDetails(request); + const result = await recurringService.listRecurringDetails(request); expect(result).toBeTruthy(); expect(result.details?.[0].recurringDetailReference).toBe("recurringReference"); }); test("should disable", async (): Promise => { - scope.post("/payments") - .reply(200, paymentsSuccess); - - const paymentsRequest: PaymentRequest = createPaymentsCheckoutRequest(); - const res = await checkout.payments(paymentsRequest); - scope.post("/disable") .reply(200, disableSuccess); - const request: DisableRequest = { + const request: recurring.DisableRequest = { merchantAccount: process.env.ADYEN_MERCHANT!, shopperReference: "shopperReference", - recurringDetailReference: res.additionalData!["recurring.recurringDetailReference"] + recurringDetailReference: "recurring.recurringDetailReference", }; try { - const result = await recurring.disable(request); + const result = await recurringService.disable(request); expect(result).toBeTruthy(); } catch (e) { fail(e); @@ -85,7 +69,7 @@ describe("Recurring", (): void => { scope.post("/notifyShopper") .reply(200, notifyShopperSuccess); - const notifyShopperRequest: NotifyShopperRequest = { + const notifyShopperRequest: recurring.NotifyShopperRequest = { merchantAccount: process.env.ADYEN_MERCHANT!, shopperReference: "shopperReference", storedPaymentMethodId: "8415995487234100", @@ -99,7 +83,7 @@ describe("Recurring", (): void => { }; try { - const result = await recurring.notifyShopper(notifyShopperRequest); + const result = await recurringService.notifyShopper(notifyShopperRequest); expect(result).toBeTruthy(); } catch (e) { fail(e); @@ -108,7 +92,7 @@ describe("Recurring", (): void => { test("should schedule account updater", async (): Promise => { - const scheduleAccountUpdaterSuccess: ScheduleAccountUpdaterResult = { + const scheduleAccountUpdaterSuccess: recurring.ScheduleAccountUpdaterResult = { pspReference: "mocked_psp", result: "SUCCESS" }; @@ -116,7 +100,7 @@ describe("Recurring", (): void => { scope.post("/scheduleAccountUpdater") .reply(200, scheduleAccountUpdaterSuccess); - const request: ScheduleAccountUpdaterRequest = { + const request: recurring.ScheduleAccountUpdaterRequest = { merchantAccount: process.env.ADYEN_MERCHANT!, reference: "ref", card: { @@ -128,7 +112,60 @@ describe("Recurring", (): void => { }; try { - const result = await recurring.scheduleAccountUpdater(request); + const result = await recurringService.scheduleAccountUpdater(request); + expect(result).toBeTruthy(); + } catch (e) { + fail(e); + } + }); + + test("should do a createPermit request", async (): Promise => { + const createPermitResultSuccess: recurring.CreatePermitResult = { + pspReference: "1234567890" + }; + + scope.post("/createPermit") + .reply(200, createPermitResultSuccess); + + const permit: Permit = { + validTillDate: new Date("2022-03-25"), + partnerId: "partnerID" + }; + + const request: recurring.CreatePermitRequest = { + permits: [permit], + merchantAccount: process.env.ADYEN_MERCHANT!, + shopperReference: "shopperRef", + recurringDetailReference: "recurringRef", + }; + + const serializedRequest: CreatePermitRequest = ObjectSerializer.serialize(request, "CreatePermitRequest"); + expect(serializedRequest.permits[0].validTillDate?.toString()).toBe("2022-03-25T00:00:00.000Z"); + + try { + const result = await recurringService.createPermit(request); + expect(result).toBeTruthy(); + } catch (e) { + fail(e); + } + }); + + test("should do a disablePermit request", async (): Promise => { + const disablePermitResultSuccess: recurring.DisablePermitResult = { + pspReference: "1234567890", + status: "disabled", + }; + + scope.post("/disablePermit") + .reply(200, disablePermitResultSuccess); + + const request: recurring.DisablePermitRequest = { + merchantAccount: process.env.ADYEN_MERCHANT!, + token: "permitToken" + }; + + try { + const result = await recurringService.disablePermit(request); expect(result).toBeTruthy(); } catch (e) { fail(e); diff --git a/src/__tests__/storedValue.spec.ts b/src/__tests__/storedValue.spec.ts index ef24809f8..848ef8ae3 100644 --- a/src/__tests__/storedValue.spec.ts +++ b/src/__tests__/storedValue.spec.ts @@ -2,23 +2,11 @@ import nock from "nock"; import Client from "../client"; import {createClient} from "../__mocks__/base"; import {StoredValue} from "../services"; -import { StoredValueIssueRequest, - StoredValueIssueResponse, - StoredValueStatusChangeRequest, - StoredValueStatusChangeResponse, - StoredValueLoadRequest, - StoredValueLoadResponse, - StoredValueBalanceCheckRequest, - StoredValueBalanceCheckResponse, - StoredValueBalanceMergeRequest, - StoredValueBalanceMergeResponse, - StoredValueVoidRequest, - StoredValueVoidResponse -} from "../typings/storedValue/models"; +import { storedValue } from "../typings"; let client: Client; -let storedValue: StoredValue; +let storedValueService: StoredValue; let scope: nock.Scope; beforeEach((): void => { @@ -27,7 +15,7 @@ beforeEach((): void => { } client = createClient(); scope = nock(`${client.config.storedValueEndpoint}/${Client.STOREDVALUE_API_VERSION}`); - storedValue = new StoredValue(client); + storedValueService = new StoredValue(client); }); afterEach(() => { @@ -50,7 +38,7 @@ describe("StoredValue", (): void => { "type": "givex" } }); - const issueRequest: StoredValueIssueRequest = { + const issueRequest: storedValue.StoredValueIssueRequest = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store": "YOUR_STORE_ID", "paymentMethod": { @@ -63,7 +51,7 @@ describe("StoredValue", (): void => { "reference": "YOUR_REFERENCE" }; - const issueResponse: StoredValueIssueResponse = await storedValue.issue(issueRequest); + const issueResponse: storedValue.StoredValueIssueResponse = await storedValueService.issue(issueRequest); expect(issueResponse.pspReference).toEqual("851564651069192J"); }); @@ -83,7 +71,7 @@ describe("StoredValue", (): void => { "type": "givex" } }); - const issueRequest: StoredValueIssueRequest = { + const issueRequest: storedValue.StoredValueIssueRequest = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store": "YOUR_STORE_ID", "paymentMethod": { @@ -93,7 +81,7 @@ describe("StoredValue", (): void => { "reference": "YOUR_REFERENCE" }; - const issueResponse: StoredValueIssueResponse = await storedValue.issue(issueRequest); + const issueResponse: storedValue.StoredValueIssueResponse = await storedValueService.issue(issueRequest); expect(issueResponse.pspReference).toEqual("851564651069192J"); }); @@ -109,8 +97,8 @@ describe("StoredValue", (): void => { "resultCode": "Success" }); - const statusRequest: StoredValueStatusChangeRequest = { - "status": StoredValueStatusChangeRequest.StatusEnum.Active, + const statusRequest: storedValue.StoredValueStatusChangeRequest = { + "status": storedValue.StoredValueStatusChangeRequest.StatusEnum.Active, "amount": { "currency": "USD", "value": 1000 @@ -125,7 +113,7 @@ describe("StoredValue", (): void => { "reference": "YOUR_REFERENCE" }; - const changeStatusResponse: StoredValueStatusChangeResponse = await storedValue.changeStatus(statusRequest); + const changeStatusResponse: storedValue.StoredValueStatusChangeResponse = await storedValueService.changeStatus(statusRequest); expect(changeStatusResponse.pspReference).toEqual("851564652149588K"); }); @@ -140,8 +128,8 @@ describe("StoredValue", (): void => { "resultCode": "Success" }); - const statusRequest: StoredValueStatusChangeRequest = { - "status": StoredValueStatusChangeRequest.StatusEnum.Inactive, + const statusRequest: storedValue.StoredValueStatusChangeRequest = { + "status": storedValue.StoredValueStatusChangeRequest.StatusEnum.Inactive, "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store":"YOUR_STORE_ID", "paymentMethod": { @@ -149,11 +137,11 @@ describe("StoredValue", (): void => { }, "recurringDetailReference": "7219627091701347", "shopperReference": "YOUR_UNIQUE_SHOPPER_ID_P3fW3k9D2tvXFu6l", - "shopperInteraction": StoredValueStatusChangeRequest.ShopperInteractionEnum.Ecommerce, + "shopperInteraction": storedValue.StoredValueStatusChangeRequest.ShopperInteractionEnum.Ecommerce, "reference": "YOUR_REFERENCE" }; - const changeStatusResponse: StoredValueStatusChangeResponse = await storedValue.changeStatus(statusRequest); + const changeStatusResponse: storedValue.StoredValueStatusChangeResponse = await storedValueService.changeStatus(statusRequest); expect(changeStatusResponse.pspReference).toEqual("851564652149588K"); }); @@ -168,12 +156,12 @@ describe("StoredValue", (): void => { "resultCode": "Success" }); - const loadRequest: StoredValueLoadRequest = { + const loadRequest: storedValue.StoredValueLoadRequest = { "amount": { "currency": "USD", "value": 2000 }, - "loadType": StoredValueLoadRequest.LoadTypeEnum.MerchandiseReturn, + "loadType": storedValue.StoredValueLoadRequest.LoadTypeEnum.MerchandiseReturn, "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store":"YOUR_STORE_ID", "paymentMethod": { @@ -184,7 +172,7 @@ describe("StoredValue", (): void => { "reference": "YOUR_REFERENCE" }; - const loadResponse: StoredValueLoadResponse = await storedValue.load(loadRequest); + const loadResponse: storedValue.StoredValueLoadResponse = await storedValueService.load(loadRequest); expect(loadResponse.pspReference).toEqual("851564654294247B"); }); @@ -199,7 +187,7 @@ describe("StoredValue", (): void => { "resultCode": "Success" }); - const checkBalanceRequest: StoredValueBalanceCheckRequest = { + const checkBalanceRequest: storedValue.StoredValueBalanceCheckRequest = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store":"YOUR_STORE_ID", "paymentMethod": { @@ -210,7 +198,7 @@ describe("StoredValue", (): void => { "reference": "YOUR_REFERENCE" }; - const checkBalanceResponse: StoredValueBalanceCheckResponse = await storedValue.checkBalance(checkBalanceRequest); + const checkBalanceResponse: storedValue.StoredValueBalanceCheckResponse = await storedValueService.checkBalance(checkBalanceRequest); expect(checkBalanceResponse.pspReference).toEqual("881564657480267D"); }); @@ -225,7 +213,7 @@ describe("StoredValue", (): void => { "resultCode": "Success" }); - const mergeBalanceRequest: StoredValueBalanceMergeRequest = { + const mergeBalanceRequest: storedValue.StoredValueBalanceMergeRequest = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "store":"YOUR_STORE_ID", "sourcePaymentMethod": { @@ -240,7 +228,7 @@ describe("StoredValue", (): void => { "reference": "YOUR_REFERENCE" }; - const mergeBalanceResponse: StoredValueBalanceMergeResponse = await storedValue.mergebalance(mergeBalanceRequest); + const mergeBalanceResponse: storedValue.StoredValueBalanceMergeResponse = await storedValueService.mergebalance(mergeBalanceRequest); expect(mergeBalanceResponse.pspReference).toEqual("881564657480267D"); }); @@ -255,13 +243,13 @@ describe("StoredValue", (): void => { "resultCode": "Success" }); - const voidTransactionRequest: StoredValueVoidRequest = { + const voidTransactionRequest: storedValue.StoredValueVoidRequest = { "merchantAccount": "YOUR_MERCHANT_ACCOUNT", "originalReference": "851564654294247B", "reference": "YOUR_REFERENCE" }; - const voidTransactionResponse: StoredValueVoidResponse = await storedValue.voidTransaction(voidTransactionRequest); + const voidTransactionResponse: storedValue.StoredValueVoidResponse = await storedValueService.voidTransaction(voidTransactionRequest); expect(voidTransactionResponse.pspReference).toEqual("851564673300692A"); }); }); \ No newline at end of file diff --git a/src/__tests__/terminalCloudAPI.spec.ts b/src/__tests__/terminalCloudAPI.spec.ts index 30b2a4496..00fd1f7a3 100644 --- a/src/__tests__/terminalCloudAPI.spec.ts +++ b/src/__tests__/terminalCloudAPI.spec.ts @@ -1,29 +1,10 @@ -/* - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * Adyen NodeJS API Library - * Copyright (c) 2022 Adyen N.V. - * This file is open source and available under the MIT license. - * See the LICENSE file for more info. - */ - import nock from "nock"; import { createClient, createTerminalAPIPaymentRequest, createTerminalAPIRefundRequest } from "../__mocks__/base"; import { asyncRes } from "../__mocks__/terminalApi/async"; import { syncRefund, syncRes, syncResEventNotification } from "../__mocks__/terminalApi/sync"; import Client from "../client"; import TerminalCloudAPI from "../services/terminalCloudAPI"; -import { SaleToAcquirerData, TerminalApiResponse } from "../typings/terminal/models"; +import { terminal} from "../typings"; let client: Client; let terminalCloudAPI: TerminalCloudAPI; @@ -44,10 +25,8 @@ afterEach((): void => { nock.cleanAll(); }); -const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI); describe("Terminal Cloud API", (): void => { - test.each([isCI])("should make an async payment request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should make an async payment request", async (): Promise => { scope.post("/async").reply(200, asyncRes); const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest(); @@ -57,19 +36,17 @@ describe("Terminal Cloud API", (): void => { expect(requestResponse).toEqual("ok"); }); - test.each([isCI])("should make a sync payment request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should make a sync payment request", async (): Promise => { scope.post("/sync").reply(200, syncRes); const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest(); - const terminalAPIResponse: TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest); + const terminalAPIResponse: terminal.TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest); expect(terminalAPIResponse.SaleToPOIResponse?.PaymentResponse).toBeDefined(); expect(terminalAPIResponse.SaleToPOIResponse?.MessageHeader).toBeDefined(); }); - test.each([isCI])("should return event notification if response contains it, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should return event notification if response contains it", async (): Promise => { const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest(); scope.post("/sync").reply(200, syncResEventNotification); @@ -79,12 +56,11 @@ describe("Terminal Cloud API", (): void => { expect(terminalAPIResponse.SaleToPOIRequest?.EventNotification).toBeDefined(); }); - test.each([isCI])("should make an async refund request, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should make an async refund request", async (): Promise => { scope.post("/sync").reply(200, syncRes); const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest(); - const terminalAPIResponse: TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest); + const terminalAPIResponse: terminal.TerminalApiResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest); const pOITransactionId = terminalAPIResponse.SaleToPOIResponse!.PaymentResponse!.POIData!.POITransactionID; expect(pOITransactionId).toBeTruthy(); @@ -94,7 +70,7 @@ describe("Terminal Cloud API", (): void => { const terminalAPIRefundRequest = createTerminalAPIRefundRequest(pOITransactionId); const id = Math.floor(Math.random() * Math.floor(10000000)).toString(); terminalAPIRefundRequest.SaleToPOIRequest.MessageHeader.ServiceID = id; - const saleToAcquirerData: SaleToAcquirerData = new SaleToAcquirerData(); + const saleToAcquirerData: terminal.SaleToAcquirerData = new terminal.SaleToAcquirerData(); saleToAcquirerData.currency = "EUR"; terminalAPIRefundRequest.SaleToPOIRequest.ReversalRequest!.SaleData!.SaleToAcquirerData = saleToAcquirerData; const terminalAPIRefundResponse = await terminalCloudAPI.sync(terminalAPIRefundRequest); diff --git a/src/__tests__/terminalLocalAPI.spec.ts b/src/__tests__/terminalLocalAPI.spec.ts index 61da4a298..7832fc653 100644 --- a/src/__tests__/terminalLocalAPI.spec.ts +++ b/src/__tests__/terminalLocalAPI.spec.ts @@ -1,28 +1,9 @@ -/* - * ###### - * ###### - * ############ ####( ###### #####. ###### ############ ############ - * ############# #####( ###### #####. ###### ############# ############# - * ###### #####( ###### #####. ###### ##### ###### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### - * ###### ###### #####( ###### #####. ###### ##### ##### ###### - * ############# ############# ############# ############# ##### ###### - * ############ ############ ############# ############ ##### ###### - * ###### - * ############# - * ############ - * Adyen NodeJS API Library - * Copyright (c) 2021 Adyen B.V. - * This file is open source and available under the MIT license. - * See the LICENSE file for more info. - */ - import nock from "nock"; import { createClient, createTerminalAPIPaymentRequest } from "../__mocks__/base"; import { localEncRes, wrongEncRes } from "../__mocks__/terminalApi/local"; import Client from "../client"; import TerminalLocalAPI from "../services/terminalLocalAPI"; -import { SecurityKey, TerminalApiResponse } from "../typings/terminal/models"; +import { terminal } from "../typings"; import NexoCryptoException from "../services/exception/nexoCryptoException"; let client: Client; @@ -43,34 +24,30 @@ afterEach((): void => { nock.cleanAll(); }); -const isCI = process.env.CI === "true" || (typeof process.env.CI === "boolean" && process.env.CI); - describe("Terminal Local API", (): void => { - test.each([isCI, true])("should make a local payment, isMock: %p", async (isMock): Promise => { - !isMock && nock.restore(); + test("should make a local payment", async (): Promise => { scope.post("/").reply(200, localEncRes); const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest(); - const securityKey: SecurityKey = { + const securityKey: terminal.SecurityKey = { AdyenCryptoVersion: 0, KeyIdentifier: "CryptoKeyIdentifier12345", KeyVersion: 0, Passphrase: "p@ssw0rd123456", }; - const terminalApiResponse: TerminalApiResponse = + const terminalApiResponse: terminal.TerminalApiResponse = await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey); expect(terminalApiResponse.SaleToPOIResponse?.PaymentResponse).toBeDefined(); expect(terminalApiResponse.SaleToPOIResponse?.MessageHeader).toBeDefined(); }); - test.each([isCI, true])("should return NexoCryptoException, isMock: %p", async (isMock: boolean): Promise => { - !isMock && nock.restore(); + test("should return NexoCryptoException", async (): Promise => { scope.post("/").reply(200, wrongEncRes); const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest(); - const securityKey: SecurityKey = { + const securityKey: terminal.SecurityKey = { AdyenCryptoVersion: 0, KeyIdentifier: "CryptoKeyIdentifier12345", KeyVersion: 0, diff --git a/src/__tests__/terminalManagement.spec.ts b/src/__tests__/terminalManagement.spec.ts index 8a438bc8d..978ab7b0a 100644 --- a/src/__tests__/terminalManagement.spec.ts +++ b/src/__tests__/terminalManagement.spec.ts @@ -2,21 +2,10 @@ import nock from "nock"; import Client from "../client"; import { createClient } from "../__mocks__/base"; import TerminalManagement from "../services/terminalManagement"; -import { - AssignTerminalsRequest, - AssignTerminalsResponse, - FindTerminalRequest, - FindTerminalResponse, - GetStoresUnderAccountRequest, - GetStoresUnderAccountResponse, - GetTerminalDetailsRequest, - GetTerminalDetailsResponse, - GetTerminalsUnderAccountRequest, - GetTerminalsUnderAccountResponse -} from "../typings/terminalManagement/models"; +import { terminalManagement } from "../typings"; let client: Client; -let terminalManagement: TerminalManagement; +let terminalManagementService: TerminalManagement; let scope: nock.Scope; beforeEach((): void => { @@ -25,7 +14,7 @@ beforeEach((): void => { } client = createClient(); scope = nock(`${client.config.terminalManagementEndpoint}/${Client.TERMINAL_MANAGEMENT_API_VERSION}`); - terminalManagement = new TerminalManagement(client); + terminalManagementService = new TerminalManagement(client); }); afterEach(() => { @@ -40,14 +29,14 @@ describe("POS Terminal Management API", (): void => { "P400Plus-275479597": "RemoveConfigScheduled" } }); - const request: AssignTerminalsRequest = { + const request: terminalManagement.AssignTerminalsRequest = { "companyAccount": "YOUR_COMPANY_ACCOUNT", "terminals": [ "P400Plus-275479597" ] }; - const response: AssignTerminalsResponse = await terminalManagement.assignTerminals(request); + const response: terminalManagement.AssignTerminalsResponse = await terminalManagementService.assignTerminals(request); expect(response.results["P400Plus-275479597"]).toEqual("RemoveConfigScheduled"); }); @@ -60,11 +49,11 @@ describe("POS Terminal Management API", (): void => { "merchantInventory": false, "terminal": "P400Plus-275479597" }); - const request: FindTerminalRequest = { + const request: terminalManagement.FindTerminalRequest = { "terminal": "P400Plus-275479597" }; - const response: FindTerminalResponse = await terminalManagement.findTerminal(request); + const response: terminalManagement.FindTerminalResponse = await terminalManagementService.findTerminal(request); expect(response.terminal).toEqual("P400Plus-275479597"); }); @@ -87,11 +76,11 @@ describe("POS Terminal Management API", (): void => { } ] }); - const request: GetStoresUnderAccountRequest = { + const request: terminalManagement.GetStoresUnderAccountRequest = { "companyAccount": "YOUR_COMPANY_ACCOUNT" }; - const response: GetStoresUnderAccountResponse = await terminalManagement.getStoresUnderAccount(request); + const response: terminalManagement.GetStoresUnderAccountResponse = await terminalManagementService.getStoresUnderAccount(request); expect(response.stores).toHaveLength(1); expect(response.stores![0].status).toEqual("Active"); @@ -113,11 +102,11 @@ describe("POS Terminal Management API", (): void => { "country": "NETHERLANDS", "dhcpEnabled": false }); - const request: GetTerminalDetailsRequest = { + const request: terminalManagement.GetTerminalDetailsRequest = { "terminal": "P400Plus-275479597" }; - const response: GetTerminalDetailsResponse = await terminalManagement.getTerminalDetails(request); + const response: terminalManagement.GetTerminalDetailsResponse = await terminalManagementService.getTerminalDetails(request); expect(response.deviceModel).toBe("P400Plus"); }); @@ -144,11 +133,11 @@ describe("POS Terminal Management API", (): void => { } ] }); - const request: GetTerminalsUnderAccountRequest = { + const request: terminalManagement.GetTerminalsUnderAccountRequest = { "companyAccount": "YOUR_COMPANY_ACCOUNT" }; - const response: GetTerminalsUnderAccountResponse = await terminalManagement.getTerminalsUnderAccount(request); + const response: terminalManagement.GetTerminalsUnderAccountResponse = await terminalManagementService.getTerminalsUnderAccount(request); expect(response.merchantAccounts).toHaveLength(1); expect(response.merchantAccounts![0].stores).toHaveLength(1); diff --git a/src/__tests__/transfers.spec.ts b/src/__tests__/transfers.spec.ts index 50086e4e6..d14d99e19 100644 --- a/src/__tests__/transfers.spec.ts +++ b/src/__tests__/transfers.spec.ts @@ -3,7 +3,7 @@ import { createClient } from "../__mocks__/base"; import { transfersSuccess, getTransactionSuccess, listTransactionsSuccess } from "../__mocks__/transfers/responses"; import Client from "../client"; import { Transfers } from "../services"; -import { TransferInfo, Transfer, Transaction, TransactionSearchResponse, IbanAccountIdentification} from "../typings/transfer/models"; +import { transfer} from "../typings"; let client: Client; let transferService: Transfers; @@ -26,9 +26,9 @@ describe("Transfers", (): void => { test("should transfer fund", async (): Promise => { scope.post("/transfers") .reply(200, transfersSuccess); - const request = new TransferInfo(); + const request = new transfer.TransferInfo(); request.amount = { currency: "EUR", value: 1000}; - request.category = TransferInfo.CategoryEnum.Bank; + request.category = transfer.TransferInfo.CategoryEnum.Bank; request.counterparty = { balanceAccountId: "123", transferInstrumentId: "transfer_id", @@ -38,26 +38,26 @@ describe("Transfers", (): void => { }, accountIdentification: { iban: "NLRABO12321", - type: IbanAccountIdentification.TypeEnum.Iban + type: transfer.IbanAccountIdentification.TypeEnum.Iban } }, }; - const response: Transfer = await transferService.transfers(request); + const response: transfer.Transfer = await transferService.transfers(request); expect(response.id).toEqual("1W1UG35U8A9J5ZLG"); }); test("should get transaction", async (): Promise => { scope.get("/transactions/123") .reply(200, getTransactionSuccess); - const response: Transaction = await transferService.getTransaction("123"); + const response: transfer.Transaction = await transferService.getTransaction("123"); expect(response.id).toEqual("IZK7C25U7DYVX03Y"); }); test("should list transactions", async (): Promise => { scope.get("/transactions") .reply(200, listTransactionsSuccess); - const response: TransactionSearchResponse = await transferService.listTransactions(); + const response: transfer.TransactionSearchResponse = await transferService.listTransactions(); expect(response.data?.length).toEqual(3); if(response.data && response.data?.length > 0) { expect(response?.data[0]?.id).toEqual("1VVF0D5U66PIUIVP"); diff --git a/src/client.ts b/src/client.ts index e23c9700b..035be110c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -6,6 +6,10 @@ import ClientInterface from "./httpClient/clientInterface"; type ClientParametersOverload = | { config: Config } | { config: Config; httpClient: ClientInterface } +| { username: string; password: string; environment: Environment} +| { username: string; password: string; environment: Environment; httpClient: ClientInterface } +| { username: string; password: string; environment: Environment; liveEndpointUrlPrefix: string } +| { username: string; password: string; environment: Environment; liveEndpointUrlPrefix: string; httpClient: ClientInterface } | { username: string; password: string; environment: Environment; applicationName: string } | { username: string; password: string; environment: Environment; applicationName: string; httpClient: ClientInterface } | { username: string; password: string; environment: Environment; applicationName: string; liveEndpointUrlPrefix: string } @@ -68,9 +72,12 @@ class Client { public static LEGAL_ENTITY_MANAGEMENT_API_VERSION = "v2"; public static LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_TEST = "https://kyc-test.adyen.com/lem"; public static LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_LIVE = "https://kyc-live.adyen.com/lem"; - public static TRANSFERS_API_VERSION="v3"; - public static TRANSFERS_API_VERSION_TEST = "https://balanceplatform-api-test.adyen.com/btl"; - public static TRANSFERS_API_VERSION_LIVE = "https://balanceplatform-api-live.adyen.com/btl"; + public static TRANSFERS_API_VERSION = "v3"; + public static TRANSFERS_API_ENDPOINT_TEST = "https://balanceplatform-api-test.adyen.com/btl"; + public static TRANSFERS_API_ENDPOINT_LIVE = "https://balanceplatform-api-live.adyen.com/btl"; + public static DATA_PROTECTION_API_VERSION = "v1"; + public static DATA_PROTECTION_API_ENDPOINT_TEST = "https://ca-test.adyen.com/ca/services/DataProtectionService"; + public static DATA_PROTECTION_API_ENDPOINT_LIVE = "https://ca-live.adyen.com/ca/services/DataProtectionService"; private _httpClient!: ClientInterface; @@ -87,10 +94,12 @@ class Client { const environment = options.environment || this.config.environment; if (environment) { this.setEnvironment(environment, options.liveEndpointUrlPrefix); - if (options.username && options.password && options.applicationName) { + if (options.username && options.password) { this.config.username = options.username; this.config.password = options.password; - this.config.applicationName = options.applicationName; + if(options.applicationName) { + this.config.applicationName = options.applicationName; + } } if (options.apiKey) { @@ -116,7 +125,8 @@ class Client { this.config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_TEST; this.config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_TEST; this.config.legalEntityManagementEndpoint = Client.LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_TEST; - this.config.transfersEndpoint = Client.TRANSFERS_API_VERSION_TEST; + this.config.transfersEndpoint = Client.TRANSFERS_API_ENDPOINT_TEST; + this.config.dataProtectionEndpoint = Client.DATA_PROTECTION_API_ENDPOINT_TEST; } else if (environment === "LIVE") { this.config.endpoint = Client.ENDPOINT_LIVE; this.config.marketPayEndpoint = Client.MARKETPAY_ENDPOINT_LIVE; @@ -128,7 +138,8 @@ class Client { this.config.managementEndpoint = Client.MANAGEMENT_API_ENDPOINT_LIVE; this.config.balancePlatformEndpoint = Client.BALANCE_PLATFORM_API_ENDPOINT_LIVE; this.config.legalEntityManagementEndpoint = Client.LEGAL_ENTITY_MANAGEMENT_API_ENDPOINT_LIVE; - this.config.transfersEndpoint = Client.TRANSFERS_API_VERSION_LIVE; + this.config.transfersEndpoint = Client.TRANSFERS_API_ENDPOINT_LIVE; + this.config.dataProtectionEndpoint = Client.DATA_PROTECTION_API_ENDPOINT_LIVE; if (liveEndpointUrlPrefix) { this.config.endpoint = @@ -164,4 +175,4 @@ class Client { } } -export default Client; \ No newline at end of file +export default Client; diff --git a/src/config.ts b/src/config.ts index f78f277a5..332a5ce23 100644 --- a/src/config.ts +++ b/src/config.ts @@ -41,6 +41,7 @@ interface ConfigConstructor { balancePlatformEndpoint?: string; legalEntityManagementEndpoint?: string; transfersEndpoint?: string; + dataProtectionEndpoint?: string; } class Config { @@ -72,6 +73,7 @@ class Config { public balancePlatformEndpoint?: string; public legalEntityManagementEndpoint?: string; public transfersEndpoint?: string; + public dataProtectionEndpoint?: string; public constructor(options: ConfigConstructor = {}) { if (options.username) this.username = options.username; @@ -98,6 +100,7 @@ class Config { if (options.balancePlatformEndpoint) this.balancePlatformEndpoint = options.balancePlatformEndpoint; if (options.legalEntityManagementEndpoint) this.legalEntityManagementEndpoint = options.legalEntityManagementEndpoint; if (options.transfersEndpoint) this.transfersEndpoint = options.transfersEndpoint; + if (options.dataProtectionEndpoint) this.dataProtectionEndpoint = options.dataProtectionEndpoint; } public set checkoutEndpoint(checkoutEndpoint: string | undefined) { diff --git a/src/services/dataProtection.ts b/src/services/dataProtection.ts new file mode 100644 index 000000000..5a63d3456 --- /dev/null +++ b/src/services/dataProtection.ts @@ -0,0 +1,25 @@ +import Client from "../client"; +import getJsonResponse from "../helpers/getJsonResponse"; +import Service from "../service"; +import { SubjectErasureByPspReferenceRequest, SubjectErasureResponse, ObjectSerializer } from "../typings/dataProtection/models"; +import DataProtectionResource from "./resource/dataProtectionresource"; +import { IRequest } from "../typings/requestOptions"; + +class DataProtection extends Service { + private readonly _dataProtectionResource: DataProtectionResource; + + public constructor(client: Client) { + super(client); + this._dataProtectionResource = new DataProtectionResource(this, "/requestSubjectErasure"); + } + public async requestSubjectErasure(subjectErasureByPspReferenceRequest: SubjectErasureByPspReferenceRequest, requestOptions?: IRequest.Options): Promise { + const response = await getJsonResponse( + this._dataProtectionResource, + subjectErasureByPspReferenceRequest, + requestOptions, + ); + return ObjectSerializer.deserialize(response, "SubjectErasureResponse"); + } +} + +export default DataProtection; diff --git a/src/services/index.ts b/src/services/index.ts index 85db97b6e..eb4926547 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -11,3 +11,5 @@ export { default as TerminalManagement} from "./terminalManagement"; export { default as Management } from "./management"; export { default as LegalEntityManagement } from "./legalEntityManagement"; export { default as Transfers } from "./transfers"; +export { default as BalancePlatform } from "./balancePlatform"; +export { default as DataProtection } from "./dataProtection"; diff --git a/src/services/management.ts b/src/services/management.ts index 5a46e076b..0e4447fa9 100644 --- a/src/services/management.ts +++ b/src/services/management.ts @@ -1,6 +1,7 @@ import Service from "../service"; import Client from "../client"; +// Deprecated classes import MeApi from "./management/meApi"; import MerchantAccount from "./management/merchantAccount"; import MerchantAllowedOrigins from "./management/merchantAllowedOrigins"; @@ -14,59 +15,208 @@ import MerchantTerminalSettings from "./management/merchantTerminalSettings"; import MerchantUsers from "./management/merchantUsers"; import MerchantWebhooks from "./management/merchantWebhooks"; +// Recommended classes +import APICredentialsCompanyLevelApi from './management/aPICredentialsCompanyLevelApi'; +import APICredentialsMerchantLevelApi from './management/aPICredentialsMerchantLevelApi'; +import APIKeyCompanyLevelApi from './management/aPIKeyCompanyLevelApi'; +import APIKeyMerchantLevelApi from './management/aPIKeyMerchantLevelApi'; +import AccountCompanyLevelApi from './management/accountCompanyLevelApi'; +import AccountMerchantLevelApi from './management/accountMerchantLevelApi'; +import AccountStoreLevelApi from './management/accountStoreLevelApi'; +import AllowedOriginsCompanyLevelApi from './management/allowedOriginsCompanyLevelApi'; +import AllowedOriginsMerchantLevelApi from './management/allowedOriginsMerchantLevelApi'; +import ClientKeyCompanyLevelApi from './management/clientKeyCompanyLevelApi'; +import ClientKeyMerchantLevelApi from './management/clientKeyMerchantLevelApi'; +import MyAPICredentialApi from './management/myAPICredentialApi'; +import PaymentMethodsMerchantLevelApi from './management/paymentMethodsMerchantLevelApi'; +import PayoutSettingsMerchantLevelApi from './management/payoutSettingsMerchantLevelApi'; +import TerminalActionsCompanyLevelApi from './management/terminalActionsCompanyLevelApi'; +import TerminalActionsTerminalLevelApi from './management/terminalActionsTerminalLevelApi'; +import TerminalOrdersCompanyLevelApi from './management/terminalOrdersCompanyLevelApi'; +import TerminalOrdersMerchantLevelApi from './management/terminalOrdersMerchantLevelApi'; +import TerminalSettingsCompanyLevelApi from './management/terminalSettingsCompanyLevelApi'; +import TerminalSettingsMerchantLevelApi from './management/terminalSettingsMerchantLevelApi'; +import TerminalSettingsStoreLevelApi from './management/terminalSettingsStoreLevelApi'; +import TerminalSettingsTerminalLevelApi from './management/terminalSettingsTerminalLevelApi'; +import TerminalsTerminalLevelApi from './management/terminalsTerminalLevelApi'; +import UsersCompanyLevelApi from './management/usersCompanyLevelApi'; +import UsersMerchantLevelApi from './management/usersMerchantLevelApi'; +import WebhooksCompanyLevelApi from './management/webhooksCompanyLevelApi'; +import WebhooksMerchantLevelApi from './management/webhooksMerchantLevelApi'; + class Management extends Service { public constructor(client: Client) { super(client); } + /** + * @deprecated + */ public get Me() { const meApi = new MeApi(this.client); return meApi.Me; } + /** + * @deprecated + */ public get MerchantAccount() { return new MerchantAccount(this.client); } + /** + * @deprecated + */ public get MerchantAllowedOrigins() { return new MerchantAllowedOrigins(this.client); } + /** + * @deprecated + */ public get MerchantApiCredentials() { return new MerchantApiCredentials(this.client); } + /** + * @deprecated + */ public get MerchantApiKey() { return new MerchantApiKey(this.client); } + /** + * @deprecated + */ public get MerchantClientKey() { return new MerchantClientKey(this.client); } + /** + * @deprecated + */ public get MerchantPaymentMethods() { return new MerchantPaymentMethods(this.client); } + /** + * @deprecated + */ public get MerchantPayoutSettings() { return new MerchantPayoutSettings(this.client); } + /** + * @deprecated + */ public get MerchantTerminalOrders() { return new MerchantTerminalOrders(this.client); } + /** + * @deprecated + */ public get MerchantTerminalSettings() { return new MerchantTerminalSettings(this.client); } + /** + * @deprecated + */ public get MerchantUsers() { return new MerchantUsers(this.client); } + /** + * @deprecated + */ public get MerchantWebhooks() { return new MerchantWebhooks(this.client); } + + // ## Recommended classes + + public get APICredentialsCompanyLevelApi() { + return new APICredentialsCompanyLevelApi(this.client); + } + public get APICredentialsMerchantLevelApi() { + return new APICredentialsMerchantLevelApi(this.client); + } + public get APIKeyCompanyLevelApi() { + return new APIKeyCompanyLevelApi(this.client); + } + public get APIKeyMerchantLevelApi() { + return new APIKeyMerchantLevelApi(this.client); + } + public get AccountCompanyLevelApi() { + return new AccountCompanyLevelApi(this.client); + } + public get AccountMerchantLevelApi() { + return new AccountMerchantLevelApi(this.client); + } + public get AccountStoreLevelApi() { + return new AccountStoreLevelApi(this.client); + } + public get AllowedOriginsCompanyLevelApi() { + return new AllowedOriginsCompanyLevelApi(this.client); + } + public get AllowedOriginsMerchantLevelApi() { + return new AllowedOriginsMerchantLevelApi(this.client); + } + public get ClientKeyCompanyLevelApi() { + return new ClientKeyCompanyLevelApi(this.client); + } + public get ClientKeyMerchantLevelApi() { + return new ClientKeyMerchantLevelApi(this.client); + } + public get MyAPICredentialApi() { + return new MyAPICredentialApi(this.client); + } + public get PaymentMethodsMerchantLevelApi() { + return new PaymentMethodsMerchantLevelApi(this.client); + } + public get PayoutSettingsMerchantLevelApi() { + return new PayoutSettingsMerchantLevelApi(this.client); + } + public get TerminalActionsCompanyLevelApi() { + return new TerminalActionsCompanyLevelApi(this.client); + } + public get TerminalActionsTerminalLevelApi() { + return new TerminalActionsTerminalLevelApi(this.client); + } + public get TerminalOrdersCompanyLevelApi() { + return new TerminalOrdersCompanyLevelApi(this.client); + } + public get TerminalOrdersMerchantLevelApi() { + return new TerminalOrdersMerchantLevelApi(this.client); + } + public get TerminalSettingsCompanyLevelApi() { + return new TerminalSettingsCompanyLevelApi(this.client); + } + public get TerminalSettingsMerchantLevelApi() { + return new TerminalSettingsMerchantLevelApi(this.client); + } + public get TerminalSettingsStoreLevelApi() { + return new TerminalSettingsStoreLevelApi(this.client); + } + public get TerminalSettingsTerminalLevelApi() { + return new TerminalSettingsTerminalLevelApi(this.client); + } + public get TerminalsTerminalLevelApi() { + return new TerminalsTerminalLevelApi(this.client); + } + public get UsersCompanyLevelApi() { + return new UsersCompanyLevelApi(this.client); + } + public get UsersMerchantLevelApi() { + return new UsersMerchantLevelApi(this.client); + } + public get WebhooksCompanyLevelApi() { + return new WebhooksCompanyLevelApi(this.client); + } + public get WebhooksMerchantLevelApi() { + return new WebhooksMerchantLevelApi(this.client); + } } export default Management; diff --git a/src/services/management/aPICredentialsCompanyLevelApi.ts b/src/services/management/aPICredentialsCompanyLevelApi.ts new file mode 100644 index 000000000..f88f2e7f3 --- /dev/null +++ b/src/services/management/aPICredentialsCompanyLevelApi.ts @@ -0,0 +1,95 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { CompanyApiCredential } from '../../typings/management/models'; +import { CreateCompanyApiCredentialRequest } from '../../typings/management/models'; +import { CreateCompanyApiCredentialResponse } from '../../typings/management/models'; +import { ListCompanyApiCredentialsResponse } from '../../typings/management/models'; +import { UpdateCompanyApiCredentialRequest } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class APICredentialsCompanyLevelApi extends Service { + /** + * @summary Get a list of API credentials + * @param companyId The unique identifier of the company account. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + */ + public async listApiCredentials(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListCompanyApiCredentialsResponse"); + } + /** + * @summary Get an API credential + * @param companyId The unique identifier of the company account. + * @param apiCredentialId Unique identifier of the API credential. + */ + public async getApiCredential(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "CompanyApiCredential"); + } + /** + * @summary Update an API credential. + * @param companyId The unique identifier of the company account. + * @param apiCredentialId Unique identifier of the API credential. + * @param updateCompanyApiCredentialRequest + */ + public async updateApiCredential(companyId: string, apiCredentialId: string, updateCompanyApiCredentialRequest: UpdateCompanyApiCredentialRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdateCompanyApiCredentialRequest = ObjectSerializer.serialize(updateCompanyApiCredentialRequest, "UpdateCompanyApiCredentialRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "CompanyApiCredential"); + } + /** + * @summary Create an API credential. + * @param companyId The unique identifier of the company account. + * @param createCompanyApiCredentialRequest + */ + public async createApiCredential(companyId: string, createCompanyApiCredentialRequest: CreateCompanyApiCredentialRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const request: CreateCompanyApiCredentialRequest = ObjectSerializer.serialize(createCompanyApiCredentialRequest, "CreateCompanyApiCredentialRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "CreateCompanyApiCredentialResponse"); + } +} diff --git a/src/services/management/aPICredentialsMerchantLevelApi.ts b/src/services/management/aPICredentialsMerchantLevelApi.ts new file mode 100644 index 000000000..94e46ccdc --- /dev/null +++ b/src/services/management/aPICredentialsMerchantLevelApi.ts @@ -0,0 +1,95 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { ApiCredential } from '../../typings/management/models'; +import { CreateApiCredentialResponse } from '../../typings/management/models'; +import { CreateMerchantApiCredentialRequest } from '../../typings/management/models'; +import { ListMerchantApiCredentialsResponse } from '../../typings/management/models'; +import { UpdateMerchantApiCredentialRequest } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class APICredentialsMerchantLevelApi extends Service { + /** + * @summary Get a list of API credentials + * @param merchantId The unique identifier of the merchant account. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + */ + public async listApiCredentials(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListMerchantApiCredentialsResponse"); + } + /** + * @summary Get an API credential + * @param merchantId The unique identifier of the merchant account. + * @param apiCredentialId Unique identifier of the API credential. + */ + public async getApiCredential(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ApiCredential"); + } + /** + * @summary Update an API credential + * @param merchantId The unique identifier of the merchant account. + * @param apiCredentialId Unique identifier of the API credential. + * @param updateMerchantApiCredentialRequest + */ + public async updateApiCredential(merchantId: string, apiCredentialId: string, updateMerchantApiCredentialRequest: UpdateMerchantApiCredentialRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdateMerchantApiCredentialRequest = ObjectSerializer.serialize(updateMerchantApiCredentialRequest, "UpdateMerchantApiCredentialRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "ApiCredential"); + } + /** + * @summary Create an API credential + * @param merchantId The unique identifier of the merchant account. + * @param createMerchantApiCredentialRequest + */ + public async createApiCredential(merchantId: string, createMerchantApiCredentialRequest: CreateMerchantApiCredentialRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: CreateMerchantApiCredentialRequest = ObjectSerializer.serialize(createMerchantApiCredentialRequest, "CreateMerchantApiCredentialRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "CreateApiCredentialResponse"); + } +} diff --git a/src/services/management/aPIKeyCompanyLevelApi.ts b/src/services/management/aPIKeyCompanyLevelApi.ts new file mode 100644 index 000000000..f4faaa194 --- /dev/null +++ b/src/services/management/aPIKeyCompanyLevelApi.ts @@ -0,0 +1,38 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { GenerateApiKeyResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class APIKeyCompanyLevelApi extends Service { + /** + * @summary Generate new API key + * @param companyId The unique identifier of the company account. + * @param apiCredentialId Unique identifier of the API credential. + */ + public async generateNewApiKey(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/generateApiKey" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "GenerateApiKeyResponse"); + } +} diff --git a/src/services/management/aPIKeyMerchantLevelApi.ts b/src/services/management/aPIKeyMerchantLevelApi.ts new file mode 100644 index 000000000..960cdb9f7 --- /dev/null +++ b/src/services/management/aPIKeyMerchantLevelApi.ts @@ -0,0 +1,38 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { GenerateApiKeyResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class APIKeyMerchantLevelApi extends Service { + /** + * @summary Generate new API key + * @param merchantId The unique identifier of the merchant account. + * @param apiCredentialId Unique identifier of the API credential. + */ + public async generateNewApiKey(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/generateApiKey" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "GenerateApiKeyResponse"); + } +} diff --git a/src/services/management/accountCompanyLevelApi.ts b/src/services/management/accountCompanyLevelApi.ts new file mode 100644 index 000000000..440b49132 --- /dev/null +++ b/src/services/management/accountCompanyLevelApi.ts @@ -0,0 +1,70 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { Company } from '../../typings/management/models'; +import { ListCompanyResponse } from '../../typings/management/models'; +import { ListMerchantResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class AccountCompanyLevelApi extends Service { + /** + * @summary Get a list of company accounts + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + */ + public async listCompanyAccounts(requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies"; + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListCompanyResponse"); + } + /** + * @summary Get a company account + * @param companyId The unique identifier of the company account. + */ + public async getCompanyAccount(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Company"); + } + /** + * @summary Get a list of merchant accounts + * @param companyId The unique identifier of the company account. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + */ + public async listMerchantAccounts(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/merchants" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListMerchantResponse"); + } +} diff --git a/src/services/management/accountMerchantLevelApi.ts b/src/services/management/accountMerchantLevelApi.ts new file mode 100644 index 000000000..0756afffb --- /dev/null +++ b/src/services/management/accountMerchantLevelApi.ts @@ -0,0 +1,85 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { CreateMerchantRequest } from '../../typings/management/models'; +import { CreateMerchantResponse } from '../../typings/management/models'; +import { ListMerchantResponse } from '../../typings/management/models'; +import { Merchant } from '../../typings/management/models'; +import { RequestActivationResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class AccountMerchantLevelApi extends Service { + /** + * @summary Get a list of merchant accounts + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + */ + public async listMerchantAccounts(requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants"; + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListMerchantResponse"); + } + /** + * @summary Get a merchant account + * @param merchantId The unique identifier of the merchant account. + */ + public async getMerchantAccount(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Merchant"); + } + /** + * @summary Create a merchant account + * @param createMerchantRequest + */ + public async createMerchantAccount(createMerchantRequest: CreateMerchantRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants"; + const resource = new ManagementResource(this, localVarPath); + const request: CreateMerchantRequest = ObjectSerializer.serialize(createMerchantRequest, "CreateMerchantRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "CreateMerchantResponse"); + } + /** + * @summary Request to activate a merchant account + * @param merchantId The unique identifier of the merchant account. + */ + public async requestToActivateMerchantAccount(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/activate" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "RequestActivationResponse"); + } +} diff --git a/src/services/management/accountStoreLevelApi.ts b/src/services/management/accountStoreLevelApi.ts new file mode 100644 index 000000000..bb6cd84fd --- /dev/null +++ b/src/services/management/accountStoreLevelApi.ts @@ -0,0 +1,160 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { ListStoresResponse } from '../../typings/management/models'; +import { Store } from '../../typings/management/models'; +import { StoreCreationRequest } from '../../typings/management/models'; +import { StoreCreationWithMerchantCodeRequest } from '../../typings/management/models'; +import { UpdateStoreRequest } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class AccountStoreLevelApi extends Service { + /** + * @summary Get a list of stores + * @param merchantId The unique identifier of the merchant account. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + * @param reference The reference of the store. + */ + public async listStoresByMerchantId(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/stores" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListStoresResponse"); + } + /** + * @summary Get a store + * @param merchantId The unique identifier of the merchant account. + * @param storeId The unique identifier of the store. + */ + public async getStore(merchantId: string, storeId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/stores/{storeId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Store"); + } + /** + * @summary Get a list of stores + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + * @param reference The reference of the store. + * @param merchantId The unique identifier of the merchant account. + */ + public async listStores(requestOptions?: IRequest.Options): Promise { + const localVarPath = "/stores"; + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListStoresResponse"); + } + /** + * @summary Get a store + * @param storeId The unique identifier of the store. + */ + public async getStoreById(storeId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/stores/{storeId}" + .replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Store"); + } + /** + * @summary Update a store + * @param merchantId The unique identifier of the merchant account. + * @param storeId The unique identifier of the store. + * @param updateStoreRequest + */ + public async updateStore(merchantId: string, storeId: string, updateStoreRequest: UpdateStoreRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/stores/{storeId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdateStoreRequest = ObjectSerializer.serialize(updateStoreRequest, "UpdateStoreRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Store"); + } + /** + * @summary Update a store + * @param storeId The unique identifier of the store. + * @param updateStoreRequest + */ + public async updateStoreById(storeId: string, updateStoreRequest: UpdateStoreRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/stores/{storeId}" + .replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdateStoreRequest = ObjectSerializer.serialize(updateStoreRequest, "UpdateStoreRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Store"); + } + /** + * @summary Create a store + * @param merchantId The unique identifier of the merchant account. + * @param storeCreationRequest + */ + public async createStoreByMerchantId(merchantId: string, storeCreationRequest: StoreCreationRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/stores" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: StoreCreationRequest = ObjectSerializer.serialize(storeCreationRequest, "StoreCreationRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "Store"); + } + /** + * @summary Create a store + * @param storeCreationWithMerchantCodeRequest + */ + public async createStore(storeCreationWithMerchantCodeRequest: StoreCreationWithMerchantCodeRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/stores"; + const resource = new ManagementResource(this, localVarPath); + const request: StoreCreationWithMerchantCodeRequest = ObjectSerializer.serialize(storeCreationWithMerchantCodeRequest, "StoreCreationWithMerchantCodeRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "Store"); + } +} diff --git a/src/services/management/allowedOriginsCompanyLevelApi.ts b/src/services/management/allowedOriginsCompanyLevelApi.ts new file mode 100644 index 000000000..047f18f69 --- /dev/null +++ b/src/services/management/allowedOriginsCompanyLevelApi.ts @@ -0,0 +1,95 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { AllowedOrigin } from '../../typings/management/models'; +import { AllowedOriginsResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class AllowedOriginsCompanyLevelApi extends Service { + /** + * @summary Delete an allowed origin + * @param companyId The unique identifier of the company account. + * @param apiCredentialId Unique identifier of the API credential. + * @param originId Unique identifier of the allowed origin. + */ + public async deleteAllowedOrigin(companyId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))) + .replace('{' + 'originId' + '}', encodeURIComponent(String(originId))); + const resource = new ManagementResource(this, localVarPath); + await getJsonResponse( + resource, + "", + { ...requestOptions, method: "DELETE" } + ); + } + /** + * @summary Get a list of allowed origins + * @param companyId The unique identifier of the company account. + * @param apiCredentialId Unique identifier of the API credential. + */ + public async listAllowedOrigins(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AllowedOriginsResponse"); + } + /** + * @summary Get an allowed origin + * @param companyId The unique identifier of the company account. + * @param apiCredentialId Unique identifier of the API credential. + * @param originId Unique identifier of the allowed origin. + */ + public async getAllowedOrigin(companyId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))) + .replace('{' + 'originId' + '}', encodeURIComponent(String(originId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AllowedOrigin"); + } + /** + * @summary Create an allowed origin + * @param companyId The unique identifier of the company account. + * @param apiCredentialId Unique identifier of the API credential. + * @param allowedOrigin + */ + public async createAllowedOrigin(companyId: string, apiCredentialId: string, allowedOrigin: AllowedOrigin, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/allowedOrigins" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const request: AllowedOrigin = ObjectSerializer.serialize(allowedOrigin, "AllowedOrigin"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "AllowedOriginsResponse"); + } +} diff --git a/src/services/management/allowedOriginsMerchantLevelApi.ts b/src/services/management/allowedOriginsMerchantLevelApi.ts new file mode 100644 index 000000000..6d7c53f43 --- /dev/null +++ b/src/services/management/allowedOriginsMerchantLevelApi.ts @@ -0,0 +1,95 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { AllowedOrigin } from '../../typings/management/models'; +import { AllowedOriginsResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class AllowedOriginsMerchantLevelApi extends Service { + /** + * @summary Delete an allowed origin + * @param merchantId The unique identifier of the merchant account. + * @param apiCredentialId Unique identifier of the API credential. + * @param originId Unique identifier of the allowed origin. + */ + public async deleteAllowedOrigin(merchantId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))) + .replace('{' + 'originId' + '}', encodeURIComponent(String(originId))); + const resource = new ManagementResource(this, localVarPath); + await getJsonResponse( + resource, + "", + { ...requestOptions, method: "DELETE" } + ); + } + /** + * @summary Get a list of allowed origins + * @param merchantId The unique identifier of the merchant account. + * @param apiCredentialId Unique identifier of the API credential. + */ + public async listAllowedOrigins(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AllowedOriginsResponse"); + } + /** + * @summary Get an allowed origin + * @param merchantId The unique identifier of the merchant account. + * @param apiCredentialId Unique identifier of the API credential. + * @param originId Unique identifier of the allowed origin. + */ + public async getAllowedOrigin(merchantId: string, apiCredentialId: string, originId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins/{originId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))) + .replace('{' + 'originId' + '}', encodeURIComponent(String(originId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AllowedOrigin"); + } + /** + * @summary Create an allowed origin + * @param merchantId The unique identifier of the merchant account. + * @param apiCredentialId Unique identifier of the API credential. + * @param allowedOrigin + */ + public async createAllowedOrigin(merchantId: string, apiCredentialId: string, allowedOrigin: AllowedOrigin, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/allowedOrigins" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const request: AllowedOrigin = ObjectSerializer.serialize(allowedOrigin, "AllowedOrigin"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "AllowedOriginsResponse"); + } +} diff --git a/src/services/management/clientKeyCompanyLevelApi.ts b/src/services/management/clientKeyCompanyLevelApi.ts new file mode 100644 index 000000000..1bd90894d --- /dev/null +++ b/src/services/management/clientKeyCompanyLevelApi.ts @@ -0,0 +1,38 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { GenerateClientKeyResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class ClientKeyCompanyLevelApi extends Service { + /** + * @summary Generate new client key + * @param companyId The unique identifier of the company account. + * @param apiCredentialId Unique identifier of the API credential. + */ + public async generateNewClientKey(companyId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/apiCredentials/{apiCredentialId}/generateClientKey" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "GenerateClientKeyResponse"); + } +} diff --git a/src/services/management/clientKeyMerchantLevelApi.ts b/src/services/management/clientKeyMerchantLevelApi.ts new file mode 100644 index 000000000..af57b89f3 --- /dev/null +++ b/src/services/management/clientKeyMerchantLevelApi.ts @@ -0,0 +1,38 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { GenerateClientKeyResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class ClientKeyMerchantLevelApi extends Service { + /** + * @summary Generate new client key + * @param merchantId The unique identifier of the merchant account. + * @param apiCredentialId Unique identifier of the API credential. + */ + public async generateNewClientKey(merchantId: string, apiCredentialId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/apiCredentials/{apiCredentialId}/generateClientKey" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'apiCredentialId' + '}', encodeURIComponent(String(apiCredentialId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "GenerateClientKeyResponse"); + } +} diff --git a/src/services/management/myAPICredentialApi.ts b/src/services/management/myAPICredentialApi.ts new file mode 100644 index 000000000..7edb681fd --- /dev/null +++ b/src/services/management/myAPICredentialApi.ts @@ -0,0 +1,94 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { AllowedOrigin } from '../../typings/management/models'; +import { AllowedOriginsResponse } from '../../typings/management/models'; +import { CreateAllowedOriginRequest } from '../../typings/management/models'; +import { MeApiCredential } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class MyAPICredentialApi extends Service { + /** + * @summary Remove allowed origin + * @param originId Unique identifier of the allowed origin. + */ + public async removeAllowedOrigin(originId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/me/allowedOrigins/{originId}" + .replace('{' + 'originId' + '}', encodeURIComponent(String(originId))); + const resource = new ManagementResource(this, localVarPath); + await getJsonResponse( + resource, + "", + { ...requestOptions, method: "DELETE" } + ); + } + /** + * @summary Get API credential details + */ + public async getApiCredentialDetails(requestOptions?: IRequest.Options): Promise { + const localVarPath = "/me"; + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "MeApiCredential"); + } + /** + * @summary Get allowed origins + */ + public async getAllowedOrigins(requestOptions?: IRequest.Options): Promise { + const localVarPath = "/me/allowedOrigins"; + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AllowedOriginsResponse"); + } + /** + * @summary Get allowed origin details + * @param originId Unique identifier of the allowed origin. + */ + public async getAllowedOriginDetails(originId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/me/allowedOrigins/{originId}" + .replace('{' + 'originId' + '}', encodeURIComponent(String(originId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AllowedOrigin"); + } + /** + * @summary Add allowed origin + * @param createAllowedOriginRequest + */ + public async addAllowedOrigin(createAllowedOriginRequest: CreateAllowedOriginRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/me/allowedOrigins"; + const resource = new ManagementResource(this, localVarPath); + const request: CreateAllowedOriginRequest = ObjectSerializer.serialize(createAllowedOriginRequest, "CreateAllowedOriginRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "AllowedOriginsResponse"); + } +} diff --git a/src/services/management/paymentMethodsMerchantLevelApi.ts b/src/services/management/paymentMethodsMerchantLevelApi.ts new file mode 100644 index 000000000..a9e45c18d --- /dev/null +++ b/src/services/management/paymentMethodsMerchantLevelApi.ts @@ -0,0 +1,132 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { ApplePayInfo } from '../../typings/management/models'; +import { PaymentMethod } from '../../typings/management/models'; +import { PaymentMethodResponse } from '../../typings/management/models'; +import { PaymentMethodSetupInfo } from '../../typings/management/models'; +import { UpdatePaymentMethodInfo } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class PaymentMethodsMerchantLevelApi extends Service { + /** + * @summary Get all payment methods + * @param merchantId The unique identifier of the merchant account. + * @param storeId The unique identifier of the store for which to return the payment methods. + * @param businessLineId The unique identifier of the Business Line for which to return the payment methods. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + * @param pageNumber The number of the page to fetch. + */ + public async getAllPaymentMethods(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/paymentMethodSettings" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "PaymentMethodResponse"); + } + /** + * @summary Get payment method details + * @param merchantId The unique identifier of the merchant account. + * @param paymentMethodId The unique identifier of the payment method. + */ + public async getPaymentMethodDetails(merchantId: string, paymentMethodId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'paymentMethodId' + '}', encodeURIComponent(String(paymentMethodId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "PaymentMethod"); + } + /** + * @summary Get Apple Pay domains + * @param merchantId The unique identifier of the merchant account. + * @param paymentMethodId The unique identifier of the payment method. + */ + public async getApplePayDomains(merchantId: string, paymentMethodId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}/getApplePayDomains" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'paymentMethodId' + '}', encodeURIComponent(String(paymentMethodId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ApplePayInfo"); + } + /** + * @summary Update a payment method + * @param merchantId The unique identifier of the merchant account. + * @param paymentMethodId The unique identifier of the payment method. + * @param updatePaymentMethodInfo + */ + public async updatePaymentMethod(merchantId: string, paymentMethodId: string, updatePaymentMethodInfo: UpdatePaymentMethodInfo, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'paymentMethodId' + '}', encodeURIComponent(String(paymentMethodId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdatePaymentMethodInfo = ObjectSerializer.serialize(updatePaymentMethodInfo, "UpdatePaymentMethodInfo"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "PaymentMethod"); + } + /** + * @summary Request a payment method + * @param merchantId The unique identifier of the merchant account. + * @param paymentMethodSetupInfo + */ + public async requestPaymentMethod(merchantId: string, paymentMethodSetupInfo: PaymentMethodSetupInfo, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/paymentMethodSettings" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: PaymentMethodSetupInfo = ObjectSerializer.serialize(paymentMethodSetupInfo, "PaymentMethodSetupInfo"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "PaymentMethod"); + } + /** + * @summary Add an Apple Pay domain + * @param merchantId The unique identifier of the merchant account. + * @param paymentMethodId The unique identifier of the payment method. + * @param applePayInfo + */ + public async addApplePayDomain(merchantId: string, paymentMethodId: string, applePayInfo: ApplePayInfo, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/paymentMethodSettings/{paymentMethodId}/addApplePayDomains" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'paymentMethodId' + '}', encodeURIComponent(String(paymentMethodId))); + const resource = new ManagementResource(this, localVarPath); + const request: ApplePayInfo = ObjectSerializer.serialize(applePayInfo, "ApplePayInfo"); + await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + } +} diff --git a/src/services/management/payoutSettingsMerchantLevelApi.ts b/src/services/management/payoutSettingsMerchantLevelApi.ts new file mode 100644 index 000000000..6819c3931 --- /dev/null +++ b/src/services/management/payoutSettingsMerchantLevelApi.ts @@ -0,0 +1,108 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { PayoutSettings } from '../../typings/management/models'; +import { PayoutSettingsRequest } from '../../typings/management/models'; +import { PayoutSettingsResponse } from '../../typings/management/models'; +import { UpdatePayoutSettingsRequest } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class PayoutSettingsMerchantLevelApi extends Service { + /** + * @summary Delete a payout setting + * @param merchantId The unique identifier of the merchant account. + * @param payoutSettingsId The unique identifier of the payout setting. + */ + public async deletePayoutSetting(merchantId: string, payoutSettingsId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/payoutSettings/{payoutSettingsId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'payoutSettingsId' + '}', encodeURIComponent(String(payoutSettingsId))); + const resource = new ManagementResource(this, localVarPath); + await getJsonResponse( + resource, + "", + { ...requestOptions, method: "DELETE" } + ); + } + /** + * @summary Get a list of payout settings + * @param merchantId The unique identifier of the merchant account. + */ + public async listPayoutSettings(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/payoutSettings" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "PayoutSettingsResponse"); + } + /** + * @summary Get a payout setting + * @param merchantId The unique identifier of the merchant account. + * @param payoutSettingsId The unique identifier of the payout setting. + */ + public async getPayoutSetting(merchantId: string, payoutSettingsId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/payoutSettings/{payoutSettingsId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'payoutSettingsId' + '}', encodeURIComponent(String(payoutSettingsId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "PayoutSettings"); + } + /** + * @summary Update a payout setting + * @param merchantId The unique identifier of the merchant account. + * @param payoutSettingsId The unique identifier of the payout setting. + * @param updatePayoutSettingsRequest + */ + public async updatePayoutSetting(merchantId: string, payoutSettingsId: string, updatePayoutSettingsRequest: UpdatePayoutSettingsRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/payoutSettings/{payoutSettingsId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'payoutSettingsId' + '}', encodeURIComponent(String(payoutSettingsId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdatePayoutSettingsRequest = ObjectSerializer.serialize(updatePayoutSettingsRequest, "UpdatePayoutSettingsRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "PayoutSettings"); + } + /** + * @summary Add a payout setting + * @param merchantId The unique identifier of the merchant account. + * @param payoutSettingsRequest + */ + public async addPayoutSetting(merchantId: string, payoutSettingsRequest: PayoutSettingsRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/payoutSettings" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: PayoutSettingsRequest = ObjectSerializer.serialize(payoutSettingsRequest, "PayoutSettingsRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "PayoutSettings"); + } +} diff --git a/src/services/management/terminalActionsCompanyLevelApi.ts b/src/services/management/terminalActionsCompanyLevelApi.ts new file mode 100644 index 000000000..47ab39054 --- /dev/null +++ b/src/services/management/terminalActionsCompanyLevelApi.ts @@ -0,0 +1,94 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { AndroidAppsResponse } from '../../typings/management/models'; +import { AndroidCertificatesResponse } from '../../typings/management/models'; +import { ExternalTerminalAction } from '../../typings/management/models'; +import { ListExternalTerminalActionsResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class TerminalActionsCompanyLevelApi extends Service { + /** + * @summary Get a list of Android apps + * @param companyId The unique identifier of the company account. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 20 items on a page. + */ + public async listAndroidApps(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/androidApps" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AndroidAppsResponse"); + } + /** + * @summary Get a list of Android certificates + * @param companyId The unique identifier of the company account. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 20 items on a page. + */ + public async listAndroidCertificates(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/androidCertificates" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "AndroidCertificatesResponse"); + } + /** + * @summary Get a list of terminal actions + * @param companyId The unique identifier of the company account. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 20 items on a page. + * @param status Returns terminal actions with the specified status. Allowed values: **pending**, **successful**, **failed**, **cancelled**, **tryLater**. + * @param type Returns terminal actions of the specified type. Allowed values: **InstallAndroidApp**, **UninstallAndroidApp**, **InstallAndroidCertificate**, **UninstallAndroidCertificate**. + */ + public async listTerminalActions(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalActions" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListExternalTerminalActionsResponse"); + } + /** + * @summary Get terminal action + * @param companyId The unique identifier of the company account. + * @param actionId The unique identifier of the terminal action. + */ + public async getTerminalAction(companyId: string, actionId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalActions/{actionId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'actionId' + '}', encodeURIComponent(String(actionId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ExternalTerminalAction"); + } +} diff --git a/src/services/management/terminalActionsTerminalLevelApi.ts b/src/services/management/terminalActionsTerminalLevelApi.ts new file mode 100644 index 000000000..c87ca13db --- /dev/null +++ b/src/services/management/terminalActionsTerminalLevelApi.ts @@ -0,0 +1,37 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { ScheduleTerminalActionsRequest } from '../../typings/management/models'; +import { ScheduleTerminalActionsResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class TerminalActionsTerminalLevelApi extends Service { + /** + * @summary Create a terminal action + * @param scheduleTerminalActionsRequest + */ + public async createTerminalAction(scheduleTerminalActionsRequest: ScheduleTerminalActionsRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/terminals/scheduleActions"; + const resource = new ManagementResource(this, localVarPath); + const request: ScheduleTerminalActionsRequest = ObjectSerializer.serialize(scheduleTerminalActionsRequest, "ScheduleTerminalActionsRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "ScheduleTerminalActionsResponse"); + } +} diff --git a/src/services/management/terminalOrdersCompanyLevelApi.ts b/src/services/management/terminalOrdersCompanyLevelApi.ts new file mode 100644 index 000000000..543ec61f1 --- /dev/null +++ b/src/services/management/terminalOrdersCompanyLevelApi.ts @@ -0,0 +1,202 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { BillingEntitiesResponse } from '../../typings/management/models'; +import { ShippingLocation } from '../../typings/management/models'; +import { ShippingLocationsResponse } from '../../typings/management/models'; +import { TerminalModelsResponse } from '../../typings/management/models'; +import { TerminalOrder } from '../../typings/management/models'; +import { TerminalOrderRequest } from '../../typings/management/models'; +import { TerminalOrdersResponse } from '../../typings/management/models'; +import { TerminalProductsResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class TerminalOrdersCompanyLevelApi extends Service { + /** + * @summary Get a list of billing entities + * @param companyId The unique identifier of the company account. + * @param name The name of the billing entity. + */ + public async listBillingEntities(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/billingEntities" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "BillingEntitiesResponse"); + } + /** + * @summary Get a list of shipping locations + * @param companyId The unique identifier of the company account. + * @param name The name of the shipping location. + * @param offset The number of locations to skip. + * @param limit The number of locations to return. + */ + public async listShippingLocations(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/shippingLocations" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ShippingLocationsResponse"); + } + /** + * @summary Get a list of terminal models + * @param companyId The unique identifier of the company account. + */ + public async listTerminalModels(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalModels" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalModelsResponse"); + } + /** + * @summary Get a list of orders + * @param companyId The unique identifier of the company account. + * @param customerOrderReference Your purchase order number. + * @param status The order status. Possible values (not case-sensitive): Placed, Confirmed, Cancelled, Shipped, Delivered. + * @param offset The number of orders to skip. + * @param limit The number of orders to return. + */ + public async listOrders(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalOrders" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrdersResponse"); + } + /** + * @summary Get an order + * @param companyId The unique identifier of the company account. + * @param orderId The unique identifier of the order. + */ + public async getOrder(companyId: string, orderId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalOrders/{orderId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + /** + * @summary Get a list of terminal products + * @param companyId The unique identifier of the company account. + * @param country The country to return products for, in [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. For example, **US** + * @param terminalModelId The terminal model to return products for. Use the ID returned in the [GET `/terminalModels`](https://docs.adyen.com/api-explorer/#/ManagementService/latest/get/terminalModels) response. For example, **Verifone.M400** + * @param offset The number of products to skip. + * @param limit The number of products to return. + */ + public async listTerminalProducts(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalProducts" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalProductsResponse"); + } + /** + * @summary Update an order + * @param companyId The unique identifier of the company account. + * @param orderId The unique identifier of the order. + * @param terminalOrderRequest + */ + public async updateOrder(companyId: string, orderId: string, terminalOrderRequest: TerminalOrderRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalOrders/{orderId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + const resource = new ManagementResource(this, localVarPath); + const request: TerminalOrderRequest = ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + /** + * @summary Create a shipping location + * @param companyId The unique identifier of the company account. + * @param shippingLocation + */ + public async createShippingLocation(companyId: string, shippingLocation: ShippingLocation, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/shippingLocations" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const request: ShippingLocation = ObjectSerializer.serialize(shippingLocation, "ShippingLocation"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "ShippingLocation"); + } + /** + * @summary Create an order + * @param companyId The unique identifier of the company account. + * @param terminalOrderRequest + */ + public async createOrder(companyId: string, terminalOrderRequest: TerminalOrderRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalOrders" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const request: TerminalOrderRequest = ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + /** + * @summary Cancel an order + * @param companyId The unique identifier of the company account. + * @param orderId The unique identifier of the order. + */ + public async cancelOrder(companyId: string, orderId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalOrders/{orderId}/cancel" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } +} diff --git a/src/services/management/terminalOrdersMerchantLevelApi.ts b/src/services/management/terminalOrdersMerchantLevelApi.ts new file mode 100644 index 000000000..aa67766b1 --- /dev/null +++ b/src/services/management/terminalOrdersMerchantLevelApi.ts @@ -0,0 +1,202 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { BillingEntitiesResponse } from '../../typings/management/models'; +import { ShippingLocation } from '../../typings/management/models'; +import { ShippingLocationsResponse } from '../../typings/management/models'; +import { TerminalModelsResponse } from '../../typings/management/models'; +import { TerminalOrder } from '../../typings/management/models'; +import { TerminalOrderRequest } from '../../typings/management/models'; +import { TerminalOrdersResponse } from '../../typings/management/models'; +import { TerminalProductsResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class TerminalOrdersMerchantLevelApi extends Service { + /** + * @summary Get a list of billing entities + * @param merchantId The unique identifier of the merchant account. + * @param name The name of the billing entity. + */ + public async listBillingEntities(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/billingEntities" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "BillingEntitiesResponse"); + } + /** + * @summary Get a list of shipping locations + * @param merchantId The unique identifier of the merchant account. + * @param name The name of the shipping location. + * @param offset The number of locations to skip. + * @param limit The number of locations to return. + */ + public async listShippingLocations(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/shippingLocations" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ShippingLocationsResponse"); + } + /** + * @summary Get a list of terminal models + * @param merchantId The unique identifier of the merchant account. + */ + public async listTerminalModels(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalModels" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalModelsResponse"); + } + /** + * @summary Get a list of orders + * @param merchantId + * @param customerOrderReference Your purchase order number. + * @param status The order status. Possible values (not case-sensitive): Placed, Confirmed, Cancelled, Shipped, Delivered. + * @param offset The number of orders to skip. + * @param limit The number of orders to return. + */ + public async listOrders(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalOrders" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrdersResponse"); + } + /** + * @summary Get an order + * @param merchantId The unique identifier of the merchant account. + * @param orderId The unique identifier of the order. + */ + public async getOrder(merchantId: string, orderId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalOrders/{orderId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + /** + * @summary Get a list of terminal products + * @param merchantId The unique identifier of the merchant account. + * @param country The country to return products for, in [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format. For example, **US** + * @param terminalModelId The terminal model to return products for. Use the ID returned in the [GET `/terminalModels`](https://docs.adyen.com/api-explorer/#/ManagementService/latest/get/terminalModels) response. For example, **Verifone.M400** + * @param offset The number of products to skip. + * @param limit The number of products to return. + */ + public async listTerminalProducts(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalProducts" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalProductsResponse"); + } + /** + * @summary Update an order + * @param merchantId The unique identifier of the merchant account. + * @param orderId The unique identifier of the order. + * @param terminalOrderRequest + */ + public async updateOrder(merchantId: string, orderId: string, terminalOrderRequest: TerminalOrderRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalOrders/{orderId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + const resource = new ManagementResource(this, localVarPath); + const request: TerminalOrderRequest = ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + /** + * @summary Create a shipping location + * @param merchantId The unique identifier of the merchant account. + * @param shippingLocation + */ + public async createShippingLocation(merchantId: string, shippingLocation: ShippingLocation, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/shippingLocations" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: ShippingLocation = ObjectSerializer.serialize(shippingLocation, "ShippingLocation"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "ShippingLocation"); + } + /** + * @summary Create an order + * @param merchantId The unique identifier of the merchant account. + * @param terminalOrderRequest + */ + public async createOrder(merchantId: string, terminalOrderRequest: TerminalOrderRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalOrders" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: TerminalOrderRequest = ObjectSerializer.serialize(terminalOrderRequest, "TerminalOrderRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } + /** + * @summary Cancel an order + * @param merchantId The unique identifier of the merchant account. + * @param orderId The unique identifier of the order. + */ + public async cancelOrder(merchantId: string, orderId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalOrders/{orderId}/cancel" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "TerminalOrder"); + } +} diff --git a/src/services/management/terminalSettingsCompanyLevelApi.ts b/src/services/management/terminalSettingsCompanyLevelApi.ts new file mode 100644 index 000000000..083243473 --- /dev/null +++ b/src/services/management/terminalSettingsCompanyLevelApi.ts @@ -0,0 +1,88 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { Logo } from '../../typings/management/models'; +import { TerminalSettings } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class TerminalSettingsCompanyLevelApi extends Service { + /** + * @summary Get the terminal logo + * @param companyId The unique identifier of the company account. + * @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T. + */ + public async getTerminalLogo(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalLogos" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Get terminal settings + * @param companyId The unique identifier of the company account. + */ + public async getTerminalSettings(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalSettings" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } + /** + * @summary Update the terminal logo + * @param companyId The unique identifier of the company account. + * @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T. + * @param logo + */ + public async updateTerminalLogo(companyId: string, logo: Logo, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalLogos" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const request: Logo = ObjectSerializer.serialize(logo, "Logo"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Update terminal settings + * @param companyId The unique identifier of the company account. + * @param terminalSettings + */ + public async updateTerminalSettings(companyId: string, terminalSettings: TerminalSettings, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/terminalSettings" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const request: TerminalSettings = ObjectSerializer.serialize(terminalSettings, "TerminalSettings"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } +} diff --git a/src/services/management/terminalSettingsMerchantLevelApi.ts b/src/services/management/terminalSettingsMerchantLevelApi.ts new file mode 100644 index 000000000..22b391c52 --- /dev/null +++ b/src/services/management/terminalSettingsMerchantLevelApi.ts @@ -0,0 +1,88 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { Logo } from '../../typings/management/models'; +import { TerminalSettings } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class TerminalSettingsMerchantLevelApi extends Service { + /** + * @summary Get the terminal logo + * @param merchantId The unique identifier of the merchant account. + * @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T. + */ + public async getTerminalLogo(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalLogos" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Get terminal settings + * @param merchantId The unique identifier of the merchant account. + */ + public async getTerminalSettings(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalSettings" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } + /** + * @summary Update the terminal logo + * @param merchantId The unique identifier of the merchant account. + * @param model The terminal model. Allowed values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T. + * @param logo + */ + public async updateTerminalLogo(merchantId: string, logo: Logo, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalLogos" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: Logo = ObjectSerializer.serialize(logo, "Logo"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Update terminal settings + * @param merchantId The unique identifier of the merchant account. + * @param terminalSettings + */ + public async updateTerminalSettings(merchantId: string, terminalSettings: TerminalSettings, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/terminalSettings" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: TerminalSettings = ObjectSerializer.serialize(terminalSettings, "TerminalSettings"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } +} diff --git a/src/services/management/terminalSettingsStoreLevelApi.ts b/src/services/management/terminalSettingsStoreLevelApi.ts new file mode 100644 index 000000000..a0084a5cb --- /dev/null +++ b/src/services/management/terminalSettingsStoreLevelApi.ts @@ -0,0 +1,162 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { Logo } from '../../typings/management/models'; +import { TerminalSettings } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class TerminalSettingsStoreLevelApi extends Service { + /** + * @summary Get the terminal logo + * @param merchantId The unique identifier of the merchant account. + * @param reference The reference that identifies the store. + * @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T. + */ + public async getTerminalLogo(merchantId: string, reference: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/stores/{reference}/terminalLogos" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'reference' + '}', encodeURIComponent(String(reference))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Get terminal settings + * @param merchantId The unique identifier of the merchant account. + * @param reference The reference that identifies the store. + */ + public async getTerminalSettings(merchantId: string, reference: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/stores/{reference}/terminalSettings" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'reference' + '}', encodeURIComponent(String(reference))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } + /** + * @summary Get the terminal logo + * @param storeId The unique identifier of the store. + * @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T. + */ + public async getTerminalLogoByStoreId(storeId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/stores/{storeId}/terminalLogos" + .replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Get terminal settings + * @param storeId The unique identifier of the store. + */ + public async getTerminalSettingsByStoreId(storeId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/stores/{storeId}/terminalSettings" + .replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } + /** + * @summary Update the terminal logo + * @param merchantId The unique identifier of the merchant account. + * @param reference The reference that identifies the store. + * @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T + * @param logo + */ + public async updateTerminalLogo(merchantId: string, reference: string, logo: Logo, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/stores/{reference}/terminalLogos" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'reference' + '}', encodeURIComponent(String(reference))); + const resource = new ManagementResource(this, localVarPath); + const request: Logo = ObjectSerializer.serialize(logo, "Logo"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Update terminal settings + * @param merchantId The unique identifier of the merchant account. + * @param reference The reference that identifies the store. + * @param terminalSettings + */ + public async updateTerminalSettings(merchantId: string, reference: string, terminalSettings: TerminalSettings, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/stores/{reference}/terminalSettings" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'reference' + '}', encodeURIComponent(String(reference))); + const resource = new ManagementResource(this, localVarPath); + const request: TerminalSettings = ObjectSerializer.serialize(terminalSettings, "TerminalSettings"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } + /** + * @summary Update the terminal logo + * @param storeId The unique identifier of the store. + * @param model The terminal model. Possible values: E355, VX675WIFIBT, VX680, VX690, VX700, VX820, M400, MX925, P400Plus, UX300, UX410, V200cPlus, V240mPlus, V400cPlus, V400m, e280, e285, e285p, S1E, S1EL, S1F2, S1L, S1U, S7T. + * @param logo + */ + public async updateTerminalLogoByStoreId(storeId: string, logo: Logo, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/stores/{storeId}/terminalLogos" + .replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId))); + const resource = new ManagementResource(this, localVarPath); + const request: Logo = ObjectSerializer.serialize(logo, "Logo"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Update terminal settings + * @param storeId The unique identifier of the store. + * @param terminalSettings + */ + public async updateTerminalSettingsByStoreId(storeId: string, terminalSettings: TerminalSettings, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/stores/{storeId}/terminalSettings" + .replace('{' + 'storeId' + '}', encodeURIComponent(String(storeId))); + const resource = new ManagementResource(this, localVarPath); + const request: TerminalSettings = ObjectSerializer.serialize(terminalSettings, "TerminalSettings"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } +} diff --git a/src/services/management/terminalSettingsTerminalLevelApi.ts b/src/services/management/terminalSettingsTerminalLevelApi.ts new file mode 100644 index 000000000..f078d0f46 --- /dev/null +++ b/src/services/management/terminalSettingsTerminalLevelApi.ts @@ -0,0 +1,86 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { Logo } from '../../typings/management/models'; +import { TerminalSettings } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class TerminalSettingsTerminalLevelApi extends Service { + /** + * @summary Get the terminal logo + * @param terminalId The unique identifier of the payment terminal. + */ + public async getTerminalLogo(terminalId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/terminals/{terminalId}/terminalLogos" + .replace('{' + 'terminalId' + '}', encodeURIComponent(String(terminalId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Get terminal settings + * @param terminalId The unique identifier of the payment terminal. + */ + public async getTerminalSettings(terminalId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/terminals/{terminalId}/terminalSettings" + .replace('{' + 'terminalId' + '}', encodeURIComponent(String(terminalId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } + /** + * @summary Update the logo + * @param terminalId The unique identifier of the payment terminal. + * @param logo + */ + public async updateLogo(terminalId: string, logo: Logo, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/terminals/{terminalId}/terminalLogos" + .replace('{' + 'terminalId' + '}', encodeURIComponent(String(terminalId))); + const resource = new ManagementResource(this, localVarPath); + const request: Logo = ObjectSerializer.serialize(logo, "Logo"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Logo"); + } + /** + * @summary Update terminal settings + * @param terminalId The unique identifier of the payment terminal. + * @param terminalSettings + */ + public async updateTerminalSettings(terminalId: string, terminalSettings: TerminalSettings, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/terminals/{terminalId}/terminalSettings" + .replace('{' + 'terminalId' + '}', encodeURIComponent(String(terminalId))); + const resource = new ManagementResource(this, localVarPath); + const request: TerminalSettings = ObjectSerializer.serialize(terminalSettings, "TerminalSettings"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "TerminalSettings"); + } +} diff --git a/src/services/management/terminalsTerminalLevelApi.ts b/src/services/management/terminalsTerminalLevelApi.ts new file mode 100644 index 000000000..709956561 --- /dev/null +++ b/src/services/management/terminalsTerminalLevelApi.ts @@ -0,0 +1,41 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { ListTerminalsResponse } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class TerminalsTerminalLevelApi extends Service { + /** + * @summary Get a list of terminals + * @param searchQuery Returns terminals with an ID that contains the specified string. If present, other query parameters are ignored. + * @param countries Returns terminals located in the countries specified by their [two-letter country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). + * @param merchantIds Returns terminals that belong to the merchant accounts specified by their unique merchant account ID. + * @param storeIds Returns terminals that are assigned to the [stores](https://docs.adyen.com/api-explorer/#/ManagementService/latest/get/stores) specified by their unique store ID. + * @param brandModels Returns terminals of the [models](https://docs.adyen.com/api-explorer/#/ManagementService/latest/get/companies/{companyId}/terminalModels) specified in the format *brand.model*. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 20 items on a page. + */ + public async listTerminals(requestOptions?: IRequest.Options): Promise { + const localVarPath = "/terminals"; + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListTerminalsResponse"); + } +} diff --git a/src/services/management/usersCompanyLevelApi.ts b/src/services/management/usersCompanyLevelApi.ts new file mode 100644 index 000000000..e39e493b4 --- /dev/null +++ b/src/services/management/usersCompanyLevelApi.ts @@ -0,0 +1,95 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { CompanyUser } from '../../typings/management/models'; +import { CreateCompanyUserRequest } from '../../typings/management/models'; +import { CreateCompanyUserResponse } from '../../typings/management/models'; +import { ListCompanyUsersResponse } from '../../typings/management/models'; +import { UpdateCompanyUserRequest } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class UsersCompanyLevelApi extends Service { + /** + * @summary Get a list of users + * @param companyId The unique identifier of the company account. + * @param pageNumber The number of the page to return. + * @param pageSize The number of items to have on a page. Maximum value is **100**. The default is **10** items on a page. + */ + public async listUsers(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/users" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListCompanyUsersResponse"); + } + /** + * @summary Get user details + * @param companyId The unique identifier of the company account. + * @param userId The unique identifier of the user. + */ + public async getUserDetails(companyId: string, userId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/users/{userId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'userId' + '}', encodeURIComponent(String(userId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "CompanyUser"); + } + /** + * @summary Update user details + * @param companyId The unique identifier of the company account. + * @param userId The unique identifier of the user. + * @param updateCompanyUserRequest + */ + public async updateUserDetails(companyId: string, userId: string, updateCompanyUserRequest: UpdateCompanyUserRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/users/{userId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'userId' + '}', encodeURIComponent(String(userId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdateCompanyUserRequest = ObjectSerializer.serialize(updateCompanyUserRequest, "UpdateCompanyUserRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "CompanyUser"); + } + /** + * @summary Create a new user + * @param companyId The unique identifier of the company account. + * @param createCompanyUserRequest + */ + public async createNewUser(companyId: string, createCompanyUserRequest: CreateCompanyUserRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/users" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const request: CreateCompanyUserRequest = ObjectSerializer.serialize(createCompanyUserRequest, "CreateCompanyUserRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "CreateCompanyUserResponse"); + } +} diff --git a/src/services/management/usersMerchantLevelApi.ts b/src/services/management/usersMerchantLevelApi.ts new file mode 100644 index 000000000..7a7024018 --- /dev/null +++ b/src/services/management/usersMerchantLevelApi.ts @@ -0,0 +1,95 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { CreateMerchantUserRequest } from '../../typings/management/models'; +import { CreateUserResponse } from '../../typings/management/models'; +import { ListMerchantUsersResponse } from '../../typings/management/models'; +import { UpdateMerchantUserRequest } from '../../typings/management/models'; +import { User } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class UsersMerchantLevelApi extends Service { + /** + * @summary Get a list of users + * @param merchantId Unique identifier of the merchant. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page. Maximum value is **100**. The default is **10** items on a page. + */ + public async listUsers(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/users" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListMerchantUsersResponse"); + } + /** + * @summary Get user details + * @param merchantId Unique identifier of the merchant. + * @param userId Unique identifier of the user. + */ + public async getUserDetails(merchantId: string, userId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/users/{userId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'userId' + '}', encodeURIComponent(String(userId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "User"); + } + /** + * @summary Update a user + * @param merchantId Unique identifier of the merchant. + * @param userId Unique identifier of the user. + * @param updateMerchantUserRequest + */ + public async updateUser(merchantId: string, userId: string, updateMerchantUserRequest: UpdateMerchantUserRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/users/{userId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'userId' + '}', encodeURIComponent(String(userId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdateMerchantUserRequest = ObjectSerializer.serialize(updateMerchantUserRequest, "UpdateMerchantUserRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "User"); + } + /** + * @summary Create a new user + * @param merchantId Unique identifier of the merchant. + * @param createMerchantUserRequest + */ + public async createNewUser(merchantId: string, createMerchantUserRequest: CreateMerchantUserRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/users" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: CreateMerchantUserRequest = ObjectSerializer.serialize(createMerchantUserRequest, "CreateMerchantUserRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "CreateUserResponse"); + } +} diff --git a/src/services/management/webhooksCompanyLevelApi.ts b/src/services/management/webhooksCompanyLevelApi.ts new file mode 100644 index 000000000..a6a99dd77 --- /dev/null +++ b/src/services/management/webhooksCompanyLevelApi.ts @@ -0,0 +1,149 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { CreateCompanyWebhookRequest } from '../../typings/management/models'; +import { GenerateHmacKeyResponse } from '../../typings/management/models'; +import { ListWebhooksResponse } from '../../typings/management/models'; +import { TestCompanyWebhookRequest } from '../../typings/management/models'; +import { TestWebhookResponse } from '../../typings/management/models'; +import { UpdateCompanyWebhookRequest } from '../../typings/management/models'; +import { Webhook } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class WebhooksCompanyLevelApi extends Service { + /** + * @summary Remove a webhook + * @param companyId The unique identifier of the company account. + * @param webhookId Unique identifier of the webhook configuration. + */ + public async removeWebhook(companyId: string, webhookId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/webhooks/{webhookId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + await getJsonResponse( + resource, + "", + { ...requestOptions, method: "DELETE" } + ); + } + /** + * @summary List all webhooks + * @param companyId Unique identifier of the [company account](https://docs.adyen.com/account/account-structure#company-account). + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + */ + public async listAllWebhooks(companyId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/webhooks" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListWebhooksResponse"); + } + /** + * @summary Get a webhook + * @param companyId Unique identifier of the [company account](https://docs.adyen.com/account/account-structure#company-account). + * @param webhookId Unique identifier of the webhook configuration. + */ + public async getWebhook(companyId: string, webhookId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/webhooks/{webhookId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Webhook"); + } + /** + * @summary Update a webhook + * @param companyId The unique identifier of the company account. + * @param webhookId Unique identifier of the webhook configuration. + * @param updateCompanyWebhookRequest + */ + public async updateWebhook(companyId: string, webhookId: string, updateCompanyWebhookRequest: UpdateCompanyWebhookRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/webhooks/{webhookId}" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdateCompanyWebhookRequest = ObjectSerializer.serialize(updateCompanyWebhookRequest, "UpdateCompanyWebhookRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Webhook"); + } + /** + * @summary Set up a webhook + * @param companyId Unique identifier of the [company account](https://docs.adyen.com/account/account-structure#company-account). + * @param createCompanyWebhookRequest + */ + public async setUpWebhook(companyId: string, createCompanyWebhookRequest: CreateCompanyWebhookRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/webhooks" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))); + const resource = new ManagementResource(this, localVarPath); + const request: CreateCompanyWebhookRequest = ObjectSerializer.serialize(createCompanyWebhookRequest, "CreateCompanyWebhookRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "Webhook"); + } + /** + * @summary Generate an HMAC key + * @param companyId The unique identifier of the company account. + * @param webhookId Unique identifier of the webhook configuration. + */ + public async generateHmacKey(companyId: string, webhookId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/webhooks/{webhookId}/generateHmac" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "GenerateHmacKeyResponse"); + } + /** + * @summary Test a webhook + * @param companyId The unique identifier of the company account. + * @param webhookId Unique identifier of the webhook configuration. + * @param testCompanyWebhookRequest + */ + public async testWebhook(companyId: string, webhookId: string, testCompanyWebhookRequest: TestCompanyWebhookRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/companies/{companyId}/webhooks/{webhookId}/test" + .replace('{' + 'companyId' + '}', encodeURIComponent(String(companyId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + const request: TestCompanyWebhookRequest = ObjectSerializer.serialize(testCompanyWebhookRequest, "TestCompanyWebhookRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "TestWebhookResponse"); + } +} diff --git a/src/services/management/webhooksMerchantLevelApi.ts b/src/services/management/webhooksMerchantLevelApi.ts new file mode 100644 index 000000000..c7cc7e8f9 --- /dev/null +++ b/src/services/management/webhooksMerchantLevelApi.ts @@ -0,0 +1,149 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +import { CreateMerchantWebhookRequest } from '../../typings/management/models'; +import { GenerateHmacKeyResponse } from '../../typings/management/models'; +import { ListWebhooksResponse } from '../../typings/management/models'; +import { TestWebhookRequest } from '../../typings/management/models'; +import { TestWebhookResponse } from '../../typings/management/models'; +import { UpdateMerchantWebhookRequest } from '../../typings/management/models'; +import { Webhook } from '../../typings/management/models'; +import { IRequest } from "../../typings/requestOptions"; +import ManagementResource from "../resource/management/managementResource"; +import { ObjectSerializer } from "../../typings/management/models"; + + +export default class WebhooksMerchantLevelApi extends Service { + /** + * @summary Remove a webhook + * @param merchantId The unique identifier of the merchant account. + * @param webhookId Unique identifier of the webhook configuration. + */ + public async removeWebhook(merchantId: string, webhookId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/webhooks/{webhookId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + await getJsonResponse( + resource, + "", + { ...requestOptions, method: "DELETE" } + ); + } + /** + * @summary List all webhooks + * @param merchantId The unique identifier of the merchant account. + * @param pageNumber The number of the page to fetch. + * @param pageSize The number of items to have on a page, maximum 100. The default is 10 items on a page. + */ + public async listAllWebhooks(merchantId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/webhooks" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "ListWebhooksResponse"); + } + /** + * @summary Get a webhook + * @param merchantId The unique identifier of the merchant account. + * @param webhookId Unique identifier of the webhook configuration. + */ + public async getWebhook(merchantId: string, webhookId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/webhooks/{webhookId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "GET" } + ); + return ObjectSerializer.deserialize(response, "Webhook"); + } + /** + * @summary Update a webhook + * @param merchantId The unique identifier of the merchant account. + * @param webhookId Unique identifier of the webhook configuration. + * @param updateMerchantWebhookRequest + */ + public async updateWebhook(merchantId: string, webhookId: string, updateMerchantWebhookRequest: UpdateMerchantWebhookRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/webhooks/{webhookId}" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + const request: UpdateMerchantWebhookRequest = ObjectSerializer.serialize(updateMerchantWebhookRequest, "UpdateMerchantWebhookRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "PATCH" } + ); + return ObjectSerializer.deserialize(response, "Webhook"); + } + /** + * @summary Set up a webhook + * @param merchantId The unique identifier of the merchant account. + * @param createMerchantWebhookRequest + */ + public async setUpWebhook(merchantId: string, createMerchantWebhookRequest: CreateMerchantWebhookRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/webhooks" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))); + const resource = new ManagementResource(this, localVarPath); + const request: CreateMerchantWebhookRequest = ObjectSerializer.serialize(createMerchantWebhookRequest, "CreateMerchantWebhookRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "Webhook"); + } + /** + * @summary Generate an HMAC key + * @param merchantId The unique identifier of the merchant account. + * @param webhookId + */ + public async generateHmacKey(merchantId: string, webhookId: string, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/webhooks/{webhookId}/generateHmac" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + const response = await getJsonResponse( + resource, + "", + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "GenerateHmacKeyResponse"); + } + /** + * @summary Test a webhook + * @param merchantId The unique identifier of the merchant account. + * @param webhookId Unique identifier of the webhook configuration. + * @param testWebhookRequest + */ + public async testWebhook(merchantId: string, webhookId: string, testWebhookRequest: TestWebhookRequest, requestOptions?: IRequest.Options): Promise { + const localVarPath = "/merchants/{merchantId}/webhooks/{webhookId}/test" + .replace('{' + 'merchantId' + '}', encodeURIComponent(String(merchantId))) + .replace('{' + 'webhookId' + '}', encodeURIComponent(String(webhookId))); + const resource = new ManagementResource(this, localVarPath); + const request: TestWebhookRequest = ObjectSerializer.serialize(testWebhookRequest, "TestWebhookRequest"); + const response = await getJsonResponse( + resource, + request, + { ...requestOptions, method: "POST" } + ); + return ObjectSerializer.deserialize(response, "TestWebhookResponse"); + } +} diff --git a/src/services/recurring.ts b/src/services/recurring.ts index a2f174253..499563ce5 100644 --- a/src/services/recurring.ts +++ b/src/services/recurring.ts @@ -1,10 +1,6 @@ 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"; -import NotifyShopper from "./resource/recurring/notifyShopper"; import { RecurringDetailsRequest, RecurringDetailsResult, @@ -13,50 +9,79 @@ import { ScheduleAccountUpdaterRequest, ScheduleAccountUpdaterResult, NotifyShopperRequest, - NotifyShopperResult + NotifyShopperResult, + CreatePermitRequest, + CreatePermitResult, + DisablePermitRequest, + DisablePermitResult, ObjectSerializer } from "../typings/recurring/models"; +import RecurringResource from "./resource/RecurringResource"; class Recurring extends Service { - private readonly _listRecurringDetails: ListRecurringDetails; - private readonly _disable: Disable; - private readonly _scheduleAccountUpdater: ScheduleAccountUpdater; - private readonly _notifyShopper: NotifyShopper; + private readonly _listRecurringDetails: RecurringResource; + private readonly _disable: RecurringResource; + private readonly _scheduleAccountUpdater: RecurringResource; + private readonly _notifyShopper: RecurringResource; + private readonly _createPermit: RecurringResource; + private readonly _disablePermit: RecurringResource; public constructor(client: Client) { super(client); - this._listRecurringDetails = new ListRecurringDetails(this); - this._disable = new Disable(this); - this._scheduleAccountUpdater = new ScheduleAccountUpdater(this); - this._notifyShopper = new NotifyShopper(this); + this._listRecurringDetails = new RecurringResource(this, "/listRecurringDetails"); + this._disable = new RecurringResource(this, "/disable"); + this._scheduleAccountUpdater = new RecurringResource(this, "/scheduleAccountUpdater"); + this._notifyShopper = new RecurringResource(this, "/notifyShopper"); + this._createPermit = new RecurringResource(this, "/createPermit"); + this._disablePermit = new RecurringResource(this, "/disablePermit") } - public listRecurringDetails(request: RecurringDetailsRequest): Promise { + public listRecurringDetails(recurringDetailsRequest: RecurringDetailsRequest): Promise { + const request: RecurringDetailsRequest = ObjectSerializer.serialize(recurringDetailsRequest, "RecurringDetailsRequest"); return getJsonResponse( this._listRecurringDetails, request, ); } - public disable(request: DisableRequest): Promise { + public disable(disableRequest: DisableRequest): Promise { + const request: DisableRequest = ObjectSerializer.serialize(disableRequest, "DisableRequest"); return getJsonResponse( this._disable, request, ); } - public scheduleAccountUpdater(request: ScheduleAccountUpdaterRequest): Promise { + public scheduleAccountUpdater(scheduleAccountUpdaterRequest: ScheduleAccountUpdaterRequest): Promise { + const request: ScheduleAccountUpdaterRequest = ObjectSerializer.serialize(scheduleAccountUpdaterRequest, "ScheduleAccountUpdaterRequest"); return getJsonResponse( this._scheduleAccountUpdater, request, ); } - public notifyShopper(request: NotifyShopperRequest): Promise { + public notifyShopper(notifyShopperRequest: NotifyShopperRequest): Promise { + const request: NotifyShopperRequest = ObjectSerializer.serialize(notifyShopperRequest, "NotifyShopperRequest"); return getJsonResponse( this._notifyShopper, request ); } + + public createPermit(createPermitRequest: CreatePermitRequest): Promise{ + const request: CreatePermitRequest = ObjectSerializer.serialize(createPermitRequest, "CreatePermitRequest"); + return getJsonResponse( + this._createPermit, + request + ); + } + + public disablePermit(disablePermitRequest: DisablePermitRequest): Promise{ + const request: DisablePermitRequest = ObjectSerializer.serialize(disablePermitRequest, "DisablePermitRequest"); + return getJsonResponse( + this._disablePermit, + request + ); + } } export default Recurring; diff --git a/src/services/resource/RecurringResource.ts b/src/services/resource/RecurringResource.ts new file mode 100644 index 000000000..41fc3c2e3 --- /dev/null +++ b/src/services/resource/RecurringResource.ts @@ -0,0 +1,14 @@ +import Client from "../../client"; +import Service from "../../service"; +import Resource from "../resource"; + +class RecurringResource extends Resource { + public constructor(service: Service, endpoint: string) { + super( + service, + `${service.client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}${endpoint}` , + ); + } +} + +export default RecurringResource; \ No newline at end of file diff --git a/src/services/resource/dataProtectionresource.ts b/src/services/resource/dataProtectionresource.ts new file mode 100644 index 000000000..824b69a1d --- /dev/null +++ b/src/services/resource/dataProtectionresource.ts @@ -0,0 +1,14 @@ +import Client from "../../client"; +import Service from "../../service"; +import Resource from "../resource"; + +class DataProtectionResource extends Resource { + public constructor(service: Service, endpoint: string) { + super( + service, + `${service.client.config.dataProtectionEndpoint}/${Client.DATA_PROTECTION_API_VERSION}${endpoint}` + ); + } +} + +export default DataProtectionResource; \ No newline at end of file diff --git a/src/services/resource/recurring/disable.ts b/src/services/resource/recurring/disable.ts deleted file mode 100644 index 0f49705eb..000000000 --- a/src/services/resource/recurring/disable.ts +++ /dev/null @@ -1,33 +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 Resource from "../../resource"; - -class Disable extends Resource { - public constructor(service: Service) { - super( - service, - `${service.client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}/disable`, - ); - } -} - -export default Disable; diff --git a/src/services/resource/recurring/listRecurringDetails.ts b/src/services/resource/recurring/listRecurringDetails.ts deleted file mode 100644 index d7aaac414..000000000 --- a/src/services/resource/recurring/listRecurringDetails.ts +++ /dev/null @@ -1,33 +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 Resource from "../../resource"; - -class ListRecurringDetails extends Resource { - public constructor(service: Service) { - super( - service, - `${service.client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}/listRecurringDetails`, - ); - } -} - -export default ListRecurringDetails; diff --git a/src/services/resource/recurring/notifyShopper.ts b/src/services/resource/recurring/notifyShopper.ts deleted file mode 100644 index ee0ec2a07..000000000 --- a/src/services/resource/recurring/notifyShopper.ts +++ /dev/null @@ -1,33 +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 Resource from "../../resource"; - -class NotifyShopper extends Resource { - public constructor(service: Service) { - super( - service, - `${service.client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}/notifyShopper`, - ); - } -} - -export default NotifyShopper; diff --git a/src/services/resource/recurring/scheduleAccountUpdater.ts b/src/services/resource/recurring/scheduleAccountUpdater.ts deleted file mode 100644 index 11fa87ac4..000000000 --- a/src/services/resource/recurring/scheduleAccountUpdater.ts +++ /dev/null @@ -1,33 +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 Resource from "../../resource"; - -class ScheduleAccountUpdater extends Resource { - public constructor(service: Service) { - super( - service, - `${service.client.config.endpoint}/pal/servlet/Recurring/${Client.RECURRING_API_VERSION}/scheduleAccountUpdater`, - ); - } -} - -export default ScheduleAccountUpdater; diff --git a/src/typings/dataProtection/models.ts b/src/typings/dataProtection/models.ts new file mode 100644 index 000000000..9d7b69738 --- /dev/null +++ b/src/typings/dataProtection/models.ts @@ -0,0 +1,154 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export * from './serviceError'; +export * from './subjectErasureByPspReferenceRequest'; +export * from './subjectErasureResponse'; + + +import { ServiceError } from './serviceError'; +import { SubjectErasureByPspReferenceRequest } from './subjectErasureByPspReferenceRequest'; +import { SubjectErasureResponse } from './subjectErasureResponse'; + +/* tslint:disable:no-unused-variable */ +let primitives = [ + "string", + "boolean", + "double", + "integer", + "long", + "float", + "number", + "any" + ]; + +let enumsMap: {[index: string]: any} = { + "SubjectErasureResponse.ResultEnum": SubjectErasureResponse.ResultEnum, +} + +let typeMap: {[index: string]: any} = { + "ServiceError": ServiceError, + "SubjectErasureByPspReferenceRequest": SubjectErasureByPspReferenceRequest, + "SubjectErasureResponse": SubjectErasureResponse, +} + +export class ObjectSerializer { + public static findCorrectType(data: any, expectedType: string) { + if (data == undefined) { + return expectedType; + } else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) { + return expectedType; + } else if (expectedType === "Date") { + return expectedType; + } else { + if (enumsMap[expectedType]) { + return expectedType; + } + + if (!typeMap[expectedType]) { + return expectedType; // w/e we don't know the type + } + + // Check the discriminator + let discriminatorProperty = typeMap[expectedType].discriminator; + if (discriminatorProperty == null) { + return expectedType; // the type does not have a discriminator. use it. + } else { + if (data[discriminatorProperty]) { + var discriminatorType = data[discriminatorProperty]; + if(typeMap[discriminatorType]){ + return discriminatorType; // use the type given in the discriminator + } else { + return expectedType; // discriminator did not map to a type + } + } else { + return expectedType; // discriminator was not present (or an empty string) + } + } + } + } + + public static serialize(data: any, type: string) { + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index = 0; index < data.length; index++) { + let datum = data[index]; + transformedData.push(ObjectSerializer.serialize(datum, subType)); + } + return transformedData; + } else if (type === "Date") { + return data.toISOString(); + } else if (type === "SaleToAcquirerData") { + const dataString = JSON.stringify(data); + return Buffer.from(dataString).toString("base64"); + } else { + if (enumsMap[type]) { + return data; + } + if (!typeMap[type]) { // in case we dont know the type + return data; + } + + // Get the actual type of this object + type = this.findCorrectType(data, type); + + // get the map for the correct type. + let attributeTypes = typeMap[type].getAttributeTypeMap(); + let instance: {[index: string]: any} = {}; + for (let index = 0; index < attributeTypes.length; index++) { + let attributeType = attributeTypes[index]; + instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type); + } + return instance; + } + } + + public static deserialize(data: any, type: string) { + // polymorphism may change the actual type. + type = ObjectSerializer.findCorrectType(data, type); + if (data == undefined) { + return data; + } else if (primitives.indexOf(type.toLowerCase()) !== -1) { + return data; + } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 + let subType: string = type.replace("Array<", ""); // Array => Type> + subType = subType.substring(0, subType.length - 1); // Type> => Type + let transformedData: any[] = []; + for (let index = 0; index < data.length; index++) { + let datum = data[index]; + transformedData.push(ObjectSerializer.deserialize(datum, subType)); + } + return transformedData; + } else if (type === "Date") { + return new Date(data); + } else { + if (enumsMap[type]) {// is Enum + return data; + } + + if (!typeMap[type]) { // dont know the type + return data; + } + let instance = new typeMap[type](); + let attributeTypes = typeMap[type].getAttributeTypeMap(); + for (let index = 0; index < attributeTypes.length; index++) { + let attributeType = attributeTypes[index]; + instance[attributeType.name] = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type); + } + return instance; + } + } +} diff --git a/src/typings/dataProtection/serviceError.ts b/src/typings/dataProtection/serviceError.ts new file mode 100644 index 000000000..2c988389e --- /dev/null +++ b/src/typings/dataProtection/serviceError.ts @@ -0,0 +1,66 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class ServiceError { + /** + * The error code mapped to the error message. + */ + 'errorCode'?: string; + /** + * The category of the error. + */ + 'errorType'?: string; + /** + * A short explanation of the issue. + */ + 'message'?: string; + /** + * The PSP reference of the payment. + */ + 'pspReference'?: string; + /** + * The HTTP response status. + */ + 'status'?: number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "errorCode", + "baseName": "errorCode", + "type": "string" + }, + { + "name": "errorType", + "baseName": "errorType", + "type": "string" + }, + { + "name": "message", + "baseName": "message", + "type": "string" + }, + { + "name": "pspReference", + "baseName": "pspReference", + "type": "string" + }, + { + "name": "status", + "baseName": "status", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return ServiceError.attributeTypeMap; + } +} + diff --git a/src/typings/dataProtection/subjectErasureByPspReferenceRequest.ts b/src/typings/dataProtection/subjectErasureByPspReferenceRequest.ts new file mode 100644 index 000000000..6537fb6ba --- /dev/null +++ b/src/typings/dataProtection/subjectErasureByPspReferenceRequest.ts @@ -0,0 +1,48 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class SubjectErasureByPspReferenceRequest { + /** + * Set this to **true** if you want to delete shopper-related data, even if the shopper has an existing recurring transaction. This only deletes the shopper-related data for the specific payment, but does not cancel the existing recurring transaction. + */ + 'forceErasure'?: boolean; + /** + * Your merchant account + */ + 'merchantAccount'?: string; + /** + * The PSP reference of the payment. We will delete all shopper-related data for this payment. + */ + 'pspReference'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "forceErasure", + "baseName": "forceErasure", + "type": "boolean" + }, + { + "name": "merchantAccount", + "baseName": "merchantAccount", + "type": "string" + }, + { + "name": "pspReference", + "baseName": "pspReference", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return SubjectErasureByPspReferenceRequest.attributeTypeMap; + } +} + diff --git a/src/typings/dataProtection/subjectErasureResponse.ts b/src/typings/dataProtection/subjectErasureResponse.ts new file mode 100644 index 000000000..b39566ebe --- /dev/null +++ b/src/typings/dataProtection/subjectErasureResponse.ts @@ -0,0 +1,38 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class SubjectErasureResponse { + /** + * The result of this operation. + */ + 'result'?: SubjectErasureResponse.ResultEnum; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "result", + "baseName": "result", + "type": "SubjectErasureResponse.ResultEnum" + } ]; + + static getAttributeTypeMap() { + return SubjectErasureResponse.attributeTypeMap; + } +} + +export namespace SubjectErasureResponse { + export enum ResultEnum { + ActiveRecurringTokenExists = 'ACTIVE_RECURRING_TOKEN_EXISTS', + AlreadyProcessed = 'ALREADY_PROCESSED', + PaymentNotFound = 'PAYMENT_NOT_FOUND', + Success = 'SUCCESS' + } +} diff --git a/src/typings/index.ts b/src/typings/index.ts index db18a6893..78590ba0c 100644 --- a/src/typings/index.ts +++ b/src/typings/index.ts @@ -9,9 +9,11 @@ /// /// +export * as balancePlatform from './balancePlatform/models'; export * as binlookup from './binlookup/models'; export * as checkout from './checkout/models'; export * as notification from './notification/models'; +export * as payments from './payments/models'; export * as payouts from './payouts/models'; export * as platformsNotifications from './platformsNotifications/models'; export * as platformsAccount from './platformsAccount/models'; @@ -24,3 +26,4 @@ export * as terminalManagement from './terminalManagement/models'; export * as management from './management/models'; export * as legalEntityManagement from './legalEntityManagement/models'; export * as transfer from './transfer/models'; +export * as dataProtection from './dataProtection/models'; diff --git a/src/typings/management/applePayInfo.ts b/src/typings/management/applePayInfo.ts index 9bd89b65f..fc38ff98e 100644 --- a/src/typings/management/applePayInfo.ts +++ b/src/typings/management/applePayInfo.ts @@ -10,9 +10,9 @@ export class ApplePayInfo { /** - * The list of merchant domains. For more information, see [Apple Pay documentation](https://docs.adyen.com/payment-methods/apple-pay/enable-apple-pay#register-merchant-domain). + * The list of merchant domains. Maximum: 99 domains per request. For more information, see [Apple Pay documentation](https://docs.adyen.com/payment-methods/apple-pay/web-drop-in?tab=adyen-certificate-live_1#going-live). */ - 'domains': Array; + 'domains'?: Array; static discriminator: string | undefined = undefined; diff --git a/src/typings/management/companyUser.ts b/src/typings/management/companyUser.ts index 580765251..e7a2f6282 100644 --- a/src/typings/management/companyUser.ts +++ b/src/typings/management/companyUser.ts @@ -44,7 +44,7 @@ export class CompanyUser { /** * The username for this user. */ - 'username': string; + 'username'?: string; static discriminator: string | undefined = undefined; diff --git a/src/typings/management/configuration.ts b/src/typings/management/configuration.ts index 6eef6a946..01461d53b 100644 --- a/src/typings/management/configuration.ts +++ b/src/typings/management/configuration.ts @@ -21,7 +21,7 @@ export class Configuration { /** * Funding source. Possible values: * **Credit** * **Debit** */ - 'sources'?: Configuration.SourcesEnum; + 'sources'?: Array; static discriminator: string | undefined = undefined; @@ -39,7 +39,7 @@ export class Configuration { { "name": "sources", "baseName": "sources", - "type": "Configuration.SourcesEnum" + "type": "Array" } ]; static getAttributeTypeMap() { @@ -47,7 +47,3 @@ export class Configuration { } } -export namespace Configuration { - export enum SourcesEnum { - } -} diff --git a/src/typings/management/createCompanyUserRequest.ts b/src/typings/management/createCompanyUserRequest.ts index ba24cb5e0..772403f7b 100644 --- a/src/typings/management/createCompanyUserRequest.ts +++ b/src/typings/management/createCompanyUserRequest.ts @@ -21,8 +21,8 @@ export class CreateCompanyUserRequest { /** * The email address of the user. */ - 'email': string; - 'name': Name; + 'email'?: string; + 'name'?: Name; /** * The list of [roles](https://docs.adyen.com/account/user-roles) for this user. */ @@ -34,7 +34,7 @@ export class CreateCompanyUserRequest { /** * The username for this user. Allowed length: 255 alphanumeric characters. */ - 'username': string; + 'username'?: string; static discriminator: string | undefined = undefined; diff --git a/src/typings/management/createCompanyUserResponse.ts b/src/typings/management/createCompanyUserResponse.ts index a1d81083e..c0ad79ff5 100644 --- a/src/typings/management/createCompanyUserResponse.ts +++ b/src/typings/management/createCompanyUserResponse.ts @@ -44,7 +44,7 @@ export class CreateCompanyUserResponse { /** * The username for this user. */ - 'username': string; + 'username'?: string; static discriminator: string | undefined = undefined; diff --git a/src/typings/management/createMerchantRequest.ts b/src/typings/management/createMerchantRequest.ts index 6366ccd6f..3de6f5bd5 100644 --- a/src/typings/management/createMerchantRequest.ts +++ b/src/typings/management/createMerchantRequest.ts @@ -33,6 +33,10 @@ export class CreateMerchantRequest { * Your reference for the merchant account. To make this reference the unique identifier of the merchant account, your Adyen contact can set up a template on your company account. The template can have 6 to 255 characters with upper- and lower-case letters, underscores, and numbers. When your company account has a template, then the `reference` is required and must be unique within the company account. */ 'reference'?: string; + /** + * List of sales channels that the merchant will process payments with + */ + 'salesChannels'?: Array; static discriminator: string | undefined = undefined; @@ -66,6 +70,11 @@ export class CreateMerchantRequest { "name": "reference", "baseName": "reference", "type": "string" + }, + { + "name": "salesChannels", + "baseName": "salesChannels", + "type": "Array" } ]; static getAttributeTypeMap() { diff --git a/src/typings/management/createMerchantUserRequest.ts b/src/typings/management/createMerchantUserRequest.ts index ff4f78380..1e9531848 100644 --- a/src/typings/management/createMerchantUserRequest.ts +++ b/src/typings/management/createMerchantUserRequest.ts @@ -17,8 +17,8 @@ export class CreateMerchantUserRequest { /** * The email address of the user. */ - 'email': string; - 'name': Name; + 'email'?: string; + 'name'?: Name; /** * The list of [roles](https://docs.adyen.com/account/user-roles) for this user. */ @@ -30,7 +30,7 @@ export class CreateMerchantUserRequest { /** * The username for this user. Allowed length: 255 alphanumeric characters. */ - 'username': string; + 'username'?: string; static discriminator: string | undefined = undefined; diff --git a/src/typings/management/createUserResponse.ts b/src/typings/management/createUserResponse.ts index 58601c680..3696d6c60 100644 --- a/src/typings/management/createUserResponse.ts +++ b/src/typings/management/createUserResponse.ts @@ -40,7 +40,7 @@ export class CreateUserResponse { /** * The username for this user. */ - 'username': string; + 'username'?: string; static discriminator: string | undefined = undefined; diff --git a/src/typings/management/googlePayInfo.ts b/src/typings/management/googlePayInfo.ts new file mode 100644 index 000000000..e8a64779d --- /dev/null +++ b/src/typings/management/googlePayInfo.ts @@ -0,0 +1,30 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class GooglePayInfo { + /** + * Google Pay [Merchant ID](https://support.google.com/paymentscenter/answer/7163092?hl=en). Character length and limitations: 16 alphanumeric characters or 20 numeric characters. + */ + 'merchantId'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "merchantId", + "baseName": "merchantId", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return GooglePayInfo.attributeTypeMap; + } +} + diff --git a/src/typings/management/key.ts b/src/typings/management/key.ts new file mode 100644 index 000000000..51cef2310 --- /dev/null +++ b/src/typings/management/key.ts @@ -0,0 +1,48 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class Key { + /** + * Identifier + */ + 'identifier'?: string; + /** + * Passphrase + */ + 'passphrase'?: string; + /** + * Version number + */ + 'version'?: number; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "identifier", + "baseName": "identifier", + "type": "string" + }, + { + "name": "passphrase", + "baseName": "passphrase", + "type": "string" + }, + { + "name": "version", + "baseName": "version", + "type": "number" + } ]; + + static getAttributeTypeMap() { + return Key.attributeTypeMap; + } +} + diff --git a/src/typings/management/klarnaInfo.ts b/src/typings/management/klarnaInfo.ts index 94a3b7e05..1a58f2aee 100644 --- a/src/typings/management/klarnaInfo.ts +++ b/src/typings/management/klarnaInfo.ts @@ -20,7 +20,7 @@ export class KlarnaInfo { /** * The region of operation. For example, **NA**, **EU**, **CH**, **AU**. */ - 'region': KlarnaInfo.RegionEnum; + 'region'?: KlarnaInfo.RegionEnum; /** * The email address of merchant support. */ diff --git a/src/typings/management/mealVoucherFRInfo.ts b/src/typings/management/mealVoucherFRInfo.ts new file mode 100644 index 000000000..76ed0af6f --- /dev/null +++ b/src/typings/management/mealVoucherFRInfo.ts @@ -0,0 +1,52 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class MealVoucherFRInfo { + /** + * Meal Voucher conecsId. Format: digits only + */ + 'conecsId': string; + /** + * Meal Voucher siret. Format: 14 digits. + */ + 'siret': string; + /** + * The list of additional payment methods + */ + 'subTypes'?: MealVoucherFRInfo.SubTypesEnum; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "conecsId", + "baseName": "conecsId", + "type": "string" + }, + { + "name": "siret", + "baseName": "siret", + "type": "string" + }, + { + "name": "subTypes", + "baseName": "subTypes", + "type": "MealVoucherFRInfo.SubTypesEnum" + } ]; + + static getAttributeTypeMap() { + return MealVoucherFRInfo.attributeTypeMap; + } +} + +export namespace MealVoucherFRInfo { + export enum SubTypesEnum { + } +} diff --git a/src/typings/management/models.ts b/src/typings/management/models.ts index 0474b7cb7..ad756529f 100644 --- a/src/typings/management/models.ts +++ b/src/typings/management/models.ts @@ -57,6 +57,7 @@ export * from './generateApiKeyResponse'; export * from './generateClientKeyResponse'; export * from './generateHmacKeyResponse'; export * from './giroPayInfo'; +export * from './googlePayInfo'; export * from './gratuity'; export * from './hardware'; export * from './idName'; @@ -65,6 +66,7 @@ export * from './installAndroidCertificateDetails'; export * from './invalidField'; export * from './jSONObject'; export * from './jSONPath'; +export * from './key'; export * from './klarnaInfo'; export * from './links'; export * from './linksElement'; @@ -80,6 +82,7 @@ export * from './listTerminalsResponse'; export * from './listWebhooksResponse'; export * from './logo'; export * from './meApiCredential'; +export * from './mealVoucherFRInfo'; export * from './merchant'; export * from './merchantLinks'; export * from './minorUnitsMonetaryValue'; @@ -87,10 +90,12 @@ export * from './modelFile'; export * from './name'; export * from './name2'; export * from './nexo'; +export * from './notificationUrl'; export * from './offlineProcessing'; export * from './opi'; export * from './orderItem'; export * from './paginationLinks'; +export * from './passcodes'; export * from './payPalInfo'; export * from './paymentMethod'; export * from './paymentMethodResponse'; @@ -112,6 +117,7 @@ export * from './shippingLocationsResponse'; export * from './shopperStatement'; export * from './signature'; export * from './sofortInfo'; +export * from './standalone'; export * from './store'; export * from './storeCreationRequest'; export * from './storeCreationWithMerchantCodeRequest'; @@ -200,6 +206,7 @@ import { GenerateApiKeyResponse } from './generateApiKeyResponse'; import { GenerateClientKeyResponse } from './generateClientKeyResponse'; import { GenerateHmacKeyResponse } from './generateHmacKeyResponse'; import { GiroPayInfo } from './giroPayInfo'; +import { GooglePayInfo } from './googlePayInfo'; import { Gratuity } from './gratuity'; import { Hardware } from './hardware'; import { IdName } from './idName'; @@ -208,6 +215,7 @@ import { InstallAndroidCertificateDetails } from './installAndroidCertificateDet import { InvalidField } from './invalidField'; import { JSONObject } from './jSONObject'; import { JSONPath } from './jSONPath'; +import { Key } from './key'; import { KlarnaInfo } from './klarnaInfo'; import { Links } from './links'; import { LinksElement } from './linksElement'; @@ -223,6 +231,7 @@ import { ListTerminalsResponse } from './listTerminalsResponse'; import { ListWebhooksResponse } from './listWebhooksResponse'; import { Logo } from './logo'; import { MeApiCredential } from './meApiCredential'; +import { MealVoucherFRInfo } from './mealVoucherFRInfo'; import { Merchant } from './merchant'; import { MerchantLinks } from './merchantLinks'; import { MinorUnitsMonetaryValue } from './minorUnitsMonetaryValue'; @@ -230,10 +239,12 @@ import { ModelFile } from './modelFile'; import { Name } from './name'; import { Name2 } from './name2'; import { Nexo } from './nexo'; +import { NotificationUrl } from './notificationUrl'; import { OfflineProcessing } from './offlineProcessing'; import { Opi } from './opi'; import { OrderItem } from './orderItem'; import { PaginationLinks } from './paginationLinks'; +import { Passcodes } from './passcodes'; import { PayPalInfo } from './payPalInfo'; import { PaymentMethod } from './paymentMethod'; import { PaymentMethodResponse } from './paymentMethodResponse'; @@ -255,6 +266,7 @@ import { ShippingLocationsResponse } from './shippingLocationsResponse'; import { ShopperStatement } from './shopperStatement'; import { Signature } from './signature'; import { SofortInfo } from './sofortInfo'; +import { Standalone } from './standalone'; import { Store } from './store'; import { StoreCreationRequest } from './storeCreationRequest'; import { StoreCreationWithMerchantCodeRequest } from './storeCreationWithMerchantCodeRequest'; @@ -306,7 +318,6 @@ let primitives = [ ]; let enumsMap: {[index: string]: any} = { - "Configuration.SourcesEnum": Configuration.SourcesEnum, "Connectivity.SimcardStatusEnum": Connectivity.SimcardStatusEnum, "CreateCompanyWebhookRequest.CommunicationFormatEnum": CreateCompanyWebhookRequest.CommunicationFormatEnum, "CreateCompanyWebhookRequest.FilterMerchantAccountTypeEnum": CreateCompanyWebhookRequest.FilterMerchantAccountTypeEnum, @@ -318,7 +329,9 @@ let enumsMap: {[index: string]: any} = { "InstallAndroidAppDetails.TypeEnum": InstallAndroidAppDetails.TypeEnum, "InstallAndroidCertificateDetails.TypeEnum": InstallAndroidCertificateDetails.TypeEnum, "KlarnaInfo.RegionEnum": KlarnaInfo.RegionEnum, + "MealVoucherFRInfo.SubTypesEnum": MealVoucherFRInfo.SubTypesEnum, "PaymentMethod.VerificationStatusEnum": PaymentMethod.VerificationStatusEnum, + "PaymentMethodResponse.TypesWithErrorsEnum": PaymentMethodResponse.TypesWithErrorsEnum, "PaymentMethodSetupInfo.ShopperInteractionEnum": PaymentMethodSetupInfo.ShopperInteractionEnum, "PaymentMethodSetupInfo.TypeEnum": PaymentMethodSetupInfo.TypeEnum, "PayoutSettings.PriorityEnum": PayoutSettings.PriorityEnum, @@ -392,6 +405,7 @@ let typeMap: {[index: string]: any} = { "GenerateClientKeyResponse": GenerateClientKeyResponse, "GenerateHmacKeyResponse": GenerateHmacKeyResponse, "GiroPayInfo": GiroPayInfo, + "GooglePayInfo": GooglePayInfo, "Gratuity": Gratuity, "Hardware": Hardware, "IdName": IdName, @@ -400,6 +414,7 @@ let typeMap: {[index: string]: any} = { "InvalidField": InvalidField, "JSONObject": JSONObject, "JSONPath": JSONPath, + "Key": Key, "KlarnaInfo": KlarnaInfo, "Links": Links, "LinksElement": LinksElement, @@ -415,6 +430,7 @@ let typeMap: {[index: string]: any} = { "ListWebhooksResponse": ListWebhooksResponse, "Logo": Logo, "MeApiCredential": MeApiCredential, + "MealVoucherFRInfo": MealVoucherFRInfo, "Merchant": Merchant, "MerchantLinks": MerchantLinks, "MinorUnitsMonetaryValue": MinorUnitsMonetaryValue, @@ -422,10 +438,12 @@ let typeMap: {[index: string]: any} = { "Name": Name, "Name2": Name2, "Nexo": Nexo, + "NotificationUrl": NotificationUrl, "OfflineProcessing": OfflineProcessing, "Opi": Opi, "OrderItem": OrderItem, "PaginationLinks": PaginationLinks, + "Passcodes": Passcodes, "PayPalInfo": PayPalInfo, "PaymentMethod": PaymentMethod, "PaymentMethodResponse": PaymentMethodResponse, @@ -447,6 +465,7 @@ let typeMap: {[index: string]: any} = { "ShopperStatement": ShopperStatement, "Signature": Signature, "SofortInfo": SofortInfo, + "Standalone": Standalone, "Store": Store, "StoreCreationRequest": StoreCreationRequest, "StoreCreationWithMerchantCodeRequest": StoreCreationWithMerchantCodeRequest, diff --git a/src/typings/management/nexo.ts b/src/typings/management/nexo.ts index 53b406e78..baf89f98b 100644 --- a/src/typings/management/nexo.ts +++ b/src/typings/management/nexo.ts @@ -8,8 +8,12 @@ */ import { EventUrl } from './eventUrl'; +import { Key } from './key'; +import { NotificationUrl } from './notificationUrl'; export class Nexo { + 'displayUrls'?: NotificationUrl; + 'encryptionKey'?: Key; 'eventUrls'?: EventUrl; /** * @deprecated One or more URLs to send event messages to when using Terminal API. @@ -19,6 +23,16 @@ export class Nexo { static discriminator: string | undefined = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "displayUrls", + "baseName": "displayUrls", + "type": "NotificationUrl" + }, + { + "name": "encryptionKey", + "baseName": "encryptionKey", + "type": "Key" + }, { "name": "eventUrls", "baseName": "eventUrls", diff --git a/src/typings/management/notificationUrl.ts b/src/typings/management/notificationUrl.ts new file mode 100644 index 000000000..9026bc25b --- /dev/null +++ b/src/typings/management/notificationUrl.ts @@ -0,0 +1,40 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + +import { Url } from './url'; + +export class NotificationUrl { + /** + * One or more local URLs to send notifications to when using Terminal API. + */ + 'localUrls'?: Array; + /** + * One or more public URLs to send notifications to when using Terminal API. + */ + 'publicUrls'?: Array; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "localUrls", + "baseName": "localUrls", + "type": "Array" + }, + { + "name": "publicUrls", + "baseName": "publicUrls", + "type": "Array" + } ]; + + static getAttributeTypeMap() { + return NotificationUrl.attributeTypeMap; + } +} + diff --git a/src/typings/management/passcodes.ts b/src/typings/management/passcodes.ts new file mode 100644 index 000000000..221027cd3 --- /dev/null +++ b/src/typings/management/passcodes.ts @@ -0,0 +1,57 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class Passcodes { + /** + * The pin code used to enter the admin menu + */ + 'adminMenuPin'?: string; + /** + * Allows merchant to create a dedicated PIN for standalone refund functionality + */ + 'refundPin'?: string; + /** + * Passcode to unlock screen after sleep + */ + 'screenLockPin'?: string; + /** + * The PIN code used to enter the transaction menu + */ + 'txMenuPin'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "adminMenuPin", + "baseName": "adminMenuPin", + "type": "string" + }, + { + "name": "refundPin", + "baseName": "refundPin", + "type": "string" + }, + { + "name": "screenLockPin", + "baseName": "screenLockPin", + "type": "string" + }, + { + "name": "txMenuPin", + "baseName": "txMenuPin", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return Passcodes.attributeTypeMap; + } +} + diff --git a/src/typings/management/paymentMethod.ts b/src/typings/management/paymentMethod.ts index ea5711838..d16cc38fe 100644 --- a/src/typings/management/paymentMethod.ts +++ b/src/typings/management/paymentMethod.ts @@ -11,7 +11,9 @@ import { ApplePayInfo } from './applePayInfo'; import { BcmcInfo } from './bcmcInfo'; import { CartesBancairesInfo } from './cartesBancairesInfo'; import { GiroPayInfo } from './giroPayInfo'; +import { GooglePayInfo } from './googlePayInfo'; import { KlarnaInfo } from './klarnaInfo'; +import { MealVoucherFRInfo } from './mealVoucherFRInfo'; import { PayPalInfo } from './payPalInfo'; import { SofortInfo } from './sofortInfo'; import { SwishInfo } from './swishInfo'; @@ -37,17 +39,27 @@ export class PaymentMethod { */ 'currencies'?: Array; /** + * The list of custom routing flags to route payment to the intended acquirer. + */ + 'customRoutingFlags'?: Array; + /** * Indicates whether the payment method is enabled (**true**) or disabled (**false**). */ 'enabled'?: boolean; 'giroPay'?: GiroPayInfo; + 'googlePay'?: GooglePayInfo; /** * The identifier of the resource. */ 'id': string; 'klarna'?: KlarnaInfo; + 'mealVoucherFR'?: MealVoucherFRInfo; 'paypal'?: PayPalInfo; /** + * Your reference for the payment method. Supported characters a-z, A-Z, 0-9. + */ + 'reference'?: string; + /** * The sales channel. */ 'shopperInteraction'?: string; @@ -104,6 +116,11 @@ export class PaymentMethod { "baseName": "currencies", "type": "Array" }, + { + "name": "customRoutingFlags", + "baseName": "customRoutingFlags", + "type": "Array" + }, { "name": "enabled", "baseName": "enabled", @@ -114,6 +131,11 @@ export class PaymentMethod { "baseName": "giroPay", "type": "GiroPayInfo" }, + { + "name": "googlePay", + "baseName": "googlePay", + "type": "GooglePayInfo" + }, { "name": "id", "baseName": "id", @@ -124,11 +146,21 @@ export class PaymentMethod { "baseName": "klarna", "type": "KlarnaInfo" }, + { + "name": "mealVoucherFR", + "baseName": "mealVoucher_FR", + "type": "MealVoucherFRInfo" + }, { "name": "paypal", "baseName": "paypal", "type": "PayPalInfo" }, + { + "name": "reference", + "baseName": "reference", + "type": "string" + }, { "name": "shopperInteraction", "baseName": "shopperInteraction", diff --git a/src/typings/management/paymentMethodResponse.ts b/src/typings/management/paymentMethodResponse.ts index 1e747a0fd..787fab04b 100644 --- a/src/typings/management/paymentMethodResponse.ts +++ b/src/typings/management/paymentMethodResponse.ts @@ -24,6 +24,10 @@ export class PaymentMethodResponse { * Total number of pages. */ 'pagesTotal': number; + /** + * Payment method types with errors. + */ + 'typesWithErrors'?: Array; static discriminator: string | undefined = undefined; @@ -47,6 +51,11 @@ export class PaymentMethodResponse { "name": "pagesTotal", "baseName": "pagesTotal", "type": "number" + }, + { + "name": "typesWithErrors", + "baseName": "typesWithErrors", + "type": "Array" } ]; static getAttributeTypeMap() { @@ -54,3 +63,50 @@ export class PaymentMethodResponse { } } +export namespace PaymentMethodResponse { + export enum TypesWithErrorsEnum { + Alipay = 'alipay', + Amex = 'amex', + Applepay = 'applepay', + Bcmc = 'bcmc', + Blik = 'blik', + Cartebancaire = 'cartebancaire', + Cup = 'cup', + Diners = 'diners', + DirectEbanking = 'directEbanking', + DirectdebitGb = 'directdebit_GB', + Discover = 'discover', + EbankingFi = 'ebanking_FI', + EftposAustralia = 'eftpos_australia', + Elo = 'elo', + Elocredit = 'elocredit', + Elodebit = 'elodebit', + Girocard = 'girocard', + Giropay = 'giropay', + Googlepay = 'googlepay', + Hiper = 'hiper', + Hipercard = 'hipercard', + Ideal = 'ideal', + InteracCard = 'interac_card', + Jcb = 'jcb', + Klarna = 'klarna', + KlarnaAccount = 'klarna_account', + KlarnaPaynow = 'klarna_paynow', + Maestro = 'maestro', + Mbway = 'mbway', + Mc = 'mc', + Mcdebit = 'mcdebit', + MealVoucherFr = 'mealVoucher_FR', + Mobilepay = 'mobilepay', + Multibanco = 'multibanco', + Paypal = 'paypal', + Payshop = 'payshop', + Swish = 'swish', + Trustly = 'trustly', + Visa = 'visa', + Visadebit = 'visadebit', + Vpay = 'vpay', + Wechatpay = 'wechatpay', + WechatpayPos = 'wechatpay_pos' + } +} diff --git a/src/typings/management/paymentMethodSetupInfo.ts b/src/typings/management/paymentMethodSetupInfo.ts index 97e840ac4..8b7046cc3 100644 --- a/src/typings/management/paymentMethodSetupInfo.ts +++ b/src/typings/management/paymentMethodSetupInfo.ts @@ -11,7 +11,9 @@ import { ApplePayInfo } from './applePayInfo'; import { BcmcInfo } from './bcmcInfo'; import { CartesBancairesInfo } from './cartesBancairesInfo'; import { GiroPayInfo } from './giroPayInfo'; +import { GooglePayInfo } from './googlePayInfo'; import { KlarnaInfo } from './klarnaInfo'; +import { MealVoucherFRInfo } from './mealVoucherFRInfo'; import { PayPalInfo } from './payPalInfo'; import { SofortInfo } from './sofortInfo'; import { SwishInfo } from './swishInfo'; @@ -32,10 +34,20 @@ export class PaymentMethodSetupInfo { * The list of currencies that a payment method supports. By default, all currencies supported by the payment method. */ 'currencies'?: Array; + /** + * The list of custom routing flags to route payment to the intended acquirer. + */ + 'customRoutingFlags'?: Array; 'giroPay'?: GiroPayInfo; + 'googlePay'?: GooglePayInfo; 'klarna'?: KlarnaInfo; + 'mealVoucherFR'?: MealVoucherFRInfo; 'paypal'?: PayPalInfo; /** + * Your reference for the payment method. Supported characters a-z, A-Z, 0-9. + */ + 'reference'?: string; + /** * The sales channel. Required if the merchant account does not have a sales channel. When you provide this field, it overrides the default sales channel set on the merchant account. Possible values: **eCommerce**, **pos**, **contAuth**, and **moto**. */ 'shopperInteraction'?: PaymentMethodSetupInfo.ShopperInteractionEnum; @@ -48,7 +60,7 @@ export class PaymentMethodSetupInfo { /** * Payment method [variant](https://docs.adyen.com/development-resources/paymentmethodvariant#management-api). */ - 'type': PaymentMethodSetupInfo.TypeEnum; + 'type'?: PaymentMethodSetupInfo.TypeEnum; static discriminator: string | undefined = undefined; @@ -83,21 +95,41 @@ export class PaymentMethodSetupInfo { "baseName": "currencies", "type": "Array" }, + { + "name": "customRoutingFlags", + "baseName": "customRoutingFlags", + "type": "Array" + }, { "name": "giroPay", "baseName": "giroPay", "type": "GiroPayInfo" }, + { + "name": "googlePay", + "baseName": "googlePay", + "type": "GooglePayInfo" + }, { "name": "klarna", "baseName": "klarna", "type": "KlarnaInfo" }, + { + "name": "mealVoucherFR", + "baseName": "mealVoucher_FR", + "type": "MealVoucherFRInfo" + }, { "name": "paypal", "baseName": "paypal", "type": "PayPalInfo" }, + { + "name": "reference", + "baseName": "reference", + "type": "string" + }, { "name": "shopperInteraction", "baseName": "shopperInteraction", @@ -150,8 +182,14 @@ export namespace PaymentMethodSetupInfo { Discover = 'discover', EbankingFi = 'ebanking_FI', EftposAustralia = 'eftpos_australia', + Elo = 'elo', + Elocredit = 'elocredit', + Elodebit = 'elodebit', Girocard = 'girocard', Giropay = 'giropay', + Googlepay = 'googlepay', + Hiper = 'hiper', + Hipercard = 'hipercard', Ideal = 'ideal', InteracCard = 'interac_card', Jcb = 'jcb', @@ -161,6 +199,8 @@ export namespace PaymentMethodSetupInfo { Maestro = 'maestro', Mbway = 'mbway', Mc = 'mc', + Mcdebit = 'mcdebit', + MealVoucherFr = 'mealVoucher_FR', Mobilepay = 'mobilepay', Multibanco = 'multibanco', Paypal = 'paypal', @@ -168,6 +208,8 @@ export namespace PaymentMethodSetupInfo { Swish = 'swish', Trustly = 'trustly', Visa = 'visa', + Visadebit = 'visadebit', + Vpay = 'vpay', Wechatpay = 'wechatpay', WechatpayPos = 'wechatpay_pos' } diff --git a/src/typings/management/shopperStatement.ts b/src/typings/management/shopperStatement.ts index 6a5cb4ee1..235f52dd5 100644 --- a/src/typings/management/shopperStatement.ts +++ b/src/typings/management/shopperStatement.ts @@ -12,7 +12,7 @@ export class ShopperStatement { /** * The name you want to be shown on the shopper\'s bank or credit card statement. Maximum length: 22 characters; can\'t be all numbers. */ - 'doingBusinessAsName': string; + 'doingBusinessAsName'?: string; /** * The type of shopperstatement you want to use: fixed, append or dynamic */ diff --git a/src/typings/management/signature.ts b/src/typings/management/signature.ts index 06fd33583..b5679e70a 100644 --- a/src/typings/management/signature.ts +++ b/src/typings/management/signature.ts @@ -18,6 +18,10 @@ export class Signature { */ 'deviceName'?: string; /** + * Slogan shown on the start screen of the device. + */ + 'deviceSlogan'?: string; + /** * Skip asking for a signature. This is possible because all global card schemes (American Express, Diners, Discover, JCB, MasterCard, VISA, and UnionPay) regard a signature as optional. */ 'skipSignature'?: boolean; @@ -35,6 +39,11 @@ export class Signature { "baseName": "deviceName", "type": "string" }, + { + "name": "deviceSlogan", + "baseName": "deviceSlogan", + "type": "string" + }, { "name": "skipSignature", "baseName": "skipSignature", diff --git a/src/typings/management/standalone.ts b/src/typings/management/standalone.ts new file mode 100644 index 000000000..3a4385bf8 --- /dev/null +++ b/src/typings/management/standalone.ts @@ -0,0 +1,39 @@ +/* + * The version of the OpenAPI document: v1 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class Standalone { + /** + * The default currency that will be used when the device is in standalone mode (ISO 4217 - 3 letter code). + */ + 'currencyCode'?: string; + /** + * Enable standalone mode. + */ + 'enableStandalone'?: boolean; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "currencyCode", + "baseName": "currencyCode", + "type": "string" + }, + { + "name": "enableStandalone", + "baseName": "enableStandalone", + "type": "boolean" + } ]; + + static getAttributeTypeMap() { + return Standalone.attributeTypeMap; + } +} + diff --git a/src/typings/management/swishInfo.ts b/src/typings/management/swishInfo.ts index efb51874e..e8e5b5085 100644 --- a/src/typings/management/swishInfo.ts +++ b/src/typings/management/swishInfo.ts @@ -12,7 +12,7 @@ export class SwishInfo { /** * Swish number. Format: 10 digits without spaces. For example, **1231111111**. */ - 'swishNumber': string; + 'swishNumber'?: string; static discriminator: string | undefined = undefined; diff --git a/src/typings/management/terminalSettings.ts b/src/typings/management/terminalSettings.ts index 5858250ba..d91dd147d 100644 --- a/src/typings/management/terminalSettings.ts +++ b/src/typings/management/terminalSettings.ts @@ -14,9 +14,11 @@ import { Hardware } from './hardware'; import { Nexo } from './nexo'; import { OfflineProcessing } from './offlineProcessing'; import { Opi } from './opi'; +import { Passcodes } from './passcodes'; import { ReceiptOptions } from './receiptOptions'; import { ReceiptPrinting } from './receiptPrinting'; import { Signature } from './signature'; +import { Standalone } from './standalone'; import { Surcharge } from './surcharge'; import { Timeouts } from './timeouts'; import { WifiProfiles } from './wifiProfiles'; @@ -32,9 +34,11 @@ export class TerminalSettings { 'nexo'?: Nexo; 'offlineProcessing'?: OfflineProcessing; 'opi'?: Opi; + 'passcodes'?: Passcodes; 'receiptOptions'?: ReceiptOptions; 'receiptPrinting'?: ReceiptPrinting; 'signature'?: Signature; + 'standalone'?: Standalone; 'surcharge'?: Surcharge; 'timeouts'?: Timeouts; 'wifiProfiles'?: WifiProfiles; @@ -77,6 +81,11 @@ export class TerminalSettings { "baseName": "opi", "type": "Opi" }, + { + "name": "passcodes", + "baseName": "passcodes", + "type": "Passcodes" + }, { "name": "receiptOptions", "baseName": "receiptOptions", @@ -92,6 +101,11 @@ export class TerminalSettings { "baseName": "signature", "type": "Signature" }, + { + "name": "standalone", + "baseName": "standalone", + "type": "Standalone" + }, { "name": "surcharge", "baseName": "surcharge", diff --git a/src/typings/management/updatePaymentMethodInfo.ts b/src/typings/management/updatePaymentMethodInfo.ts index c2f858752..06a784546 100644 --- a/src/typings/management/updatePaymentMethodInfo.ts +++ b/src/typings/management/updatePaymentMethodInfo.ts @@ -19,6 +19,10 @@ export class UpdatePaymentMethodInfo { */ 'currencies'?: Array; /** + * Custom routing flags for acquirer routing. + */ + 'customRoutingFlags'?: Array; + /** * Indicates whether the payment method is enabled (**true**) or disabled (**false**). */ 'enabled'?: boolean; @@ -37,6 +41,11 @@ export class UpdatePaymentMethodInfo { "baseName": "currencies", "type": "Array" }, + { + "name": "customRoutingFlags", + "baseName": "customRoutingFlags", + "type": "Array" + }, { "name": "enabled", "baseName": "enabled", diff --git a/src/typings/management/user.ts b/src/typings/management/user.ts index e694b8042..1dcf1227f 100644 --- a/src/typings/management/user.ts +++ b/src/typings/management/user.ts @@ -40,7 +40,7 @@ export class User { /** * The username for this user. */ - 'username': string; + 'username'?: string; static discriminator: string | undefined = undefined; diff --git a/src/typings/recurring/card.ts b/src/typings/recurring/card.ts index 4faa202e4..a3b54c6a9 100644 --- a/src/typings/recurring/card.ts +++ b/src/typings/recurring/card.ts @@ -16,7 +16,7 @@ export class Card { /** * The card expiry month. Format: 2 digits, zero-padded for single digits. For example: * 03 = March * 11 = November */ - 'expiryMonth': string; + 'expiryMonth'?: string; /** * The card expiry year. Format: 4 digits. For example: 2020 */ @@ -32,7 +32,7 @@ export class Card { /** * The card number (4-19 characters). Do not use any separators. When this value is returned in a response, only the last 4 digits of the card number are returned. */ - 'number': string; + 'number'?: string; /** * The month component of the start date (for some UK debit cards only). */ diff --git a/src/typings/recurring/createPermitRequest.ts b/src/typings/recurring/createPermitRequest.ts new file mode 100644 index 000000000..3bb9231aa --- /dev/null +++ b/src/typings/recurring/createPermitRequest.ts @@ -0,0 +1,58 @@ +/* + * The version of the OpenAPI document: v68 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + +import { Permit } from './permit'; + +export class CreatePermitRequest { + /** + * The merchant account identifier, with which you want to process the transaction. + */ + 'merchantAccount': string; + /** + * The permits to create for this recurring contract. + */ + 'permits': Array; + /** + * The recurring contract the new permits will use. + */ + 'recurringDetailReference': string; + /** + * The shopper\'s reference to uniquely identify this shopper (e.g. user ID or account ID). + */ + 'shopperReference': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "merchantAccount", + "baseName": "merchantAccount", + "type": "string" + }, + { + "name": "permits", + "baseName": "permits", + "type": "Array" + }, + { + "name": "recurringDetailReference", + "baseName": "recurringDetailReference", + "type": "string" + }, + { + "name": "shopperReference", + "baseName": "shopperReference", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return CreatePermitRequest.attributeTypeMap; + } +} + diff --git a/src/typings/recurring/createPermitResult.ts b/src/typings/recurring/createPermitResult.ts new file mode 100644 index 000000000..32598bdb9 --- /dev/null +++ b/src/typings/recurring/createPermitResult.ts @@ -0,0 +1,40 @@ +/* + * The version of the OpenAPI document: v68 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + +import { PermitResult } from './permitResult'; + +export class CreatePermitResult { + /** + * List of new permits. + */ + 'permitResultList'?: Array; + /** + * A unique reference associated with the request. This value is globally unique; quote it when communicating with us about this request. + */ + 'pspReference'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "permitResultList", + "baseName": "permitResultList", + "type": "Array" + }, + { + "name": "pspReference", + "baseName": "pspReference", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return CreatePermitResult.attributeTypeMap; + } +} + diff --git a/src/typings/recurring/disablePermitRequest.ts b/src/typings/recurring/disablePermitRequest.ts new file mode 100644 index 000000000..f5409d1d1 --- /dev/null +++ b/src/typings/recurring/disablePermitRequest.ts @@ -0,0 +1,39 @@ +/* + * The version of the OpenAPI document: v68 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class DisablePermitRequest { + /** + * The merchant account identifier, with which you want to process the transaction. + */ + 'merchantAccount': string; + /** + * The permit token to disable. + */ + 'token': string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "merchantAccount", + "baseName": "merchantAccount", + "type": "string" + }, + { + "name": "token", + "baseName": "token", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return DisablePermitRequest.attributeTypeMap; + } +} + diff --git a/src/typings/recurring/disablePermitResult.ts b/src/typings/recurring/disablePermitResult.ts new file mode 100644 index 000000000..3cd94681a --- /dev/null +++ b/src/typings/recurring/disablePermitResult.ts @@ -0,0 +1,39 @@ +/* + * The version of the OpenAPI document: v68 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class DisablePermitResult { + /** + * A unique reference associated with the request. This value is globally unique; quote it when communicating with us about this request. + */ + 'pspReference'?: string; + /** + * Status of the disable request. + */ + 'status'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "pspReference", + "baseName": "pspReference", + "type": "string" + }, + { + "name": "status", + "baseName": "status", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return DisablePermitResult.attributeTypeMap; + } +} + diff --git a/src/typings/recurring/models.ts b/src/typings/recurring/models.ts index 283669650..02e643c72 100644 --- a/src/typings/recurring/models.ts +++ b/src/typings/recurring/models.ts @@ -12,11 +12,18 @@ export * from './address'; export * from './amount'; export * from './bankAccount'; export * from './card'; +export * from './createPermitRequest'; +export * from './createPermitResult'; +export * from './disablePermitRequest'; +export * from './disablePermitResult'; export * from './disableRequest'; export * from './disableResult'; export * from './name'; export * from './notifyShopperRequest'; export * from './notifyShopperResult'; +export * from './permit'; +export * from './permitRestriction'; +export * from './permitResult'; export * from './recurring'; export * from './recurringDetail'; export * from './recurringDetailsRequest'; @@ -31,11 +38,18 @@ import { Address } from './address'; import { Amount } from './amount'; import { BankAccount } from './bankAccount'; import { Card } from './card'; +import { CreatePermitRequest } from './createPermitRequest'; +import { CreatePermitResult } from './createPermitResult'; +import { DisablePermitRequest } from './disablePermitRequest'; +import { DisablePermitResult } from './disablePermitResult'; import { DisableRequest } from './disableRequest'; import { DisableResult } from './disableResult'; import { Name } from './name'; import { NotifyShopperRequest } from './notifyShopperRequest'; import { NotifyShopperResult } from './notifyShopperResult'; +import { Permit } from './permit'; +import { PermitRestriction } from './permitRestriction'; +import { PermitResult } from './permitResult'; import { Recurring } from './recurring'; import { RecurringDetail } from './recurringDetail'; import { RecurringDetailsRequest } from './recurringDetailsRequest'; @@ -67,11 +81,18 @@ let typeMap: {[index: string]: any} = { "Amount": Amount, "BankAccount": BankAccount, "Card": Card, + "CreatePermitRequest": CreatePermitRequest, + "CreatePermitResult": CreatePermitResult, + "DisablePermitRequest": DisablePermitRequest, + "DisablePermitResult": DisablePermitResult, "DisableRequest": DisableRequest, "DisableResult": DisableResult, "Name": Name, "NotifyShopperRequest": NotifyShopperRequest, "NotifyShopperResult": NotifyShopperResult, + "Permit": Permit, + "PermitRestriction": PermitRestriction, + "PermitResult": PermitResult, "Recurring": Recurring, "RecurringDetail": RecurringDetail, "RecurringDetailsRequest": RecurringDetailsRequest, diff --git a/src/typings/recurring/permit.ts b/src/typings/recurring/permit.ts new file mode 100644 index 000000000..05507c6f0 --- /dev/null +++ b/src/typings/recurring/permit.ts @@ -0,0 +1,64 @@ +/* + * The version of the OpenAPI document: v68 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + +import { PermitRestriction } from './permitRestriction'; + +export class Permit { + /** + * Partner ID (when using the permit-per-partner token sharing model). + */ + 'partnerId'?: string; + /** + * The profile to apply to this permit (when using the shared permits model). + */ + 'profileReference'?: string; + 'restriction'?: PermitRestriction; + /** + * The key to link permit requests to permit results. + */ + 'resultKey'?: string; + /** + * The expiry date for this permit. + */ + 'validTillDate'?: Date; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "partnerId", + "baseName": "partnerId", + "type": "string" + }, + { + "name": "profileReference", + "baseName": "profileReference", + "type": "string" + }, + { + "name": "restriction", + "baseName": "restriction", + "type": "PermitRestriction" + }, + { + "name": "resultKey", + "baseName": "resultKey", + "type": "string" + }, + { + "name": "validTillDate", + "baseName": "validTillDate", + "type": "Date" + } ]; + + static getAttributeTypeMap() { + return Permit.attributeTypeMap; + } +} + diff --git a/src/typings/recurring/permitRestriction.ts b/src/typings/recurring/permitRestriction.ts new file mode 100644 index 000000000..c740a9547 --- /dev/null +++ b/src/typings/recurring/permitRestriction.ts @@ -0,0 +1,43 @@ +/* + * The version of the OpenAPI document: v68 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + +import { Amount } from './amount'; + +export class PermitRestriction { + 'maxAmount'?: Amount; + 'singleTransactionLimit'?: Amount; + /** + * Only a single payment can be made using this permit if set to true, otherwise multiple payments are allowed. + */ + 'singleUse'?: boolean; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "maxAmount", + "baseName": "maxAmount", + "type": "Amount" + }, + { + "name": "singleTransactionLimit", + "baseName": "singleTransactionLimit", + "type": "Amount" + }, + { + "name": "singleUse", + "baseName": "singleUse", + "type": "boolean" + } ]; + + static getAttributeTypeMap() { + return PermitRestriction.attributeTypeMap; + } +} + diff --git a/src/typings/recurring/permitResult.ts b/src/typings/recurring/permitResult.ts new file mode 100644 index 000000000..6ac3c2277 --- /dev/null +++ b/src/typings/recurring/permitResult.ts @@ -0,0 +1,39 @@ +/* + * The version of the OpenAPI document: v68 + * Contact: developer-experience@adyen.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit this class manually. + */ + + +export class PermitResult { + /** + * The key to link permit requests to permit results. + */ + 'resultKey'?: string; + /** + * The permit token which is used to make payments by the partner company. + */ + 'token'?: string; + + static discriminator: string | undefined = undefined; + + static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ + { + "name": "resultKey", + "baseName": "resultKey", + "type": "string" + }, + { + "name": "token", + "baseName": "token", + "type": "string" + } ]; + + static getAttributeTypeMap() { + return PermitResult.attributeTypeMap; + } +} + diff --git a/src/typings/requestOptions.ts b/src/typings/requestOptions.ts index 9a54fd152..463804cb9 100644 --- a/src/typings/requestOptions.ts +++ b/src/typings/requestOptions.ts @@ -25,7 +25,8 @@ import * as https from "https"; import { URLSearchParams } from "url"; export namespace IRequest { - type QueryString = URLSearchParams | string | NodeJS.Dict | Iterable<[string, string]> | Array<[string, string]>; + type QueryString = ConstructorParameters[0]; + export type Options = https.RequestOptions & { idempotencyKey?: string; params?: QueryString; diff --git a/src/typings/terminal/outputBarcode.ts b/src/typings/terminal/outputBarcode.ts index 382d944f6..7151df180 100644 --- a/src/typings/terminal/outputBarcode.ts +++ b/src/typings/terminal/outputBarcode.ts @@ -33,7 +33,7 @@ export class OutputBarcode { 'BarcodeType'?: OutputBarcode.BarcodeTypeEnum; - 'Value'?: string; + 'BarcodeValue'?: string; static discriminator: string | undefined = undefined; @@ -44,8 +44,8 @@ export class OutputBarcode { "type": "OutputBarcode.BarcodeTypeEnum" }, { - "name": "Value", - "baseName": "Value", + "name": "BarcodeValue", + "baseName": "BarcodeValue", "type": "string" } ]; diff --git a/src/typings/terminal/pOIStatus.ts b/src/typings/terminal/pOIStatus.ts index b0c124842..487da57d5 100644 --- a/src/typings/terminal/pOIStatus.ts +++ b/src/typings/terminal/pOIStatus.ts @@ -16,13 +16,13 @@ * This file is open source and available under the MIT license. * See the LICENSE file for more info. */ - + /** * Terminal API * Definition of Terminal API Schema * * The version of the OpenAPI document: 1.0.0 - * + * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech @@ -34,21 +34,21 @@ import { CashHandlingDevice } from './cashHandlingDevice'; import { GlobalStatusType } from './globalStatusType'; export class POIStatus { - 'CardReaderOkFlag'?: boolean; + 'CardReaderOKFlag'?: boolean; 'CashHandlingDevice'?: Array; - 'CommunicationOkFlag'?: boolean; + 'CommunicationOKFlag'?: boolean; 'FraudPreventionFlag'?: boolean; 'GlobalStatus': GlobalStatusType; 'PEDOKFlag'?: boolean; 'PrinterStatus'?: POIStatus.PrinterStatusEnum; - 'SecurityOkFlag'?: boolean; + 'SecurityOKFlag'?: boolean; static discriminator: string | undefined = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { - "name": "CardReaderOkFlag", - "baseName": "CardReaderOkFlag", + "name": "CardReaderOKFlag", + "baseName": "CardReaderOKFlag", "type": "boolean" }, { @@ -57,8 +57,8 @@ export class POIStatus { "type": "Array" }, { - "name": "CommunicationOkFlag", - "baseName": "CommunicationOkFlag", + "name": "CommunicationOKFlag", + "baseName": "CommunicationOKFlag", "type": "boolean" }, { @@ -82,8 +82,8 @@ export class POIStatus { "type": "POIStatus.PrinterStatusEnum" }, { - "name": "SecurityOkFlag", - "baseName": "SecurityOkFlag", + "name": "SecurityOKFlag", + "baseName": "SecurityOKFlag", "type": "boolean" } ]; diff --git a/templates/typescript/api-all.mustache b/templates/typescript/api-all.mustache new file mode 100644 index 000000000..2e8d1aa0b --- /dev/null +++ b/templates/typescript/api-all.mustache @@ -0,0 +1,25 @@ +{{>licenseInfo}} + +{{#apiInfo}} +import Service from "../service"; +import Client from "../client"; + +{{#apis}} +{{#operations}} +import {{ classname }} from './{{serviceName}}/{{ classFilename }}'; +{{/operations}} +{{/apis}} + +export default class {{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}} extends Service { + public constructor(client: Client) { + super(client); + } +{{#apis}} + {{#operations}} + public get {{ classname }}() { + return new {{ classname }}(this.client); + } + {{/operations}} +{{/apis}} +} +{{/apiInfo}} \ No newline at end of file diff --git a/templates/typescript/api-single.mustache b/templates/typescript/api-single.mustache new file mode 100644 index 000000000..52aa697fc --- /dev/null +++ b/templates/typescript/api-single.mustache @@ -0,0 +1,43 @@ +{{>licenseInfo}} + +import getJsonResponse from "../../helpers/getJsonResponse"; +import Service from "../../service"; +/* tslint:disable:no-unused-locals */ +{{#imports}} +import { {{classname}} } from '../../typings/{{serviceName}}/models'; +{{/imports}} +import { IRequest } from "../../typings/requestOptions"; +import {{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}}Resource from "../resource/{{serviceName}}/{{serviceName}}Resource"; +import { ObjectSerializer } from "../../typings/{{serviceName}}/models"; + +{{#operations}} + +export default class {{classname}} extends Service { +{{#operation}} + /** + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{paramName}} {{description}} + {{/allParams}} + */ + public async {{#vendorExtensions.x-methodName}}{{.}}{{/vendorExtensions.x-methodName}}{{^vendorExtensions.x-methodName}}{{nickname}}{{/vendorExtensions.x-methodName}}({{#pathParams}}{{paramName}}: {{{dataType}}}, {{/pathParams}}{{#bodyParams}}{{paramName}}: {{{dataType}}}, {{/bodyParams}}requestOptions?: IRequest.Options): Promise<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}}> { + const localVarPath = "{{{path}}}"{{#pathParams}} + .replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}}; + const resource = new {{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}}Resource(this, localVarPath); +{{#bodyParam}} + const request: {{{dataType}}} = ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}"); +{{/bodyParam}} + {{#returnType}}const response = {{/returnType}}await getJsonResponse<{{#bodyParam}}{{{dataType}}}{{/bodyParam}}{{^bodyParam}}string{{/bodyParam}}, {{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}void{{/returnType}}>( + resource, + {{#bodyParam}}request{{/bodyParam}}{{^bodyParam}}""{{/bodyParam}}, + { ...requestOptions, method: "{{httpMethod}}" } + ); + {{#returnType}} + return ObjectSerializer.deserialize(response, "{{{.}}}"); + {{/returnType}} + } +{{/operation}} +} +{{/operations}} diff --git a/yarn.lock b/yarn.lock index 8bc7ea7c1..85ab224aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -818,10 +818,10 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/jest@27.5.0": - version "27.5.0" - resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.5.0.tgz#e04ed1824ca6b1dd0438997ba60f99a7405d4c7b" - integrity sha512-9RBFx7r4k+msyj/arpfaa0WOOEcaAZNmN+j80KFbFCoSqCJGHTz7YMAMGQW9Xmqm5w6l5c25vbSjMwlikJi5+g== +"@types/jest@27.5.2": + version "27.5.2" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.5.2.tgz#ec49d29d926500ffb9fd22b84262e862049c026c" + integrity sha512-mpT8LJJ4CMeeahobofYWIjFo0xonRS/HfxnVEPMPFSQdGUt1uHCnoPT7Zhb+sjDU2wz0oKV0OLUR0WzrHNgfeA== dependencies: jest-matcher-utils "^27.0.0" pretty-format "^27.0.0" @@ -843,10 +843,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.3.tgz#463fc47f13ec0688a33aec75d078a0541a447199" integrity sha512-HzNRZtp4eepNitP+BD6k2L6DROIDG4Q0fm4x+dwfsr6LGmROENnok75VGw40628xf+iR24WeMFcHuuBDUAzzsQ== -"@types/node@14.0.9": - version "14.0.9" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.9.tgz#43896ab87fc82bda1dfd600cdf44a0c8a64e11d2" - integrity sha512-0sCTiXKXELOBxvZLN4krQ0FPOAA7ij+6WwvD0k/PHd9/KAkr4dXel5J9fh6F4x1FwAQILqAWkmpeuS6mjf1iKA== +"@types/node@14.18.36": + version "14.18.36" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.36.tgz#c414052cb9d43fab67d679d5f3c641be911f5835" + integrity sha512-FXKWbsJ6a1hIrRxv+FoukuHnGTgEzKYGi7kilfMae96AL9UNkPFNWJEEYWzdRI9ooIkbr4AKldyuSTLql06vLQ== "@types/parse-json@^4.0.0": version "4.0.0" @@ -880,86 +880,121 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@5.41.0": - version "5.41.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.41.0.tgz#f8eeb1c6bb2549f795f3ba71aec3b38d1ab6b1e1" - integrity sha512-DXUS22Y57/LAFSg3x7Vi6RNAuLpTXwxB9S2nIA7msBb/Zt8p7XqMwdpdc1IU7CkOQUPgAqR5fWvxuKCbneKGmA== +"@typescript-eslint/eslint-plugin@5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.43.0.tgz#4a5248eb31b454715ddfbf8cfbf497529a0a78bc" + integrity sha512-wNPzG+eDR6+hhW4yobEmpR36jrqqQv1vxBq5LJO3fBAktjkvekfr4BRl+3Fn1CM/A+s8/EiGUbOMDoYqWdbtXA== dependencies: - "@typescript-eslint/scope-manager" "5.41.0" - "@typescript-eslint/type-utils" "5.41.0" - "@typescript-eslint/utils" "5.41.0" + "@typescript-eslint/scope-manager" "5.43.0" + "@typescript-eslint/type-utils" "5.43.0" + "@typescript-eslint/utils" "5.43.0" debug "^4.3.4" ignore "^5.2.0" + natural-compare-lite "^1.4.0" regexpp "^3.2.0" semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/parser@5.41.0": - version "5.41.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.41.0.tgz#0414a6405007e463dc527b459af1f19430382d67" - integrity sha512-HQVfix4+RL5YRWZboMD1pUfFN8MpRH4laziWkkAzyO1fvNOY/uinZcvo3QiFJVS/siNHupV8E5+xSwQZrl6PZA== +"@typescript-eslint/parser@5.45.0": + version "5.45.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.45.0.tgz#b18a5f6b3cf1c2b3e399e9d2df4be40d6b0ddd0e" + integrity sha512-brvs/WSM4fKUmF5Ot/gEve6qYiCMjm6w4HkHPfS6ZNmxTS0m0iNN4yOChImaCkqc1hRwFGqUyanMXuGal6oyyQ== dependencies: - "@typescript-eslint/scope-manager" "5.41.0" - "@typescript-eslint/types" "5.41.0" - "@typescript-eslint/typescript-estree" "5.41.0" + "@typescript-eslint/scope-manager" "5.45.0" + "@typescript-eslint/types" "5.45.0" + "@typescript-eslint/typescript-estree" "5.45.0" debug "^4.3.4" -"@typescript-eslint/scope-manager@5.41.0": - version "5.41.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.41.0.tgz#28e3a41d626288d0628be14cf9de8d49fc30fadf" - integrity sha512-xOxPJCnuktUkY2xoEZBKXO5DBCugFzjrVndKdUnyQr3+9aDWZReKq9MhaoVnbL+maVwWJu/N0SEtrtEUNb62QQ== +"@typescript-eslint/scope-manager@5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.43.0.tgz#566e46303392014d5d163704724872e1f2dd3c15" + integrity sha512-XNWnGaqAtTJsUiZaoiGIrdJYHsUOd3BZ3Qj5zKp9w6km6HsrjPk/TGZv0qMTWyWj0+1QOqpHQ2gZOLXaGA9Ekw== dependencies: - "@typescript-eslint/types" "5.41.0" - "@typescript-eslint/visitor-keys" "5.41.0" + "@typescript-eslint/types" "5.43.0" + "@typescript-eslint/visitor-keys" "5.43.0" -"@typescript-eslint/type-utils@5.41.0": - version "5.41.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.41.0.tgz#2371601171e9f26a4e6da918a7913f7266890cdf" - integrity sha512-L30HNvIG6A1Q0R58e4hu4h+fZqaO909UcnnPbwKiN6Rc3BUEx6ez2wgN7aC0cBfcAjZfwkzE+E2PQQ9nEuoqfA== +"@typescript-eslint/scope-manager@5.45.0": + version "5.45.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.45.0.tgz#7a4ac1bfa9544bff3f620ab85947945938319a96" + integrity sha512-noDMjr87Arp/PuVrtvN3dXiJstQR1+XlQ4R1EvzG+NMgXi8CuMCXpb8JqNtFHKceVSQ985BZhfRdowJzbv4yKw== dependencies: - "@typescript-eslint/typescript-estree" "5.41.0" - "@typescript-eslint/utils" "5.41.0" + "@typescript-eslint/types" "5.45.0" + "@typescript-eslint/visitor-keys" "5.45.0" + +"@typescript-eslint/type-utils@5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.43.0.tgz#91110fb827df5161209ecca06f70d19a96030be6" + integrity sha512-K21f+KY2/VvYggLf5Pk4tgBOPs2otTaIHy2zjclo7UZGLyFH86VfUOm5iq+OtDtxq/Zwu2I3ujDBykVW4Xtmtg== + dependencies: + "@typescript-eslint/typescript-estree" "5.43.0" + "@typescript-eslint/utils" "5.43.0" debug "^4.3.4" tsutils "^3.21.0" -"@typescript-eslint/types@5.41.0": - version "5.41.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.41.0.tgz#6800abebc4e6abaf24cdf220fb4ce28f4ab09a85" - integrity sha512-5BejraMXMC+2UjefDvrH0Fo/eLwZRV6859SXRg+FgbhA0R0l6lDqDGAQYhKbXhPN2ofk2kY5sgGyLNL907UXpA== +"@typescript-eslint/types@5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.43.0.tgz#e4ddd7846fcbc074325293515fa98e844d8d2578" + integrity sha512-jpsbcD0x6AUvV7tyOlyvon0aUsQpF8W+7TpJntfCUWU1qaIKu2K34pMwQKSzQH8ORgUrGYY6pVIh1Pi8TNeteg== + +"@typescript-eslint/types@5.45.0": + version "5.45.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.45.0.tgz#794760b9037ee4154c09549ef5a96599621109c5" + integrity sha512-QQij+u/vgskA66azc9dCmx+rev79PzX8uDHpsqSjEFtfF2gBUTRCpvYMh2gw2ghkJabNkPlSUCimsyBEQZd1DA== + +"@typescript-eslint/typescript-estree@5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.43.0.tgz#b6883e58ba236a602c334be116bfc00b58b3b9f2" + integrity sha512-BZ1WVe+QQ+igWal2tDbNg1j2HWUkAa+CVqdU79L4HP9izQY6CNhXfkNwd1SS4+sSZAP/EthI1uiCSY/+H0pROg== + dependencies: + "@typescript-eslint/types" "5.43.0" + "@typescript-eslint/visitor-keys" "5.43.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" -"@typescript-eslint/typescript-estree@5.41.0": - version "5.41.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.41.0.tgz#bf5c6b3138adbdc73ba4871d060ae12c59366c61" - integrity sha512-SlzFYRwFSvswzDSQ/zPkIWcHv8O5y42YUskko9c4ki+fV6HATsTODUPbRbcGDFYP86gaJL5xohUEytvyNNcXWg== +"@typescript-eslint/typescript-estree@5.45.0": + version "5.45.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.45.0.tgz#f70a0d646d7f38c0dfd6936a5e171a77f1e5291d" + integrity sha512-maRhLGSzqUpFcZgXxg1qc/+H0bT36lHK4APhp0AEUVrpSwXiRAomm/JGjSG+kNUio5kAa3uekCYu/47cnGn5EQ== dependencies: - "@typescript-eslint/types" "5.41.0" - "@typescript-eslint/visitor-keys" "5.41.0" + "@typescript-eslint/types" "5.45.0" + "@typescript-eslint/visitor-keys" "5.45.0" debug "^4.3.4" globby "^11.1.0" is-glob "^4.0.3" semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/utils@5.41.0": - version "5.41.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.41.0.tgz#f41ae5883994a249d00b2ce69f4188f3a23fa0f9" - integrity sha512-QlvfwaN9jaMga9EBazQ+5DDx/4sAdqDkcs05AsQHMaopluVCUyu1bTRUVKzXbgjDlrRAQrYVoi/sXJ9fmG+KLQ== +"@typescript-eslint/utils@5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.43.0.tgz#00fdeea07811dbdf68774a6f6eacfee17fcc669f" + integrity sha512-8nVpA6yX0sCjf7v/NDfeaOlyaIIqL7OaIGOWSPFqUKK59Gnumd3Wa+2l8oAaYO2lk0sO+SbWFWRSvhu8gLGv4A== dependencies: "@types/json-schema" "^7.0.9" "@types/semver" "^7.3.12" - "@typescript-eslint/scope-manager" "5.41.0" - "@typescript-eslint/types" "5.41.0" - "@typescript-eslint/typescript-estree" "5.41.0" + "@typescript-eslint/scope-manager" "5.43.0" + "@typescript-eslint/types" "5.43.0" + "@typescript-eslint/typescript-estree" "5.43.0" eslint-scope "^5.1.1" eslint-utils "^3.0.0" semver "^7.3.7" -"@typescript-eslint/visitor-keys@5.41.0": - version "5.41.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.41.0.tgz#d3510712bc07d5540160ed3c0f8f213b73e3bcd9" - integrity sha512-vilqeHj267v8uzzakbm13HkPMl7cbYpKVjgFWZPIOHIJHZtinvypUhJ5xBXfWYg4eFKqztbMMpOgFpT9Gfx4fw== +"@typescript-eslint/visitor-keys@5.43.0": + version "5.43.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.43.0.tgz#cbbdadfdfea385310a20a962afda728ea106befa" + integrity sha512-icl1jNH/d18OVHLfcwdL3bWUKsBeIiKYTGxMJCoGe7xFht+E4QgzOqoWYrU8XSLJWhVw8nTacbm03v23J/hFTg== dependencies: - "@typescript-eslint/types" "5.41.0" + "@typescript-eslint/types" "5.43.0" + eslint-visitor-keys "^3.3.0" + +"@typescript-eslint/visitor-keys@5.45.0": + version "5.45.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.45.0.tgz#e0d160e9e7fdb7f8da697a5b78e7a14a22a70528" + integrity sha512-jc6Eccbn2RtQPr1s7th6jJWQHBHI6GBVQkCHoJFQ5UreaKm59Vxw+ynQUPPY2u2Amquc+7tmEoC2G52ApsGNNg== + dependencies: + "@typescript-eslint/types" "5.45.0" eslint-visitor-keys "^3.3.0" abab@^2.0.3, abab@^2.0.5: @@ -1237,11 +1272,6 @@ before-after-hook@^2.2.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e" integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ== -big.js@^5.2.2: - version "5.2.2" - resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" - integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== - bl@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/bl/-/bl-5.0.0.tgz#6928804a41e9da9034868e1c50ca88f21f57aea2" @@ -1388,7 +1418,7 @@ chalk@5.0.1, chalk@^5.0.0, chalk@^5.0.1: resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6" integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w== -chalk@^2.0.0, chalk@^2.3.0: +chalk@^2.0.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -1397,7 +1427,7 @@ chalk@^2.0.0, chalk@^2.3.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0: +chalk@^4.0.0, chalk@^4.1.0: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -1813,31 +1843,18 @@ emoji-regex@^9.2.2: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== -emojis-list@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" - integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== - enabled@2.0.x: version "2.0.0" resolved "https://registry.yarnpkg.com/enabled/-/enabled-2.0.0.tgz#f9dd92ec2d6f4bbc0d5d1e64e21d61cd4665e7c2" integrity sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ== -enhanced-resolve@^4.0.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.5.0.tgz#2f3cfd84dbe3b487f18f2db2ef1e064a571ca5ec" - integrity sha512-Nv9m36S/vxpsI+Hc4/ZGRs0n9mXqSWGGq49zxb/cJfPAQMbUtttJAlNPS4AQzaBdw/pKskw5bMbekT/Y7W/Wlg== +enhanced-resolve@^5.0.0: + version "5.12.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" + integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== dependencies: - graceful-fs "^4.1.2" - memory-fs "^0.5.0" - tapable "^1.0.0" - -errno@^0.1.3: - version "0.1.8" - resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f" - integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A== - dependencies: - prr "~1.0.1" + graceful-fs "^4.2.4" + tapable "^2.2.0" error-ex@^1.3.1: version "1.3.2" @@ -1990,10 +2007,10 @@ eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@8.26.0: - version "8.26.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.26.0.tgz#2bcc8836e6c424c4ac26a5674a70d44d84f2181d" - integrity sha512-kzJkpaw1Bfwheq4VXUezFriD1GxszX6dUekM7Z3aC2o4hju+tsR/XyTC3RcoSD7jmy9VkPU3+N6YjVU2e96Oyg== +eslint@8.28.0: + version "8.28.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.28.0.tgz#81a680732634677cc890134bcdd9fdfea8e63d6e" + integrity sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ== dependencies: "@eslint/eslintrc" "^1.3.3" "@humanwhocodes/config-array" "^0.11.6" @@ -2508,7 +2525,7 @@ got@12.5.1, got@^12.1.0: p-cancelable "^3.0.0" responselike "^3.0.0" -graceful-fs@4.2.10, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.6, graceful-fs@^4.2.9: +graceful-fs@4.2.10, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: version "4.2.10" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== @@ -2700,7 +2717,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@2.0.4, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3: +inherits@2, inherits@2.0.4, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -2991,11 +3008,6 @@ isarray@^2.0.5: resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== -isarray@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== - isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" @@ -3574,13 +3586,6 @@ json5@2.x, json5@^2.2.1: resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== -json5@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" - integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== - dependencies: - minimist "^1.2.0" - jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" @@ -3658,15 +3663,6 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== -loader-utils@^1.0.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613" - integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA== - dependencies: - big.js "^5.2.2" - emojis-list "^3.0.0" - json5 "^1.0.1" - locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -3768,14 +3764,6 @@ makeerror@1.0.12: dependencies: tmpl "1.0.5" -memory-fs@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.5.0.tgz#324c01288b88652966d161db77838720845a8e3c" - integrity sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA== - dependencies: - errno "^0.1.3" - readable-stream "^2.0.1" - merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" @@ -3853,6 +3841,11 @@ mute-stream@0.0.8: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== +natural-compare-lite@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" + integrity sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -3870,7 +3863,7 @@ new-github-release-url@2.0.0: dependencies: type-fest "^2.5.1" -nock@*, nock@13.2.9: +nock@*: version "13.2.9" resolved "https://registry.yarnpkg.com/nock/-/nock-13.2.9.tgz#4faf6c28175d36044da4cfa68e33e5a15086ad4c" integrity sha512-1+XfJNYF1cjGB+TKMWi29eZ0b82QOvQs2YoLNzbpWGqFMtRQHTa57osqdGj4FrFPgkO4D4AZinzUJR9VvW3QUA== @@ -3880,6 +3873,16 @@ nock@*, nock@13.2.9: lodash "^4.17.21" propagate "^2.0.0" +nock@13.3.0: + version "13.3.0" + resolved "https://registry.yarnpkg.com/nock/-/nock-13.3.0.tgz#b13069c1a03f1ad63120f994b04bfd2556925768" + integrity sha512-HHqYQ6mBeiMc+N038w8LkMpDCRquCHWeNmN3v6645P3NhN2+qXOBqvPqo7Rt1VyCMzKhJ733wZqw5B7cQVFNPg== + dependencies: + debug "^4.1.0" + json-stringify-safe "^5.0.1" + lodash "^4.17.21" + propagate "^2.0.0" + node-domexception@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" @@ -4238,11 +4241,6 @@ pretty-format@^27.0.0, pretty-format@^27.5.1: ansi-styles "^5.0.0" react-is "^17.0.1" -process-nextick-args@~2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" - integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== - promise.allsettled@1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/promise.allsettled/-/promise.allsettled-1.0.5.tgz#2443f3d4b2aa8dfa560f6ac2aa6c4ea999d75f53" @@ -4297,11 +4295,6 @@ proxy-from-env@^1.0.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== -prr@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" - integrity sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw== - psl@^1.1.28, psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" @@ -4369,19 +4362,6 @@ readable-stream@1.1.x: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@^2.0.1: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== - dependencies: - core-util-is "~1.0.0" - inherits "~2.0.3" - isarray "~1.0.0" - process-nextick-args "~2.0.0" - safe-buffer "~5.1.1" - string_decoder "~1.1.1" - util-deprecate "~1.0.1" - readable-stream@^3.4.0, readable-stream@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" @@ -4582,7 +4562,7 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.2, safe-buffer@~5.2.0: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== -safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== @@ -4623,6 +4603,13 @@ semver@^6.0.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +semver@^7.3.4: + version "7.3.8" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" + integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== + dependencies: + lru-cache "^6.0.0" + setprototypeof@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" @@ -4818,13 +4805,6 @@ string_decoder@~0.10.x: resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" integrity sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ== -string_decoder@~1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" - integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== - dependencies: - safe-buffer "~5.1.0" - strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" @@ -4903,10 +4883,10 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -tapable@^1.0.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" - integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== +tapable@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" + integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== terminal-link@^2.0.0: version "2.1.1" @@ -5031,16 +5011,15 @@ ts-jest@^27.0.4: semver "7.x" yargs-parser "20.x" -ts-loader@8.0.10: - version "8.0.10" - resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-8.0.10.tgz#4af4afb8d26847290cd010df93a4c172df92278f" - integrity sha512-5fVbbZldz6LQi6RQ0v1P7lZ98CZGlQyM8b4xGZXw3G/XUqL8GIH+Ib6H01nImPhkHZ9+PVXZgTb+v3fRsaIHlg== +ts-loader@9.4.2: + version "9.4.2" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.4.2.tgz#80a45eee92dd5170b900b3d00abcfa14949aeb78" + integrity sha512-OmlC4WVmFv5I0PpaxYb+qGeGOdm5giHU7HwDDUjw59emP2UYMHy9fFSDcYgSNoH8sXcj4hGCSEhlDZ9ULeDraA== dependencies: - chalk "^2.3.0" - enhanced-resolve "^4.0.0" - loader-utils "^1.0.2" + chalk "^4.1.0" + enhanced-resolve "^5.0.0" micromatch "^4.0.0" - semver "^6.0.0" + semver "^7.3.4" tslib@^1.8.1: version "1.14.1" @@ -5124,10 +5103,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@4.8.4: - version "4.8.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" - integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ== +typescript@4.9.4: + version "4.9.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78" + integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg== unbox-primitive@^1.0.2: version "1.0.2" @@ -5201,7 +5180,7 @@ url-join@5.0.0: resolved "https://registry.yarnpkg.com/url-join/-/url-join-5.0.0.tgz#c2f1e5cbd95fa91082a93b58a1f42fecb4bdbcf1" integrity sha512-n2huDr9h9yzd6exQVnH/jU5mr+Pfx08LRXXZhkLLetAMESRj+anQsTAh940iMrIetKAmry9coFuZQ2jY8/p3WA== -util-deprecate@^1.0.1, util-deprecate@~1.0.1: +util-deprecate@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==