diff --git a/src/__mocks__/terminalApi/sync.ts b/src/__mocks__/terminalApi/sync.ts index ba8e39f..d1999dd 100644 --- a/src/__mocks__/terminalApi/sync.ts +++ b/src/__mocks__/terminalApi/sync.ts @@ -365,3 +365,24 @@ export const syncRefund = { } } }; + +export const syncResEventNotification = { + SaleToPOIRequest: { + EventNotification: { + EventToNotify: "Reject", + EventDetails: "message=Did+not+receive+a+response+from+the+POI.", + RejectedMessage: "ewoi...0KfQo=", + TimeStamp: "2020-03-31T10:28:39.515Z" + }, + MessageHeader: { + DeviceID: "666568147", + MessageCategory: "Event", + MessageClass: "Event", + MessageType: "Notification", + POIID: "P400Plus-123456789", + ProtocolVersion: "3.0", + SaleID: "saleid-4c32759faaa7", + ServiceID: "31122609" + } + } +}; diff --git a/src/__tests__/terminalCloudAPI.spec.ts b/src/__tests__/terminalCloudAPI.spec.ts index 00be121..ce2d68e 100644 --- a/src/__tests__/terminalCloudAPI.spec.ts +++ b/src/__tests__/terminalCloudAPI.spec.ts @@ -12,7 +12,7 @@ * ############# * ############ * Adyen NodeJS API Library - * Copyright (c) 2021 Adyen B.V. + * Copyright (c) 2022 Adyen N.V. * This file is open source and available under the MIT license. * See the LICENSE file for more info. */ @@ -20,7 +20,7 @@ import nock from "nock"; import { createClient, createTerminalAPIPaymentRequest, createTerminalAPIRefundRequest } from "../__mocks__/base"; import { asyncRes } from "../__mocks__/terminalApi/async"; -import { syncRefund, syncRes } from "../__mocks__/terminalApi/sync"; +import { syncRefund, syncRes, syncResEventNotification } from "../__mocks__/terminalApi/sync"; import Client from "../client"; import TerminalCloudAPI from "../services/terminalCloudAPI"; import { TerminalApiResponse } from "../typings/terminal/models"; @@ -68,6 +68,17 @@ describe("Terminal Cloud API", (): void => { expect(terminalAPIResponse.SaleToPOIResponse?.MessageHeader).toBeDefined(); }); + test.each([isCI, true])("should return event notification if response contains it, isMock: %p", async (isMock): Promise => { + !isMock && nock.restore(); + + const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest(); + scope.post("/sync").reply(200, syncResEventNotification); + + const terminalAPIResponse = await terminalCloudAPI.sync(terminalAPIPaymentRequest); + + expect(terminalAPIResponse.SaleToPOIRequest?.EventNotification).toBeDefined(); + }); + test.each([isCI, true])("should make an async refund request, isMock: %p", async (isMock): Promise => { !isMock && nock.restore(); scope.post("/sync").reply(200, syncRes); diff --git a/src/typings/terminal/terminalApiResponse.ts b/src/typings/terminal/terminalApiResponse.ts index 304b29f..5ff71d6 100644 --- a/src/typings/terminal/terminalApiResponse.ts +++ b/src/typings/terminal/terminalApiResponse.ts @@ -12,28 +12,24 @@ * ############# * ############ * Adyen NodeJS API Library - * Copyright (c) 2021 Adyen B.V. + * Copyright (c) 2022 Adyen N.V. * 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 - * Do not edit the class manually. */ import { SaleToPOIResponse } from './saleToPOIResponse'; +import {SaleToPOIRequest} from "./saleToPOIRequest"; export class TerminalApiResponse { 'SaleToPOIResponse'?: SaleToPOIResponse; + 'SaleToPOIRequest'?: SaleToPOIRequest; static discriminator: string | undefined = undefined; @@ -42,7 +38,12 @@ export class TerminalApiResponse { "name": "SaleToPOIResponse", "baseName": "SaleToPOIResponse", "type": "SaleToPOIResponse" - } ]; + }, + { + "name": "SaleToPOIRequest", + "baseName": "SaleToPOIRequest", + "type": "SaleToPOIRequest" + }]; static getAttributeTypeMap() { return TerminalApiResponse.attributeTypeMap;