From f4536422223cb12446304a2c9805d1461055f9fb Mon Sep 17 00:00:00 2001 From: kkyovsky Date: Mon, 20 Nov 2023 23:53:34 +0100 Subject: [PATCH 1/2] BATM-5644 - Create template module for customers to develop their extensions --- .../extensions/ITransactionListener.java | 2 +- server_extensions_template/build.gradle | 33 +++++++++++++++++++ .../myfirstextension/MyFirstExtension.java | 18 ++++++++++ .../MyTransactionListener.java | 27 +++++++++++++++ .../src/main/resources/batm-extensions.xml | 4 +++ settings.gradle | 1 + 6 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 server_extensions_template/build.gradle create mode 100644 server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyFirstExtension.java create mode 100644 server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyTransactionListener.java create mode 100644 server_extensions_template/src/main/resources/batm-extensions.xml diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionListener.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionListener.java index 535f7bb35..385a3bc06 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionListener.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionListener.java @@ -49,7 +49,7 @@ default ITransactionPreparation overrideTransactionPreparation(ITransactionPrepa /** * Callback method that is called by server before transaction is executed - however the cash is already inserted in machine in case of buy transaction. - * If your method returns false than transaction will not take place and will fail with error ERROR_NOT_APPROVED. + * If your method returns false than transaction will< not take place and will fail with error ERROR_NOT_APPROVED. * Try to return from this method in less then 10 seconds. */ default boolean isTransactionApproved(ITransactionRequest transactionRequest) { diff --git a/server_extensions_template/build.gradle b/server_extensions_template/build.gradle new file mode 100644 index 000000000..76f878e57 --- /dev/null +++ b/server_extensions_template/build.gradle @@ -0,0 +1,33 @@ +plugins { + id("shared-build-conventions") + id("shared-repositories-ext-conventions") +} + +group = projectGroup +version = projectVersion + +jar { + archiveFileName = "myfirstextension.${archiveExtension.get()}" +} + +configurations { + artifactOnly + + // handle Github (e.g. community) vs GENERAL BYTES dichotomy + generalBytesCompile + githubCompile + if (hasGbArtifactory) { + implementation { extendsFrom generalBytesCompile } + } else { + implementation { extendsFrom githubCompile } + } +} + +artifacts { + artifactOnly jar +} + +dependencies { + implementation project(":server_extensions_api") + implementation project(":currencies") +} \ No newline at end of file diff --git a/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyFirstExtension.java b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyFirstExtension.java new file mode 100644 index 000000000..1baefc5f7 --- /dev/null +++ b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyFirstExtension.java @@ -0,0 +1,18 @@ +package com.mygreatcompany.batm.server.extensions.myfirstextension; + +import com.generalbytes.batm.server.extensions.AbstractExtension; +import com.generalbytes.batm.server.extensions.IExtensionContext; + +public class MyFirstExtension extends AbstractExtension { + + @Override + public String getName() { + return "My first extension"; + } + + @Override + public void init(IExtensionContext ctx) { + super.init(ctx); + ctx.addTransactionListener(new MyTransactionListener(ctx)); + } +} diff --git a/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyTransactionListener.java b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyTransactionListener.java new file mode 100644 index 000000000..a9f053b89 --- /dev/null +++ b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyTransactionListener.java @@ -0,0 +1,27 @@ +package com.mygreatcompany.batm.server.extensions.myfirstextension; + +import com.generalbytes.batm.server.extensions.IExtensionContext; +import com.generalbytes.batm.server.extensions.ITransactionDetails; +import com.generalbytes.batm.server.extensions.ITransactionListener; + +import java.util.Map; + +public class MyTransactionListener implements ITransactionListener { + private IExtensionContext ctx; + + public MyTransactionListener(IExtensionContext ctx) { + this.ctx = ctx; + } + + @Override + public Map onTransactionCreated(ITransactionDetails transactionDetails) { + System.out.println("Bravo! Transaction has been created! Here are the details: = " + transactionDetails); + return null; + } + + @Override + public Map onTransactionUpdated(ITransactionDetails transactionDetails) { + System.out.println("Hey! Transaction has been updated! Here are the details: " + transactionDetails); + return null; + } +} diff --git a/server_extensions_template/src/main/resources/batm-extensions.xml b/server_extensions_template/src/main/resources/batm-extensions.xml new file mode 100644 index 000000000..07c2d7222 --- /dev/null +++ b/server_extensions_template/src/main/resources/batm-extensions.xml @@ -0,0 +1,4 @@ + + + + diff --git a/settings.gradle b/settings.gradle index 3bb28c1ac..f4227ae8b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,7 @@ include ':server_extensions_api' include ':server_extensions_extra' include ':server_extensions_test' +include ':server_extensions_template' include ':currencies' include ':batm_ssh_tunnel' include ':operators_sample_website' From 13dde99600beb8a95c95ec08291678dbdd1d36c8 Mon Sep 17 00:00:00 2001 From: kkyovsky Date: Tue, 21 Nov 2023 00:01:55 +0100 Subject: [PATCH 2/2] BATM-5644 - Create template module for customers to develop their extensions --- .../batm/server/extensions/ITransactionListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionListener.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionListener.java index 385a3bc06..535f7bb35 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionListener.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionListener.java @@ -49,7 +49,7 @@ default ITransactionPreparation overrideTransactionPreparation(ITransactionPrepa /** * Callback method that is called by server before transaction is executed - however the cash is already inserted in machine in case of buy transaction. - * If your method returns false than transaction will< not take place and will fail with error ERROR_NOT_APPROVED. + * If your method returns false than transaction will not take place and will fail with error ERROR_NOT_APPROVED. * Try to return from this method in less then 10 seconds. */ default boolean isTransactionApproved(ITransactionRequest transactionRequest) {