Skip to content

Commit

Permalink
BATM-5682 - Extensions examples should be in separate module (#873)
Browse files Browse the repository at this point in the history
Co-authored-by: kkyovsky <[email protected]>
  • Loading branch information
b00lean and kkyovsky authored Jan 10, 2024
1 parent 91c2f44 commit aaf8c8c
Show file tree
Hide file tree
Showing 45 changed files with 97 additions and 67 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CAS then parses any "batm-extensions.xml" found in the JAR file to enumerate the

<a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtension.java">Extension</a> is a high level component - something like a plugin - that encapsulates and instantiates the rest of the features.

Extension can be asked to provide wallet X for currency Y etc. The best way to learn more about extensions is to read the sample code and examine how other people have implemented support for their wallet or cryptocurrency in the <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_extra">server_extensions_extra</a> module. <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples">Additional examples can be found here</a>.
Extension can be asked to provide wallet X for currency Y etc. The best way to learn more about extensions is to read the sample code and examine how other people have implemented support for their wallet or cryptocurrency in the <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_extra">server_extensions_extra</a> module. <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples">Additional examples can be found here</a>.

Here is the list of some functionality that can be extended using Extensions API:
* **Implement support for different cryptocurrency wallets** - for more information, see the <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IWallet.java">IWallet</a> interface.
Expand All @@ -43,14 +43,16 @@ Here is the list of some functionality that can be extended using Extensions API
* **Send emails or SMSes from extension** - To notify your customer via SMS or email with custom messages, call the methods exposed by the <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtensionContext.java">IExtensionContext</a> interface.
* **<a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtensionContext.java">ExtensionContext</a>** is your main entrypoint for interacting with CAS.
ExtensionContext may be called from any extension. A reference to ExtensionContext is passed to an Extension when the **init** method is called by CAS on any Extension. Please make sure you read all of the methods that are available on the IExtensionContext interface. There are, for example: cash related operations, sell functionality, and more!
* **Implement RESTful services** - facilitates integration of the Server with a 3rd party system. Extensions enable you to quickly and easily create a RESTful service that sends/receives data via JSON and HTTPS. Do you want your website to contact CAS to find the current exchange rate on your BATM (or even more complicated functions)? Use <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IRestService.java">IRestService</a> for that. A simple example that returns your current CAS version can be found <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest">here</a>.
* **Implement ChatBot commands** - Do you need to execute some tasks on server by sending message to server via Telegram Messenger? Simply implement Telegram your command and you are ready to go. A simple example that returns your current CAS version can be found <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat">here</a>.
* **Implement RESTful services** - facilitates integration of the Server with a 3rd party system. Extensions enable you to quickly and easily create a RESTful service that sends/receives data via JSON and HTTPS. Do you want your website to contact CAS to find the current exchange rate on your BATM (or even more complicated functions)? Use <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IRestService.java">IRestService</a> for that. A simple example that returns your current CAS version can be found <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest">here</a>.
* **Implement ChatBot commands** - Do you need to execute some tasks on server by sending message to server via Telegram Messenger? Simply implement Telegram your command and you are ready to go. A simple example that returns your current CAS version can be found <a href="https://github.com/GENERALBYTESCOM/batm_public/blob/master/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat">here</a>.


Content
=======
* **server_extensions_api** - contains the extension API that all extensions use to extend CAS' functionality.
* **server_extensions_extra** - reference extension implementation that demonstrates BTC, LTC, CLOAK, DGB, DASH, HATCH, POT, VIA, BTX, SYS, FLASH, DOGE, NLG, ICG, NBT, GRS, MAX, BSD, MEC, BTDX, NANO, SUM, BURST, ECA, LINDA, $PAC, DAI, MKR, BTBS, GQ, VERUM, MUE, BAT and REP coin support functionality.
* **server_extensions_examples** - contains example implementations of various extensions.
* **server_extensions_template** - contains template for developer's own extension.
* **server_extensions_test** - contains tester for testing the extensions (CAS not required).
* **operators_sample_website** - The OSW is a sample web application that demonstrates how operators can enable their customers initiate sell transactions online via operator's website and later visit two-way BATMThree or BATMFour ATM when cash is ready for withdrawal. For more detailed information see <a href="https://github.com/GENERALBYTESCOM/batm_public/tree/master/operators_sample_website">description</a>.
<p align="center">`
Expand Down
34 changes: 34 additions & 0 deletions server_extensions_examples/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
id("shared-build-conventions")
id("shared-repositories-ext-conventions")
}

group = projectGroup
version = projectVersion

jar {
archiveFileName = "batm_server_extensions_examples.${archiveExtension.get()}"
}

configurations {
artifactOnly
}

artifacts {
artifactOnly jar
}

dependencies {
implementation("org.slf4j:slf4j-api:1.7.28") //for logging
implementation("javax.ws.rs:javax.ws.rs-api:2.1") //for REST services
implementation("javax.servlet:javax.servlet-api:3.1.0") //for REST services
implementation("com.github.mmazi:rescu:2.1.0") //for REST client
implementation("com.vdurmont:emoji-java:3.1.3") //for chat emojis
implementation("com.fasterxml.jackson.core:jackson-annotations:2.12.0") //JSON serialization
implementation("com.fasterxml.jackson.core:jackson-databind:2.12.0") //JSON serialization
implementation("com.fasterxml.jackson.core:jackson-core:2.12.0") //JSON serialization
implementation("com.nexmo:client:5.5.0") // sms provider

implementation project(":server_extensions_api")
implementation project(":currencies")
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples;
package com.generalbytes.batm.server.extensions.examples;

import com.generalbytes.batm.common.currencies.CryptoCurrency;
import com.generalbytes.batm.server.extensions.AbstractExtension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples;
package com.generalbytes.batm.server.extensions.examples;

import com.generalbytes.batm.server.extensions.*;
import com.generalbytes.batm.server.extensions.exceptions.UpdateException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.activeTerminals;
package com.generalbytes.batm.server.extensions.examples.activeterminals;

import com.generalbytes.batm.server.extensions.AbstractExtension;
import com.generalbytes.batm.server.extensions.IExtensionContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.activeTerminals;
package com.generalbytes.batm.server.extensions.examples.activeterminals;

import com.generalbytes.batm.server.extensions.ApiAccessType;
import com.generalbytes.batm.server.extensions.IApiAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.chat;
package com.generalbytes.batm.server.extensions.examples.chat;

import com.generalbytes.batm.server.extensions.AbstractExtension;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
************************************************************************************/

package com.generalbytes.batm.server.extensions.extra.examples.chat;
package com.generalbytes.batm.server.extensions.examples.chat;

import com.generalbytes.batm.server.extensions.IExtensionContext;
import com.generalbytes.batm.server.extensions.IPerson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.chat;
package com.generalbytes.batm.server.extensions.examples.chat;

import com.generalbytes.batm.server.extensions.IBanknoteCounts;
import com.generalbytes.batm.server.extensions.ICryptoConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.chat;
package com.generalbytes.batm.server.extensions.examples.chat;

import com.generalbytes.batm.common.currencies.CryptoCurrency;
import com.generalbytes.batm.server.extensions.IExtensionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.chat;
package com.generalbytes.batm.server.extensions.examples.chat;

import com.generalbytes.batm.server.extensions.IExtensionContext;
import com.generalbytes.batm.server.extensions.chat.AbstractChatCommnad;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.communication;
package com.generalbytes.batm.server.extensions.examples.communication;

import com.generalbytes.batm.server.extensions.AbstractExtension;
import com.generalbytes.batm.server.extensions.communication.ICommunicationProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.communication;
package com.generalbytes.batm.server.extensions.examples.communication;

import com.generalbytes.batm.server.extensions.communication.ICommunicationProvider;
import com.generalbytes.batm.server.extensions.communication.ISmsResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.communication;
package com.generalbytes.batm.server.extensions.examples.communication;

import com.generalbytes.batm.server.extensions.communication.ISmsErrorResponse;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.communication;
package com.generalbytes.batm.server.extensions.examples.communication;

import com.generalbytes.batm.server.extensions.communication.ISmsErrorResponse;
import com.generalbytes.batm.server.extensions.communication.ISmsResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.identity;
package com.generalbytes.batm.server.extensions.examples.identity;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.identity;
package com.generalbytes.batm.server.extensions.examples.identity;

import com.generalbytes.batm.server.extensions.AbstractExtension;
import com.generalbytes.batm.server.extensions.aml.IExternalIdentity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.identity;
package com.generalbytes.batm.server.extensions.examples.identity;

import com.generalbytes.batm.server.extensions.AbstractExtension;
import com.generalbytes.batm.server.extensions.IExtensionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.identity;
package com.generalbytes.batm.server.extensions.examples.identity;

import com.generalbytes.batm.server.extensions.IRestService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.identity;
package com.generalbytes.batm.server.extensions.examples.identity;

import com.generalbytes.batm.server.extensions.IExtensionContext;
import com.generalbytes.batm.server.extensions.IIdentity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.identity;
package com.generalbytes.batm.server.extensions.examples.identity;

import com.generalbytes.batm.server.extensions.IIdentityPiece;
import com.generalbytes.batm.server.extensions.IPerson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.identity;
package com.generalbytes.batm.server.extensions.examples.identity;

import com.generalbytes.batm.server.extensions.ILimit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.location;
package com.generalbytes.batm.server.extensions.examples.location;

import com.generalbytes.batm.server.extensions.ICashCollectionDay;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.location;
package com.generalbytes.batm.server.extensions.examples.location;

import com.generalbytes.batm.server.extensions.ICashCollectionDay;
import com.generalbytes.batm.server.extensions.ILocationDetail;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.location;
package com.generalbytes.batm.server.extensions.examples.location;

import com.generalbytes.batm.server.extensions.AbstractExtension;
import com.generalbytes.batm.server.extensions.IExtensionContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.location;
package com.generalbytes.batm.server.extensions.examples.location;

import com.generalbytes.batm.server.extensions.IRestService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.location;
package com.generalbytes.batm.server.extensions.examples.location;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.location;
package com.generalbytes.batm.server.extensions.examples.location;

import com.generalbytes.batm.server.extensions.INote;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.location;
package com.generalbytes.batm.server.extensions.examples.location;

import com.generalbytes.batm.server.extensions.IOpeningHours;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.location;
package com.generalbytes.batm.server.extensions.examples.location;

import com.generalbytes.batm.server.extensions.IOrganization;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.location;
package com.generalbytes.batm.server.extensions.examples.location;

import com.generalbytes.batm.server.extensions.IPerson;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.generalbytes.batm.server.extensions.extra.examples.notification;
package com.generalbytes.batm.server.extensions.examples.notification;

import com.generalbytes.batm.server.extensions.IExtensionContext;
import com.generalbytes.batm.server.extensions.IIdentity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.notification;
package com.generalbytes.batm.server.extensions.examples.notification;

import com.generalbytes.batm.server.extensions.AbstractExtension;
import com.generalbytes.batm.server.extensions.IExtensionContext;

/*
Enable this extension by adding the following line to /batm/config/extensions
com.generalbytes.batm.server.extensions.extra.examples.notification.NotificationExampleExtension.autoload=true
com.generalbytes.batm.server.extensions.examples.notification.NotificationExampleExtension.autoload=true
*/
public class NotificationExampleExtension extends AbstractExtension {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.rest;
package com.generalbytes.batm.server.extensions.examples.rest;

/**
* Simple data transfer class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.rest;
package com.generalbytes.batm.server.extensions.examples.rest;

import com.generalbytes.batm.server.extensions.AbstractExtension;
import com.generalbytes.batm.server.extensions.IExtensionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.rest;
package com.generalbytes.batm.server.extensions.examples.rest;

import com.generalbytes.batm.server.extensions.IExtensionContext;
import com.generalbytes.batm.server.extensions.ITransactionCashbackInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.rest;
package com.generalbytes.batm.server.extensions.examples.rest;



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Web : http://www.generalbytes.com
*
************************************************************************************/
package com.generalbytes.batm.server.extensions.extra.examples.rest;
package com.generalbytes.batm.server.extensions.examples.rest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Loading

0 comments on commit aaf8c8c

Please sign in to comment.