From 1615ef1085eab5991ef232166057c004aa2370c7 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Fortune Date: Mon, 21 Oct 2024 16:26:35 +0200 Subject: [PATCH] feat: add new remote services to enable keyple-less clients (#5) Introduced new service IDs for C# and Kotlin Multiplatform clients. Added several DTOs for analyzing, loading, and personalizing contracts. --------- Co-authored-by: Andrei Cristea --- .github/workflows/java-publish.yml | 13 ++++---- CHANGELOG.md | 9 +++++- .../demo/common/constant/RemoteServiceId.kt | 11 ++++++- .../SelectAppAndAnalyzeContractsInputDto.kt | 14 ++++++++ .../SelectAppAndAnalyzeContractsOutputDto.kt | 32 +++++++++++++++++++ .../dto/SelectAppAndLoadContractInputDto.kt | 21 ++++++++++++ .../dto/SelectAppAndLoadContractOutputDto.kt | 19 +++++++++++ .../SelectAppAndPersonalizeCardInputDto.kt | 14 ++++++++ .../SelectAppAndPersonalizeCardOutputDto.kt | 18 +++++++++++ ....kt => ContractInfoStructureParserTest.kt} | 2 +- 10 files changed, 144 insertions(+), 9 deletions(-) create mode 100644 src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndAnalyzeContractsInputDto.kt create mode 100644 src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndAnalyzeContractsOutputDto.kt create mode 100644 src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndLoadContractInputDto.kt create mode 100644 src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndLoadContractOutputDto.kt create mode 100644 src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndPersonalizeCardInputDto.kt create mode 100644 src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndPersonalizeCardOutputDto.kt rename src/test/kotlin/org/calypsonet/keyple/demo/common/parser/{ContractStructureParserTest.kt => ContractInfoStructureParserTest.kt} (98%) diff --git a/.github/workflows/java-publish.yml b/.github/workflows/java-publish.yml index 1f7de1e..6dfdca3 100644 --- a/.github/workflows/java-publish.yml +++ b/.github/workflows/java-publish.yml @@ -10,12 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository code from ${{ github.repository }}/${{ github.ref }} - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up JDK 11 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '11' - distribution: 'adopt' + distribution: 'temurin' + - name: Write gradle.properties run: | mkdir -p ~/.gradle @@ -25,12 +26,12 @@ jobs: cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import gpg --pinentry-mode loopback --passphrase "${{ secrets.OSSRH_GPG_SECRET_PASSWORD }}" --export-secret-key 568FD16F857171A0EC6D2C40742C84722FD2B235 > ~/.gradle/maven-central.gpg gpg --list-secret-keys --keyid-format LONG + - name: Update permissions - working-directory: . run: chmod +x ./gradlew ./.github/scripts/*.sh + - name: Check version - working-directory: . run: ./.github/scripts/check_version.sh + - name: Build and Publish - working-directory: . run: ./gradlew build test publish --info --stacktrace diff --git a/CHANGELOG.md b/CHANGELOG.md index 01a49db..9b9f1aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ## [2.0.2] - 2024-10-15 +### Added +- New service IDs in `RemoteServiceId` for C# Keyple-less clients and Kotlin Multiplatform Keyple-less clients. +- Introduced `SelectAppAndAnalyzeContractsInputDto` and `SelectAppAndAnalyzeContractsOutputDto` for analyzing contracts. +- Introduced `SelectAppAndLoadContractInputDto` and `SelectAppAndLoadContractOutputDto` for loading contracts. +- Introduced `SelectAppAndPersonalizeCardInputDto` and `SelectAppAndPersonalizeCardOutputDto` for personalizing cards. ### Changed -- Rename repository and artifact from `keyple-demo-common-lib` to `keyple-demo-ticketing-common-lib` +- Renamed repository and artifact from `keyple-demo-common-lib` to `keyple-demo-ticketing-common-lib` +- Renamed the test class `ContractStructureParserTest` to `ContractInfoStructureParserTest` to reflect the updated class + name. ## [2.0.1] - 2024-04-23 ### Upgraded diff --git a/src/main/kotlin/org/calypsonet/keyple/demo/common/constant/RemoteServiceId.kt b/src/main/kotlin/org/calypsonet/keyple/demo/common/constant/RemoteServiceId.kt index 49e6660..49af0e1 100644 --- a/src/main/kotlin/org/calypsonet/keyple/demo/common/constant/RemoteServiceId.kt +++ b/src/main/kotlin/org/calypsonet/keyple/demo/common/constant/RemoteServiceId.kt @@ -12,9 +12,18 @@ package org.calypsonet.keyple.demo.common.constant enum class RemoteServiceId { + + // Suitable for C# Keyple-less clients SELECT_APP_AND_READ_CONTRACTS, SELECT_APP_AND_INCREASE_CONTRACT_COUNTER, + + // Suitable for Android Keyple clients READ_CARD_AND_ANALYZE_CONTRACTS, READ_CARD_AND_WRITE_CONTRACT, - PERSONALIZE_CARD + PERSONALIZE_CARD, + + // Suitable for Kotlin Multiplaform Keyple-less client + SELECT_APP_AND_ANALYZE_CONTRACTS, + SELECT_APP_AND_LOAD_CONTRACT, + SELECT_APP_AND_PERSONALIZE_CARD } diff --git a/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndAnalyzeContractsInputDto.kt b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndAnalyzeContractsInputDto.kt new file mode 100644 index 0000000..77f032f --- /dev/null +++ b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndAnalyzeContractsInputDto.kt @@ -0,0 +1,14 @@ +/* ************************************************************************************** + * Copyright (c) 2024 Calypso Networks Association https://calypsonet.org/ + * + * See the NOTICE file(s) distributed with this work for additional information + * regarding copyright ownership. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + ************************************************************************************** */ +package org.calypsonet.keyple.demo.common.dto + +data class SelectAppAndAnalyzeContractsInputDto(var pluginType: String) diff --git a/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndAnalyzeContractsOutputDto.kt b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndAnalyzeContractsOutputDto.kt new file mode 100644 index 0000000..b6b8bec --- /dev/null +++ b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndAnalyzeContractsOutputDto.kt @@ -0,0 +1,32 @@ +/* ************************************************************************************** + * Copyright (c) 2024 Calypso Networks Association https://calypsonet.org/ + * + * See the NOTICE file(s) distributed with this work for additional information + * regarding copyright ownership. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + ************************************************************************************** */ +package org.calypsonet.keyple.demo.common.dto + +/** + * - validContracts: List of contracts present in the card. Each contract is tied to a counter by + * its index. + * - statusCode: 0 (if successful), 1 (server is not ready), 2 (card rejected). + * - message: Status message. + */ +data class SelectAppAndAnalyzeContractsOutputDto( + var applicationSerialNumber: String, + var validContracts: List, + var statusCode: Int, + var message: String +) { + /** + * - title: Contract name. + * - description: Contract details. + * - isValid: Indicates if the contract is currently usable. + */ + data class ContractInfo(var title: String, var description: String, var isValid: Boolean) +} diff --git a/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndLoadContractInputDto.kt b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndLoadContractInputDto.kt new file mode 100644 index 0000000..6e5a37f --- /dev/null +++ b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndLoadContractInputDto.kt @@ -0,0 +1,21 @@ +/* ************************************************************************************** + * Copyright (c) 2024 Calypso Networks Association https://calypsonet.org/ + * + * See the NOTICE file(s) distributed with this work for additional information + * regarding copyright ownership. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + ************************************************************************************** */ +package org.calypsonet.keyple.demo.common.dto + +import org.calypsonet.keyple.demo.common.model.type.PriorityCode + +data class SelectAppAndLoadContractInputDto( + var applicationSerialNumber: String, + var contractTariff: PriorityCode, + var ticketToLoad: Int, + var pluginType: String +) diff --git a/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndLoadContractOutputDto.kt b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndLoadContractOutputDto.kt new file mode 100644 index 0000000..0d54615 --- /dev/null +++ b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndLoadContractOutputDto.kt @@ -0,0 +1,19 @@ +/* ************************************************************************************** + * Copyright (c) 2024 Calypso Networks Association https://calypsonet.org/ + * + * See the NOTICE file(s) distributed with this work for additional information + * regarding copyright ownership. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + ************************************************************************************** */ +package org.calypsonet.keyple.demo.common.dto + +/** + * - statusCode: 0 (successful), 1 (server is not ready), 2 (card rejected), 3 (please present the + * same card). + * - message: error message + */ +data class SelectAppAndLoadContractOutputDto(var statusCode: Int, var message: String) diff --git a/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndPersonalizeCardInputDto.kt b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndPersonalizeCardInputDto.kt new file mode 100644 index 0000000..cb1c435 --- /dev/null +++ b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndPersonalizeCardInputDto.kt @@ -0,0 +1,14 @@ +/* ************************************************************************************** + * Copyright (c) 2024 Calypso Networks Association https://calypsonet.org/ + * + * See the NOTICE file(s) distributed with this work for additional information + * regarding copyright ownership. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + ************************************************************************************** */ +package org.calypsonet.keyple.demo.common.dto + +class SelectAppAndPersonalizeCardInputDto(var pluginType: String) diff --git a/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndPersonalizeCardOutputDto.kt b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndPersonalizeCardOutputDto.kt new file mode 100644 index 0000000..7b0b3c2 --- /dev/null +++ b/src/main/kotlin/org/calypsonet/keyple/demo/common/dto/SelectAppAndPersonalizeCardOutputDto.kt @@ -0,0 +1,18 @@ +/* ************************************************************************************** + * Copyright (c) 2024 Calypso Networks Association https://calypsonet.org/ + * + * See the NOTICE file(s) distributed with this work for additional information + * regarding copyright ownership. + * + * This program and the accompanying materials are made available under the terms of the + * Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + ************************************************************************************** */ +package org.calypsonet.keyple.demo.common.dto + +/** + * - statusCode: 0 (if successful), 1 (if error). + * - message: error message + */ +data class SelectAppAndPersonalizeCardOutputDto(var statusCode: Int, var message: String) diff --git a/src/test/kotlin/org/calypsonet/keyple/demo/common/parser/ContractStructureParserTest.kt b/src/test/kotlin/org/calypsonet/keyple/demo/common/parser/ContractInfoStructureParserTest.kt similarity index 98% rename from src/test/kotlin/org/calypsonet/keyple/demo/common/parser/ContractStructureParserTest.kt rename to src/test/kotlin/org/calypsonet/keyple/demo/common/parser/ContractInfoStructureParserTest.kt index 6e7300a..ad5468c 100644 --- a/src/test/kotlin/org/calypsonet/keyple/demo/common/parser/ContractStructureParserTest.kt +++ b/src/test/kotlin/org/calypsonet/keyple/demo/common/parser/ContractInfoStructureParserTest.kt @@ -20,7 +20,7 @@ import org.calypsonet.keyple.demo.common.model.type.PriorityCode import org.calypsonet.keyple.demo.common.model.type.VersionNumber import org.junit.jupiter.api.Test -class ContractStructureParserTest { +class ContractInfoStructureParserTest { private val contractStructureParser = ContractStructureParser()