diff --git a/README.md b/README.md index 5471a88f8..00707147d 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ CAS then parses any "batm-extensions.xml" found in the JAR file to enumerate the Extension 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 server_extensions_extra module. Additional examples can be found here. +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 server_extensions_extra module. Additional examples can be found here. 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 IWallet interface. @@ -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 IExtensionContext interface. * **ExtensionContext** 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 IRestService for that. A simple example that returns your current CAS version can be found here. -* **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 here. +* **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 IRestService for that. A simple example that returns your current CAS version can be found here. +* **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 here. 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 description.

` @@ -65,7 +67,7 @@ Requirements: * Java **1.8** (we recommend using https://sdkman.io/ for managing multiple JDK versions on your computer) * Gradle -When you implement support for a new crypto-coin, please add it to **server_extensions_extra** - so that it may get into the default CAS installation pack for customers. +When you implement support for a new crypto-coin, please add it to **server_extensions_extra** - so that it may get into the default CAS distribution ready to be used by other operators. Please use the appropriate Fork and Pull Request in the GitHub workflow when adding new functions, and bear in mind that your code will be reviewed prior to any merge with the master. When adding new cryptocurrency support, please remember to provide its logo! This logo will later be downloaded by the BATM from CAS and displayed on the BATM screen. Both SVG and PNG logos are supported; however, only the SVG logo is used on newer BATM versions. A PNG logo is offered only for backward compatibility, and in the few cases where the SVG logo has an unusually large size. @@ -88,6 +90,16 @@ Note that on startup, CAS scans the: /batm/app/master/extensions/ f If you happen to add new cryptocurrency in CryptoCurrency class in currencies module then don't forget to make sure that you copy your version of currencies-1.0.XX-SNAPSHOT.jar to /batm/app/master/lib +Creating your own extension +================= +When you want to develop your own operator specific extension please create a new module and implement your extension there. +Use server_extensions_template module as a termplate for your first extension. Just copy this module and rename it. +You will need to modify also settings.gradle file to contain your new extension module's name. See how is the server_extensions_template module mentioned and add line for your new extension module. +After building the whole project your built extension shoud be in following file: yournewextension/build/libs/yournewextension.jar +Copy it to CAS server at following location: /batm/app/master/extensions/ +You may also want to modify build.gradle in your new module to change at least package names and final output filename. + + How to run Tester ========== ```bash diff --git a/gradle.properties b/gradle.properties index b733dc035..ffbfa9a9a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # buildscript - project id projectGroup=com.generalbytes.batm.public -projectVersion=1.3.8 +projectVersion=1.4.5 # buildscript - common dependency versions bitrafaelVersion=1.0.44 diff --git a/operators_sample_website/src/main/java/com/generalbytes/batm/server/extensions/website/RestServiceWebsite.java b/operators_sample_website/src/main/java/com/generalbytes/batm/server/extensions/website/RestServiceWebsite.java index d4a80999d..05857e45b 100644 --- a/operators_sample_website/src/main/java/com/generalbytes/batm/server/extensions/website/RestServiceWebsite.java +++ b/operators_sample_website/src/main/java/com/generalbytes/batm/server/extensions/website/RestServiceWebsite.java @@ -7,8 +7,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.ws.rs.*; +import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.math.BigDecimal; @@ -29,10 +31,10 @@ public class RestServiceWebsite { @Path("/terminals-with-available-cash") @Produces(MediaType.APPLICATION_JSON) public Object terminalsWithAvailableCash(@HeaderParam("X-Api-Key") String apiKey, @QueryParam("amount") BigDecimal amount, - @QueryParam("fiat_currency") String fiatCurrency) { + @QueryParam("fiat_currency") String fiatCurrency, @Context HttpServletRequest request) { try { - checkSecurity(apiKey); + checkSecurity(apiKey, request); List params = new ArrayList<>(); if (amount == null) { params.add("amount"); @@ -53,7 +55,7 @@ public Object terminalsWithAvailableCash(@HeaderParam("X-Api-Key") String apiKey } return filteredTerminals; } catch (AuthenticationException e) { - return responseInvalidApiKey(); + return responseInvalidApiKey(e); } catch (Throwable e) { log.error("Error - terminals with available cash", e); } @@ -73,10 +75,11 @@ public Object terminalsWithAvailableCash(@HeaderParam("X-Api-Key") String apiKey public Object sellCrypto(@HeaderParam("X-Api-Key") String apiKey, @QueryParam("serial_number") String serialNumber, @QueryParam("fiat_amount") BigDecimal fiatAmount, @QueryParam("fiat_currency") String fiatCurrency, @QueryParam("crypto_amount") BigDecimal cryptoAmount, @QueryParam("crypto_currency") String cryptoCurrency, - @QueryParam("identity_public_id") String identityPublicId, @QueryParam("discount_code") String discountCode) { + @QueryParam("identity_public_id") String identityPublicId, @QueryParam("discount_code") String discountCode, + @Context HttpServletRequest request) { try { - checkSecurity(apiKey); + checkSecurity(apiKey, request); List params = new ArrayList<>(); if (serialNumber == null || serialNumber.trim().isEmpty()) { params.add("serial_number"); @@ -96,7 +99,7 @@ public Object sellCrypto(@HeaderParam("X-Api-Key") String apiKey, @QueryParam("s return SellExtension.getExtensionContext().sellCrypto(serialNumber, fiatAmount, fiatCurrency, cryptoAmount, cryptoCurrency, identityPublicId, discountCode); } catch (AuthenticationException e) { - return responseInvalidApiKey(); + return responseInvalidApiKey(e); } catch (Throwable e) { log.error("Error - sell crypto", e); @@ -112,16 +115,18 @@ public Object sellCrypto(@HeaderParam("X-Api-Key") String apiKey, @QueryParam("s @GET @Path("/status") @Produces(MediaType.APPLICATION_JSON) - public Object status(@HeaderParam("X-Api-Key") String apiKey, @QueryParam("transaction_id") String transactionId) { + public Object status(@HeaderParam("X-Api-Key") String apiKey, + @QueryParam("transaction_id") String transactionId, + @Context HttpServletRequest request) { try { - checkSecurity(apiKey); + checkSecurity(apiKey, request); if (transactionId == null) { return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity("{ \"error\": \"Missing parameter transaction_id\" }").build(); } return SellExtension.getExtensionContext().findTransactionByTransactionId(transactionId).getStatus(); } catch (AuthenticationException e) { - return responseInvalidApiKey(); + return responseInvalidApiKey(e); } catch (Throwable e) { log.error("Error - status", e); } @@ -137,13 +142,13 @@ public Object status(@HeaderParam("X-Api-Key") String apiKey, @QueryParam("trans @GET @Path("/terminals") @Produces(MediaType.APPLICATION_JSON) - public Object terminals(@HeaderParam("X-Api-Key") String apiKey) { + public Object terminals(@HeaderParam("X-Api-Key") String apiKey, @Context HttpServletRequest request) { try { - IApiAccess iApiAccess = checkSecurity(apiKey); + IApiAccess iApiAccess = checkSecurity(apiKey, request); return getTerminalsByApiKey(iApiAccess); } catch (AuthenticationException e) { - return responseInvalidApiKey(); + return responseInvalidApiKey(e); } catch (Throwable e) { log.error("Error - terminals", e); } @@ -184,23 +189,31 @@ private boolean isOnline(ITerminal terminal) { * @param apiKey - key generated in CAS / Third Party / Operators sample website (OSW) * @return IApiAccess - Authenticated API key */ - private IApiAccess checkSecurity(String apiKey) throws AuthenticationException { + private IApiAccess checkSecurity(String apiKey, HttpServletRequest request) throws AuthenticationException { IApiAccess iApiAccess = SellExtension.getExtensionContext().getAPIAccessByKey(apiKey, ApiAccessType.OSW); if (iApiAccess == null) { - throw new AuthenticationException("Authentication failed"); + throw new AuthenticationException("Invalid X-Api-Key"); + } + log.info("IP whitelist check, from apiAccess={}, from request={}", iApiAccess.getIpWhitelist(), request.getRemoteAddr()); + if (isIpWhitelistSet(iApiAccess) && !iApiAccess.getIpWhitelist().equals(request.getRemoteAddr())) { + throw new AuthenticationException("Access from not allowed IP address"); } return iApiAccess; } + private boolean isIpWhitelistSet(IApiAccess iApiAccess) { + return iApiAccess.getIpWhitelist() != null && !iApiAccess.getIpWhitelist().isEmpty(); + } + private Response responseInvalidParameter(List params) { Map> map = new HashMap<>(); map.put("missingParameter", params); return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(createJsonString(map)).build(); } - private Response responseInvalidApiKey() { + private Response responseInvalidApiKey(AuthenticationException e) { Map map = new HashMap<>(); - map.put("error", "Invalid X-Api-Key"); + map.put("error", e.getMessage()); return Response.status(HttpServletResponse.SC_UNAUTHORIZED).entity(createJsonString(map)).build(); } diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/AbstractExtension.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/AbstractExtension.java index 9152eba81..7464ecff1 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/AbstractExtension.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/AbstractExtension.java @@ -23,6 +23,7 @@ import com.generalbytes.batm.server.extensions.aml.verification.IIdentityVerificationProvider; import com.generalbytes.batm.server.extensions.communication.ICommunicationProvider; import com.generalbytes.batm.server.extensions.communication.IPhoneLookupProvider; +import com.generalbytes.batm.server.extensions.communication.voicecall.IVoiceCallProvider; import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.util.Set; @@ -127,6 +128,9 @@ public Set getCommunicationProviders() { return null; } + @Override + public Set getVoiceCallProviders() { return null; } + @Override public Set getSsnValidators() { return null; diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/DiscountSpec.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/DiscountSpec.java index a1b58e9cc..2d6865681 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/DiscountSpec.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/DiscountSpec.java @@ -6,6 +6,8 @@ public class DiscountSpec { private BigDecimal buyDiscount; private BigDecimal sellDiscount; + private BigDecimal buyFixedFeeDiscount; + private BigDecimal sellFixedFeeDiscount; private Date validityFrom; private Date validityTill; private Long maximumUsages; @@ -19,6 +21,60 @@ public class DiscountSpec { private String notes; /** + * Creates Discount Specification. + * + * @param buyDiscount + * @param sellDiscount + * @param buyFixedFeeDiscount The percentage discount applied to the fixed fee on purchase transactions + * A value of 10 would represent a 10% discount on the fixed fee for buying. + * @param sellFixedFeeDiscount The percentage discount applied to the fixed fee on sale transactions + * A value of 10 would represent a 10% discount on the fixed fee for selling. + * @param validityFrom + * @param validityTill + * @param maximumUsages + * @param maximumUsagesPerIdentity + * @param minimumTransactionAmount + * @param totalLimit + * @param fiatCurrency in which currency are limit amounts + * @param firstTransactionOnly + * @param code (Optional) Defined code to be used (upper-cased) or null for code to be generated. + * @param linkedIdentityPublicId (Optional) Public ID of an existing identity to be linked to the Discount. + * @param notes (Optional) Notes worth noting. + */ + public DiscountSpec(BigDecimal buyDiscount, + BigDecimal sellDiscount, + BigDecimal buyFixedFeeDiscount, + BigDecimal sellFixedFeeDiscount, + Date validityFrom, + Date validityTill, + Long maximumUsages, + Long maximumUsagesPerIdentity, + BigDecimal minimumTransactionAmount, + BigDecimal totalLimit, + String fiatCurrency, + boolean firstTransactionOnly, + String code, + String linkedIdentityPublicId, + String notes) { + this.buyDiscount = buyDiscount; + this.sellDiscount = sellDiscount; + this.buyFixedFeeDiscount = buyFixedFeeDiscount; + this.sellFixedFeeDiscount = sellFixedFeeDiscount; + this.validityFrom = validityFrom; + this.validityTill = validityTill; + this.maximumUsages = maximumUsages; + this.maximumUsagesPerIdentity = maximumUsagesPerIdentity; + this.minimumTransactionAmount = minimumTransactionAmount; + this.totalLimit = totalLimit; + this.fiatCurrency = fiatCurrency; + this.firstTransactionOnly = firstTransactionOnly; + this.code = code; + this.linkedIdentityPublicId = linkedIdentityPublicId; + this.notes = notes; + } + + /** + * @deprecated Use first constructor instead. * Creates Discount Specification. * * @param buyDiscount @@ -34,7 +90,9 @@ public class DiscountSpec { * @param code (Optional) Defined code to be used (upper-cased) or null for code to be generated. * @param linkedIdentityPublicId (Optional) Public ID of an existing identity to be linked to the Discount. * @param notes (Optional) Notes worth noting. + * */ + @Deprecated public DiscountSpec(BigDecimal buyDiscount, BigDecimal sellDiscount, Date validityFrom, Date validityTill, Long maximumUsages, Long maximumUsagesPerIdentity, BigDecimal minimumTransactionAmount, BigDecimal totalLimit, String fiatCurrency, boolean firstTransactionOnly, String code, String linkedIdentityPublicId, String notes) { this.buyDiscount = buyDiscount; this.sellDiscount = sellDiscount; @@ -67,6 +125,22 @@ public void setSellDiscount(BigDecimal sellDiscount) { this.sellDiscount = sellDiscount; } + public BigDecimal getBuyFixedFeeDiscount() { + return buyFixedFeeDiscount; + } + + public void setBuyFixedFeeDiscount(BigDecimal buyFixedFeeDiscount) { + this.buyFixedFeeDiscount = buyFixedFeeDiscount; + } + + public BigDecimal getSellFixedFeeDiscount() { + return sellFixedFeeDiscount; + } + + public void setSellFixedFeeDiscount(BigDecimal sellFixedFeeDiscount) { + this.sellFixedFeeDiscount = sellFixedFeeDiscount; + } + public Date getValidityFrom() { return validityFrom; } diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IApiAccess.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IApiAccess.java index 8fb744d44..60f19157c 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IApiAccess.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IApiAccess.java @@ -5,4 +5,5 @@ public interface IApiAccess { Collection getTerminalSerialNumbers(); + String getIpWhitelist(); } diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtension.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtension.java index b0c9d7e41..dee337b18 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtension.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtension.java @@ -24,6 +24,7 @@ import com.generalbytes.batm.server.extensions.aml.verification.IIdentityVerificationProvider; import com.generalbytes.batm.server.extensions.communication.ICommunicationProvider; import com.generalbytes.batm.server.extensions.communication.IPhoneLookupProvider; +import com.generalbytes.batm.server.extensions.communication.voicecall.IVoiceCallProvider; import com.generalbytes.batm.server.extensions.watchlist.IWatchList; import java.util.Set; @@ -174,11 +175,17 @@ public interface IExtension { ITransactionScoringProvider createTransactionScoringProvider(String transactionScoringProviderParamValues); /** - * Optionally returns external communication providers that can be used by server to sending SMS or making voice calls. + * Optionally returns external communication providers that can be used by server to sending SMS. * @return */ Set getCommunicationProviders(); + /** + * Optionally returns external communication providers that can be used by server to making voice call. + * @return + */ + Set getVoiceCallProviders(); + /** * @return Validators that can be used to validate SSNs */ diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtensionContext.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtensionContext.java index 648d14360..461da7fff 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtensionContext.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IExtensionContext.java @@ -308,6 +308,17 @@ public interface IExtensionContext { */ boolean addIdentityPiece(String identityPublicId, IIdentityPiece iidentityPiece); + /** + * Update an existing personal info identity piece. + * + *

This method can only be used to update Personal Info identity pieces. + * + * @param identityPublicId public ID of an existing identity to be updated + * @param identityPiece identity piece to be updated + * @return true in case of success, false otherwise + */ + boolean updateIdentityPiecePersonalInfo(String identityPublicId, IIdentityPiece identityPiece); + /** * @param identityId public ID of an existing identity to be updated * @param state new state to be set diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITerminal.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITerminal.java index 320c7f2bf..f6d332df6 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITerminal.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITerminal.java @@ -19,6 +19,7 @@ import java.util.Date; import java.util.List; +import java.util.Set; public interface ITerminal { @@ -59,111 +60,140 @@ public interface ITerminal { long ERROR_ACCEPTOR_IS_NOT_DETECTED = 1 << 18; //"ACCEPTOR IS NOT DETECTED" /** - * Type of terminal @see TYPE_PHYSICAL and @see TYPE_VIRTUAL(Deprecated) - * @return + * Get the type of this terminal. See TYPE_PHYSICAL and TYPE_VIRTUAL. + * + * @return The type. */ Integer getType(); /** - * Serial number of terminal - * @return + * Get the serial number of this terminal. + * + * @return The serial number. */ String getSerialNumber(); /** - * Name of the terminal - * @return + * Get the name of this terminal. + * + * @return The name. */ String getName(); /** * Terminal is active = Server will not refuse terminal communication requests - * @return + * + * @return True if this terminal is active */ boolean isActive(); /** * Terminal is locked - * @return + * + * @return True if this terminal is locked */ boolean isLocked(); /** - * Deleted terminals are not displayed in administration but are still stored in database and marked as deleted - * @return + * Deleted terminals are not displayed in administration but are still stored + * in a database and marked as deleted. + * + * @return True if this terminal is deleted */ boolean isDeleted(); /** - * Location of terminal - * @return + * Get the location of this terminal. + * + * @return The location */ ILocation getLocation(); /** - * Server time of moment when terminal connected to server last time - * @return + * Get the server time of the moment this terminal last connected to the server. + * + * @return The date and time */ Date getConnectedAt(); /** - * Server time of moment when server received last ping request from terminal - * @return + * Get the server time of the moment the server last received a ping request from this terminal. + * + * @return The date and time */ Date getLastPingAt(); /** * Duration in number of milliseconds of last ping operation measured by terminal (request + response time) - * @return + * + * @return The duration */ long getLastPingDuration(); /** - * Server date and time when terminal asked for exchange rate at last time - * @return + * Server date and time when the terminal asked for exchange rate the last time + * + * @return The date and time */ Date getExchangeRateUpdatedAt(); /** * String representation of BUY exchange rate displayed on terminal on last successful ping - * @return + * + * @return The exchange rate */ String getExchangeRatesBuy(); /** * String representation of SELL exchange rate displayed on terminal on last successful ping - * @return + * + * @return The exchange rate */ String getExchangeRatesSell(); /** * Terminal error signalized by bit value see error constants in this interface ie ERROR_NO_ERROR - * @return + * + * @return The error code */ long getErrors(); /** * Signalizes current mode in which is terminal operating see different modes in this interface i.e.: MODE_ - * @return + * + * @return The mode in which is terminal operating */ int getOperationalMode(); /** - * When server refuses to talk to terminal it signalizes the this by a REASON see list of possible reasons in this interface: MODE_REJECTED_REASON_... - * @return + * When a server refuses to talk to the terminal, it signalizes this by a REASON. + * See the list of possible reasons in this interface: + * MODE_REJECTED_REASON_... + * + * @return The reason why the server refused to talk to the terminal */ int getRejectedReason(); /** - * Returns list of enabled fiat currencies on Terminal - * @return + * Returns list of enabled fiat currencies on this terminal. + * + * @return The list of fiat currencies */ List getAllowedCashCurrencies(); /** - * Returns list of enabled cryptocurrencies on Terminal - * @return + * Returns list of enabled cryptocurrencies on this terminal. + * + * @return The list of cryptocurrencies */ List getAllowedCryptoCurrencies(); + + /** + * Returns a set of tags that are attached to this terminal. + * + * @return The tags. + */ + Set getTags(); + } diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionBuyInfo.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionBuyInfo.java index 421df426b..2aace3fa4 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionBuyInfo.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionBuyInfo.java @@ -18,6 +18,7 @@ package com.generalbytes.batm.server.extensions; import java.math.BigDecimal; +import java.util.Date; import java.util.Map; public interface ITransactionBuyInfo { @@ -67,4 +68,18 @@ public interface ITransactionBuyInfo { * @return Custom texts that should be written on the ticket. Custom data are usually generated by ITransactionListener */ Map getCustomData(); + + /** + * Server time of the transaction + * + * @return {@link Date} + */ + Date getServerTime(); + + /** + * Terminal time of the transaction - calculated from the terminal location timezone (you may have terminals across multiple time zones) + * + * @return {@link Date} + */ + Date getTerminalTime(); } diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionSellInfo.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionSellInfo.java index f0f07186c..7be95a45e 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionSellInfo.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/ITransactionSellInfo.java @@ -18,6 +18,7 @@ package com.generalbytes.batm.server.extensions; import java.math.BigDecimal; +import java.util.Date; import java.util.Map; public interface ITransactionSellInfo { @@ -93,4 +94,18 @@ public interface ITransactionSellInfo { * @return */ Map getCustomData(); + + /** + * Server time of the transaction + * + * @return {@link Date} + */ + Date getServerTime(); + + /** + * Terminal time of the transaction - calculated from the terminal location timezone (you may have terminals across multiple time zones) + * + * @return {@link Date} + */ + Date getTerminalTime(); } diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IVerificationInfo.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IVerificationInfo.java index 686430522..dd158e4a6 100644 --- a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IVerificationInfo.java +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/IVerificationInfo.java @@ -4,5 +4,6 @@ public interface IVerificationInfo { boolean isSuccess(); String getErrorMessage(); - + String getApplicantId(); + String getVerificationWebUrl(); } diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/IVoiceCallErrorResponse.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/IVoiceCallErrorResponse.java new file mode 100644 index 000000000..d34274f87 --- /dev/null +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/IVoiceCallErrorResponse.java @@ -0,0 +1,33 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ + +package com.generalbytes.batm.server.extensions.communication.voicecall; + +public interface IVoiceCallErrorResponse { + + /** + * Error message. + */ + String getErrorMessage(); + + /** + * Making of voice call failed due the number is on black list. + */ + boolean isBlacklisted(); + +} diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/IVoiceCallProvider.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/IVoiceCallProvider.java new file mode 100644 index 000000000..601b48413 --- /dev/null +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/IVoiceCallProvider.java @@ -0,0 +1,43 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ + +package com.generalbytes.batm.server.extensions.communication.voicecall; + +/** + * Provider for making voice call. + */ +public interface IVoiceCallProvider { + + /** + * Name of the voice call provider. + */ + String getName(); + + /** + * Make the voice call. + * + * @param credentials Credentials. + * @param phoneNumber Phone number. + * @param message Message. + * @param messageType Type of message. + * @param language Language in ISO 639-1 standard used at terminal. + * @return {@link IVoiceCallResponse} + */ + IVoiceCallResponse makeVoiceCall(String credentials, String phoneNumber, String message, MessageType messageType, String language); + +} diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/IVoiceCallResponse.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/IVoiceCallResponse.java new file mode 100644 index 000000000..cccc19c5f --- /dev/null +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/IVoiceCallResponse.java @@ -0,0 +1,43 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ + +package com.generalbytes.batm.server.extensions.communication.voicecall; + +public interface IVoiceCallResponse { + + enum ResponseStatus { + OK, + ERROR + } + + /** + * ID of voice call. + */ + String getSid(); + + /** + * Response status [OK, ERROR]. + */ + ResponseStatus getStatus(); + + /** + * Error information. + */ + IVoiceCallErrorResponse getErrorResponse(); + +} diff --git a/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/MessageType.java b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/MessageType.java new file mode 100644 index 000000000..296cafbe8 --- /dev/null +++ b/server_extensions_api/src/main/java/com/generalbytes/batm/server/extensions/communication/voicecall/MessageType.java @@ -0,0 +1,24 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ + +package com.generalbytes.batm.server.extensions.communication.voicecall; + +public enum MessageType { + MESSAGE, + OTP +} diff --git a/server_extensions_examples/build.gradle b/server_extensions_examples/build.gradle new file mode 100644 index 000000000..275a5bf6b --- /dev/null +++ b/server_extensions_examples/build.gradle @@ -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") +} \ No newline at end of file diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/ProfitOverrideExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/ProfitOverrideExtension.java similarity index 97% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/ProfitOverrideExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/ProfitOverrideExtension.java index 6bb423feb..47a3b22c0 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/ProfitOverrideExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/ProfitOverrideExtension.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/TransactionExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/TransactionExtension.java similarity index 97% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/TransactionExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/TransactionExtension.java index c0c91e4c0..f3a073c30 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/TransactionExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/TransactionExtension.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/activeTerminals/ActiveTerminalsExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/activeterminals/ActiveTerminalsExtension.java similarity index 94% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/activeTerminals/ActiveTerminalsExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/activeterminals/ActiveTerminalsExtension.java index 4a4dd5a47..fb8e3a7f2 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/activeTerminals/ActiveTerminalsExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/activeterminals/ActiveTerminalsExtension.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/activeTerminals/RestServiceActiveTerminals.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/activeterminals/RestServiceActiveTerminals.java similarity index 96% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/activeTerminals/RestServiceActiveTerminals.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/activeterminals/RestServiceActiveTerminals.java index 0ff8dd65d..66158ed2b 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/activeTerminals/RestServiceActiveTerminals.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/activeterminals/RestServiceActiveTerminals.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/ChatBotExtensionExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/ChatBotExtensionExample.java similarity index 95% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/ChatBotExtensionExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/ChatBotExtensionExample.java index 5277fb023..5741400de 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/ChatBotExtensionExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/ChatBotExtensionExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/ChatUtils.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/ChatUtils.java similarity index 96% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/ChatUtils.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/ChatUtils.java index 76850544f..81680d253 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/ChatUtils.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/ChatUtils.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/InfoCommand.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/InfoCommand.java similarity index 99% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/InfoCommand.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/InfoCommand.java index aaa4d186e..fc22f8e84 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/InfoCommand.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/InfoCommand.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/LightningCommand.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/LightningCommand.java similarity index 98% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/LightningCommand.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/LightningCommand.java index dd3a1f76d..4d86adaf2 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/LightningCommand.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/LightningCommand.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/VersionCommand.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/VersionCommand.java similarity index 95% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/VersionCommand.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/VersionCommand.java index 9de4c839d..17e990ba7 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/chat/VersionCommand.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/chat/VersionCommand.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/ExternalCommunicationExampleExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/ExternalCommunicationExampleExtension.java similarity index 91% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/ExternalCommunicationExampleExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/ExternalCommunicationExampleExtension.java index c449eda5c..99398ff38 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/ExternalCommunicationExampleExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/ExternalCommunicationExampleExtension.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/NexmoSmsProvider.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/NexmoSmsProvider.java similarity index 96% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/NexmoSmsProvider.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/NexmoSmsProvider.java index 09e7e95b7..6d18863c6 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/NexmoSmsProvider.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/NexmoSmsProvider.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/SmsErrorResponseImpl.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/SmsErrorResponseImpl.java similarity index 90% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/SmsErrorResponseImpl.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/SmsErrorResponseImpl.java index 340a30dc9..bd518b54f 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/SmsErrorResponseImpl.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/SmsErrorResponseImpl.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/SmsResponseImpl.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/SmsResponseImpl.java similarity index 92% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/SmsResponseImpl.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/SmsResponseImpl.java index 4035642ef..7e64053b3 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/communication/SmsResponseImpl.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/communication/SmsResponseImpl.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExampleIdentityListener.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/ExampleIdentityListener.java similarity index 99% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExampleIdentityListener.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/ExampleIdentityListener.java index e65f62b72..30c93f213 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExampleIdentityListener.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/ExampleIdentityListener.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExternalIdentityExampleExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/ExternalIdentityExampleExtension.java similarity index 98% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExternalIdentityExampleExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/ExternalIdentityExampleExtension.java index b8f33fc1c..b9b72ca29 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/ExternalIdentityExampleExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/ExternalIdentityExampleExtension.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityExampleExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityExampleExtension.java similarity index 96% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityExampleExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityExampleExtension.java index 7343bc70c..61dfa9e5e 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityExampleExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityExampleExtension.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityExampleIRestService.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityExampleIRestService.java similarity index 93% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityExampleIRestService.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityExampleIRestService.java index f5b8f8f5b..9d64795a4 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityExampleIRestService.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityExampleIRestService.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityExampleRestService.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityExampleRestService.java similarity index 99% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityExampleRestService.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityExampleRestService.java index 51e36538b..41339bac4 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityExampleRestService.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityExampleRestService.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityPieceExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityPieceExample.java similarity index 98% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityPieceExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityPieceExample.java index 1e0c398c8..75befc75f 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/IdentityPieceExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/IdentityPieceExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/LimitExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/LimitExample.java similarity index 94% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/LimitExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/LimitExample.java index 2809406cb..251a22c41 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/identity/LimitExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/identity/LimitExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/CashCollectionDayExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/CashCollectionDayExample.java similarity index 80% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/CashCollectionDayExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/CashCollectionDayExample.java index 50039c2a4..834ae7ecc 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/CashCollectionDayExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/CashCollectionDayExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationDetailExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationDetailExample.java similarity index 97% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationDetailExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationDetailExample.java index 82423c0fd..49f3d3eef 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationDetailExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationDetailExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationExampleExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationExampleExtension.java similarity index 92% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationExampleExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationExampleExtension.java index 9f21211ee..c5ffeaf40 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationExampleExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationExampleExtension.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationExampleIRestService.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationExampleIRestService.java similarity index 82% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationExampleIRestService.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationExampleIRestService.java index 7a627cde5..df1b3ddca 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationExampleIRestService.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationExampleIRestService.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationExampleRestService.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationExampleRestService.java similarity index 99% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationExampleRestService.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationExampleRestService.java index f16081abf..8d5ab6daf 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/LocationExampleRestService.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/LocationExampleRestService.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/NoteExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/NoteExample.java similarity index 93% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/NoteExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/NoteExample.java index 89c41ce8d..9d3384f21 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/NoteExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/NoteExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/OpeningHoursExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/OpeningHoursExample.java similarity index 89% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/OpeningHoursExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/OpeningHoursExample.java index 712c4ed91..77330508b 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/OpeningHoursExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/OpeningHoursExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/OrganizationExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/OrganizationExample.java similarity index 81% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/OrganizationExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/OrganizationExample.java index 94c8ab8d2..5a9d99316 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/OrganizationExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/OrganizationExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/PersonExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/PersonExample.java similarity index 96% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/PersonExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/PersonExample.java index e60688011..62ce902af 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/location/PersonExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/location/PersonExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/notification/ExampleNotificationListener.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/notification/ExampleNotificationListener.java similarity index 96% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/notification/ExampleNotificationListener.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/notification/ExampleNotificationListener.java index fb0d14d9e..9528d0846 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/notification/ExampleNotificationListener.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/notification/ExampleNotificationListener.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/notification/NotificationExampleExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/notification/NotificationExampleExtension.java similarity index 87% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/notification/NotificationExampleExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/notification/NotificationExampleExtension.java index ba4ee9add..a9991a975 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/notification/NotificationExampleExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/notification/NotificationExampleExtension.java @@ -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 { diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/MyExtensionExampleResponse.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/MyExtensionExampleResponse.java similarity index 95% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/MyExtensionExampleResponse.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/MyExtensionExampleResponse.java index 7514ee0fb..c8a0195a0 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/MyExtensionExampleResponse.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/MyExtensionExampleResponse.java @@ -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 diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/RESTExampleExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/RESTExampleExtension.java similarity index 97% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/RESTExampleExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/RESTExampleExtension.java index 477db7a91..ca05e6f5e 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/RESTExampleExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/RESTExampleExtension.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/RESTServiceExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/RESTServiceExample.java similarity index 99% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/RESTServiceExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/RESTServiceExample.java index 967db2c24..8e129b7f1 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/RESTServiceExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/RESTServiceExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/SecuredRESTServiceClient.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/SecuredRESTServiceClient.java similarity index 98% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/SecuredRESTServiceClient.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/SecuredRESTServiceClient.java index ba4b85455..e5f98ab66 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/SecuredRESTServiceClient.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/SecuredRESTServiceClient.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/SecuredRESTServiceExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/SecuredRESTServiceExample.java similarity index 98% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/SecuredRESTServiceExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/SecuredRESTServiceExample.java index ac6a0c3d9..f9005f19b 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/SecuredRESTServiceExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/SecuredRESTServiceExample.java @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/ServletFilterExample.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/ServletFilterExample.java similarity index 96% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/ServletFilterExample.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/ServletFilterExample.java index a6dc666d8..1694ab8cd 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/examples/rest/ServletFilterExample.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/rest/ServletFilterExample.java @@ -1,4 +1,4 @@ -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; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/watchlists/WatchlistExtension.java b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/watchlists/WatchlistExtension.java similarity index 97% rename from server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/watchlists/WatchlistExtension.java rename to server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/watchlists/WatchlistExtension.java index 93bf6c981..c6b1f537e 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/watchlists/WatchlistExtension.java +++ b/server_extensions_examples/src/main/java/com/generalbytes/batm/server/extensions/examples/watchlists/WatchlistExtension.java @@ -15,7 +15,7 @@ * Web : http://www.generalbytes.com * ************************************************************************************/ -package com.generalbytes.batm.server.extensions.extra.watchlists; +package com.generalbytes.batm.server.extensions.examples.watchlists; import com.generalbytes.batm.server.extensions.*; import com.generalbytes.batm.server.extensions.watchlist.WatchListMatch; diff --git a/server_extensions_examples/src/main/resources/batm-extensions.xml b/server_extensions_examples/src/main/resources/batm-extensions.xml new file mode 100644 index 000000000..7a7cf5dc0 --- /dev/null +++ b/server_extensions_examples/src/main/resources/batm-extensions.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/server_extensions_extra/build.gradle b/server_extensions_extra/build.gradle index 582ee8fcd..f29377a07 100644 --- a/server_extensions_extra/build.gradle +++ b/server_extensions_extra/build.gradle @@ -65,8 +65,6 @@ dependencies { implementation("org.reactivestreams:reactive-streams:1.0.2") // for ERC20Interface generated by web3j implementation("com.squareup.okhttp3:okhttp:4.9.0") implementation("com.squareup.okio:okio:2.8.0") - implementation("com.vdurmont:emoji-java:3.1.3") //for chat emojis - implementation("com.nexmo:client:5.5.0") // sms provider implementation("org.bitcoinj:bitcoinj-core:0.16.1") // Note when updating bitcoinj: block.io depends on libdohj for doge and ltc // which depends on bitcoinj and extends some classes, it must be compatible version diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/TestExtensionContext.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/TestExtensionContext.java index 3b0c6cd60..4fa5b1892 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/TestExtensionContext.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/TestExtensionContext.java @@ -192,6 +192,11 @@ public boolean addIdentityPiece(String identityPublicId, IIdentityPiece iidentit return false; } + @Override + public boolean updateIdentityPiecePersonalInfo(String identityPublicId, IIdentityPiece identityPiece) { + return false; + } + @Override public IIdentity updateIdentity(String identityId, String externalId, int state, int type, Date created, Date registered, BigDecimal vipBuyDiscount, BigDecimal vipSellDiscount, String note, List limitCashPerTransaction, List limitCashPerHour, List limitCashPerDay, List limitCashPerWeek, List limitCashPerMonth, List limitCashPer3Months, List limitCashPer12Months, List limitCashPerCalendarQuarter, List limitCashPerCalendarYear, List limitCashTotalIdentity, String configurationCashCurrency) { return null; diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java index e1c041913..e31130f10 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/BitcoinExtension.java @@ -37,6 +37,7 @@ import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.hitbtc.HitbtcExchange; import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.enigma.EnigmaExchange; import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.poloniex.PoloniexExchange; +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.StillmanDigitalExchange; import com.generalbytes.batm.server.extensions.extra.bitcoin.paymentprocessors.bitcoinpay.BitcoinPayPP; import com.generalbytes.batm.server.extensions.extra.bitcoin.paymentprocessors.coinofsale.CoinOfSalePP; import com.generalbytes.batm.server.extensions.extra.bitcoin.sources.bitkub.BitKubRateSource; @@ -221,6 +222,11 @@ public IExchange createExchange(String paramString) { String apiKey = paramTokenizer.nextToken(); String apiSecret = paramTokenizer.nextToken(); return new BitbuyExchange(apiKey, apiSecret); + } else if ("stillmandigital".equalsIgnoreCase(prefix)) { + String apiKey = paramTokenizer.nextToken(); + String apiSecret = paramTokenizer.nextToken(); + boolean useSandbox = paramTokenizer.hasMoreTokens() && paramTokenizer.nextToken().equals("sandbox"); + return new StillmanDigitalExchange(apiKey, apiSecret, useSandbox); } } } catch (Exception e) { @@ -587,6 +593,11 @@ public IRateSource createRateSource(String sourceLogin) { String apiKey = st.nextToken(); String apiSecret = st.nextToken(); return new BitbuyExchange(apiKey, apiSecret); + } else if ("stillmandigital".equalsIgnoreCase(rsType)) { + String apiKey = st.nextToken(); + String apiSecret = st.nextToken(); + boolean useSandbox = st.hasMoreTokens() && st.nextToken().equals("sandbox"); + return new StillmanDigitalExchange(apiKey, apiSecret, useSandbox); } } } catch (Exception e) { diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/binance/BinanceExchange.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/binance/BinanceExchange.java index ff2b8c0f0..0f5cf602e 100644 --- a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/binance/BinanceExchange.java +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/binance/BinanceExchange.java @@ -17,6 +17,7 @@ ************************************************************************************/ package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.binance; +import com.generalbytes.batm.common.currencies.CryptoCurrency; import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.XChangeExchange; import org.knowm.xchange.ExchangeSpecification; import org.knowm.xchange.currency.CurrencyPair; @@ -24,6 +25,7 @@ import org.knowm.xchange.dto.account.Wallet; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.Set; import java.util.stream.Collectors; @@ -91,6 +93,11 @@ protected BigDecimal getAmountRoundedToMinStep(BigDecimal cryptoAmount, BigDecim public String sendCoins(String destinationAddress, BigDecimal amount, String cryptoCurrency, String description) { BigDecimal withdrawalFee = getWithdrawalFee(cryptoCurrency); amount = amount.add(withdrawalFee); + + if (CryptoCurrency.USDT.getCode().equals(cryptoCurrency)) { + amount = amount.setScale(6, RoundingMode.FLOOR); + } + return super.sendCoins(destinationAddress, amount, cryptoCurrency, description); } @@ -110,8 +117,8 @@ protected BigDecimal getWithdrawalMinStep(String cryptoCurrency) { } protected static class SupportedCryptoCurrency { - private String cryptoCurrency; - private BigDecimal withdrawalMinStep; + private final String cryptoCurrency; + private final BigDecimal withdrawalMinStep; public SupportedCryptoCurrency(String cryptoCurrency) { this(cryptoCurrency, new BigDecimal("0.00000001")); diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/CurrentTimeFactory.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/CurrentTimeFactory.java new file mode 100644 index 000000000..9332d68cf --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/CurrentTimeFactory.java @@ -0,0 +1,34 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital; + +import si.mazi.rescu.SynchronizedValueFactory; + +import java.time.Clock; +import java.util.concurrent.TimeUnit; + +public class CurrentTimeFactory implements SynchronizedValueFactory { + + private static final Clock UTC_CLOCK = Clock.systemUTC(); + + + @Override + public Long createValue() { + return TimeUnit.MILLISECONDS.toSeconds(UTC_CLOCK.millis()); + } +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/IStillmanDigitalAPI.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/IStillmanDigitalAPI.java new file mode 100644 index 000000000..ec0cf83f2 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/IStillmanDigitalAPI.java @@ -0,0 +1,78 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital; + +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto.*; +import com.generalbytes.batm.server.extensions.util.net.RateLimitingInterceptor; +import si.mazi.rescu.ClientConfig; +import si.mazi.rescu.Interceptor; +import si.mazi.rescu.RestProxyFactory; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.util.List; + +@Path("") +@Produces(MediaType.APPLICATION_JSON) +public interface IStillmanDigitalAPI { + + String API_EXPIRES_HEADER = "api-timestamp"; + + static IStillmanDigitalAPI create(String apiKey, String apiSecret, + boolean useSandbox) throws GeneralSecurityException { + return create(apiKey, apiSecret, + useSandbox ? "https://sandbox-api.stillmandigital.com" : "https://api.stillmandigital.com"); + } + + static IStillmanDigitalAPI create(String apiKey, String apiSecret, String baseUrl) throws GeneralSecurityException { + final ClientConfig config = new ClientConfig(); + config.addDefaultParam(HeaderParam.class, "api-key", apiKey); + config.addDefaultParam(HeaderParam.class, API_EXPIRES_HEADER, new CurrentTimeFactory()); + config.addDefaultParam(HeaderParam.class, "api-signature", new StillmanDigitalDigest(apiSecret)); + Interceptor interceptor = new RateLimitingInterceptor(IStillmanDigitalAPI.class, 25, 30_000); + return RestProxyFactory.createProxy(IStillmanDigitalAPI.class, baseUrl, config, interceptor); + } + + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Path("/v1/trading/rate") + Rate requestRate(RateRequest request) throws IOException; + + @GET + @Path("/v1/balances") + List getBalance() throws IOException; + + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Path("/v1/trading/new") + NewOrderResponse sendOrder(OrderRequest orderRequest) throws IOException; + + @GET + @Path("/v1/orders/{id}") + RowOrderResponse getOrder(@PathParam("id") long orderId) throws IOException; + +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanDigitalDigest.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanDigitalDigest.java new file mode 100644 index 000000000..260d6c5fd --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanDigitalDigest.java @@ -0,0 +1,60 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital; + +import com.generalbytes.batm.server.coinutil.Hex; +import si.mazi.rescu.ParamsDigest; +import si.mazi.rescu.RestInvocation; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.security.GeneralSecurityException; + +public class StillmanDigitalDigest implements ParamsDigest { + + private static final String HMAC_SHA256_ALGORITHM = "HmacSHA256"; + private static final Charset CHARSET = StandardCharsets.UTF_8; + + private final Mac mac; + + public StillmanDigitalDigest(String apiSecret) throws GeneralSecurityException { + mac = Mac.getInstance(HMAC_SHA256_ALGORITHM); + mac.init(new SecretKeySpec(apiSecret.getBytes(CHARSET), HMAC_SHA256_ALGORITHM)); + } + + public String digestParams(RestInvocation restInvocation) { + // String dataForSign = method + BALANCE_URL_PART + validUntilSeconds + body; + String dataForSign = restInvocation.getHttpMethod() + + restInvocation.getMethodPath() + + restInvocation.getHttpHeadersFromParams().get(IStillmanDigitalAPI.API_EXPIRES_HEADER) + + restInvocation.getRequestBody(); + return signHmacSha256(dataForSign); + } + + private String signHmacSha256(String data) { + byte[] signData = mac.doFinal(data.getBytes(StandardCharsets.UTF_8)); + + return Hex.bytesToHexString(signData); + } +} + + + + diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanDigitalExchange.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanDigitalExchange.java new file mode 100644 index 000000000..504f0182e --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanDigitalExchange.java @@ -0,0 +1,183 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital; + +import com.generalbytes.batm.common.currencies.CryptoCurrency; +import com.generalbytes.batm.common.currencies.FiatCurrency; +import com.generalbytes.batm.server.extensions.IExchangeAdvanced; +import com.generalbytes.batm.server.extensions.IRateSourceAdvanced; +import com.generalbytes.batm.server.extensions.ITask; +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto.RateRequest; +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto.RowBalanceByAssetResponse; +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto.Side; +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto.Rate; +import com.google.common.collect.ImmutableSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.math.BigDecimal; +import java.security.GeneralSecurityException; +import java.util.Objects; +import java.util.Set; + +public class StillmanDigitalExchange implements IExchangeAdvanced, IRateSourceAdvanced { + private static final Logger log = LoggerFactory.getLogger("batm.master.exchange.StillmanDigitalExchange"); + public static final String SEPARATOR = "/"; + + private final String preferredFiatCurrency = FiatCurrency.USD.getCode(); + private final IStillmanDigitalAPI api; + + public StillmanDigitalExchange(String apiKey, + String apiSecret, + boolean useSandbox) throws GeneralSecurityException { + this.api = IStillmanDigitalAPI.create(apiKey, apiSecret, useSandbox); + } + + // for tests only + StillmanDigitalExchange(String apiKey, + String apiSecret, + String baseUrl) throws GeneralSecurityException { + this.api = IStillmanDigitalAPI.create(apiKey, apiSecret, baseUrl); + } + + private static final Set fiatCurrencies = ImmutableSet.of( + FiatCurrency.USD.getCode()); + + private static final Set cryptoCurrencies = ImmutableSet.of( + CryptoCurrency.BTC.getCode(), + CryptoCurrency.ETH.getCode()); + + @Override + public Set getCryptoCurrencies() { + return cryptoCurrencies; + } + + @Override + public Set getFiatCurrencies() { + return fiatCurrencies; + } + + @Override + public String getPreferredFiatCurrency() { + return preferredFiatCurrency; + } + + @Override + public BigDecimal getCryptoBalance(String cryptoCurrency) { + try { + for (RowBalanceByAssetResponse assetData : api.getBalance()) { + if (Objects.equals(cryptoCurrency, assetData.asset)) { + // crypto is interesting in terms on how much client can withdraw + return assetData.total; + } + } + } catch (IOException e) { + log.error("Error", e); + } + return null; + } + + @Override + public BigDecimal getFiatBalance(String fiatCurrency) { + try { + for (RowBalanceByAssetResponse assetData : api.getBalance()) { + if (Objects.equals(fiatCurrency, assetData.asset)) { + // fiat is interesting in terms on how much client can spent to buy crypto, due this just FREE + return assetData.free; + } + } + } catch (IOException e) { + log.error("Error", e); + } + return null; + } + + @Override + public String sendCoins(String destinationAddress, + BigDecimal amount, String cryptoCurrency, String description) { + return "Plz contact your manager for withdraw"; + } + + @Override + public String getDepositAddress(String cryptoCurrency) { + return null; + } + + @Override + public ITask createPurchaseCoinsTask(BigDecimal amount, String cryptoCurrency, String fiatCurrencyToUse, String description) { + return new StillmanOrderTask(api, Side.BUY, cryptoCurrency + SEPARATOR + fiatCurrencyToUse, amount, log); + } + + @Override + public ITask createSellCoinsTask(BigDecimal amount, String cryptoCurrency, String fiatCurrencyToUse, String description) { + return new StillmanOrderTask(api, Side.SELL, cryptoCurrency + SEPARATOR + fiatCurrencyToUse, amount, log); + } + + @Override + public BigDecimal getExchangeRateForBuy(String cryptoCurrency, String fiatCurrency) { + try { + Rate rate = api.requestRate(new RateRequest(cryptoCurrency + SEPARATOR + fiatCurrency)); + if (rate != null) { + return rate.buyRate; + } + } catch (IOException e) { + log.error("Error", e); + } + return null; + } + + @Override + public BigDecimal getExchangeRateForSell(String cryptoCurrency, String fiatCurrency) { + try { + Rate rate = api.requestRate(new RateRequest(cryptoCurrency + SEPARATOR + fiatCurrency)); + if (rate != null) { + return rate.sellRate; + } + } catch (IOException e) { + log.error("Error", e); + } + return null; + } + + @Override + public BigDecimal calculateBuyPrice(String cryptoCurrency, String fiatCurrency, BigDecimal cryptoAmount) { + try { + Rate rate = api.requestRate(new RateRequest(cryptoCurrency + SEPARATOR + fiatCurrency, cryptoAmount)); + if (rate != null && rate.buyRate != null) { + return rate.buyRate; + } + } catch (IOException e) { + log.error("Error", e); + } + return null; + } + + @Override + public BigDecimal calculateSellPrice(String cryptoCurrency, String fiatCurrency, BigDecimal cryptoAmount) { + try { + Rate rate = api.requestRate(new RateRequest(cryptoCurrency + SEPARATOR + fiatCurrency, cryptoAmount)); + if (rate != null && rate.sellRate != null) { + return rate.sellRate; + } + } catch (IOException e) { + log.error("Error", e); + } + return null; + } +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanOrderTask.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanOrderTask.java new file mode 100644 index 000000000..ff8bf35f3 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanOrderTask.java @@ -0,0 +1,121 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital; + +import com.generalbytes.batm.server.extensions.ITask; +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto.OrderRequest; +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto.OrderStatus; +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto.RowOrderResponse; +import com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto.Side; +import org.slf4j.Logger; + +import java.io.IOException; +import java.math.BigDecimal; +import java.util.concurrent.ThreadLocalRandom; + +public class StillmanOrderTask implements ITask { + + private final IStillmanDigitalAPI api; + private final OrderRequest request; + private final Logger log; + + private boolean failed; + private OrderStatus result; + private long orderId; + + public StillmanOrderTask(IStillmanDigitalAPI api, Side side, String symbol, BigDecimal qty, Logger log) { + this.log = log; + this.api = api; + request = new OrderRequest(); + request.side = side; + request.pairName = symbol; + request.requestAmount = qty; + request.clOrdId = "GB_" + ThreadLocalRandom.current().nextInt(0, 1_000_000); + } + + @Override + public boolean onCreate() { + try { + orderId = api.sendOrder(request).orderId; + } catch (IOException e) { + log.error("Create order task failed", e); + failed = true; + result = OrderStatus.UNKNOWN; + return false; + } + return true; + } + + @Override + public boolean onDoStep() { + RowOrderResponse orderResponse; + try { + orderResponse = api.getOrder(orderId); + } catch (IOException e) { + log.error("Get order failed, try next time", e); + return false; + } + switch (orderResponse.status) { + case ACTIVE: + case PARTIALLY_FILLED: { + log.debug("Order is still active {}", orderResponse); + return false; + } + + case REJECTED: { + result = orderResponse.status; + failed = true; + return true; + } + case CANCELED: + case CANCEL: + case FILLED: + case PARTIALLY_FILLED_CANCELED: { + result = orderResponse.status; + return true; + } + } + + return false; + } + + @Override + public void onFinish() { + + } + + @Override + public boolean isFinished() { + return result != null; + } + + @Override + public Object getResult() { + return result.toString(); + } + + @Override + public boolean isFailed() { + return failed; + } + + @Override + public long getShortestTimeForNexStepInvocation() { + return 5 * 1000; + } +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/BalanceResponse.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/BalanceResponse.java new file mode 100644 index 000000000..f5c8ce115 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/BalanceResponse.java @@ -0,0 +1,28 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + +import java.util.List; + +public class BalanceResponse { + + public String account; + + public List data; + +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/NewOrderResponse.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/NewOrderResponse.java new file mode 100644 index 000000000..b2dbfa600 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/NewOrderResponse.java @@ -0,0 +1,24 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + + +public class NewOrderResponse { + + public long orderId; +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/OrdType.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/OrdType.java new file mode 100644 index 000000000..b980eb3e0 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/OrdType.java @@ -0,0 +1,24 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + +public enum OrdType { + + MARKET + +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/OrderRequest.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/OrderRequest.java new file mode 100644 index 000000000..aed503040 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/OrderRequest.java @@ -0,0 +1,31 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + +import java.math.BigDecimal; + +public class OrderRequest { + + public Side side; + + public String pairName; + + public String clOrdId; + + public BigDecimal requestAmount; +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/OrderStatus.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/OrderStatus.java new file mode 100644 index 000000000..513e1738c --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/OrderStatus.java @@ -0,0 +1,31 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + +public enum OrderStatus { + ACTIVE, + CANCEL, + CANCELED, + EXPIRED, + FILLED, + PARTIALLY_FILLED, + PARTIALLY_FILLED_CANCELED, + REPLACED, + REJECTED, + UNKNOWN; +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/Rate.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/Rate.java new file mode 100644 index 000000000..a841204fa --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/Rate.java @@ -0,0 +1,38 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + +import java.math.BigDecimal; + +public class Rate { + + public String pairName; + + public BigDecimal buyQuantity; + + public BigDecimal buyRate; + + public BigDecimal buyTotal; + + public BigDecimal sellQuantity; + + public BigDecimal sellRate; + + public BigDecimal sellTotal; + +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/RateRequest.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/RateRequest.java new file mode 100644 index 000000000..939dcb68c --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/RateRequest.java @@ -0,0 +1,38 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + +import java.math.BigDecimal; + +public class RateRequest { + + public RateRequest(String pairName) { + this(pairName, BigDecimal.ZERO); + } + + public RateRequest(String pairName, BigDecimal requestAmount) { + this.pairName = pairName; + this.requestAmount = requestAmount; + } + + public String pairName; + + public Boolean requestInBaseAsset = true; + + public BigDecimal requestAmount; +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/RowBalanceByAssetResponse.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/RowBalanceByAssetResponse.java new file mode 100644 index 000000000..5329ddebb --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/RowBalanceByAssetResponse.java @@ -0,0 +1,32 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + +import java.math.BigDecimal; + +public class RowBalanceByAssetResponse { + + public String asset; + + public BigDecimal total; + + public BigDecimal free; + + public BigDecimal credit; + +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/RowOrderResponse.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/RowOrderResponse.java new file mode 100644 index 000000000..c2e818884 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/RowOrderResponse.java @@ -0,0 +1,36 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + + +import java.math.BigDecimal; + +public class RowOrderResponse { + + public long orderId; + public String pairName; + public Side side; + public BigDecimal price; + public OrdType ordType; + public BigDecimal quantity; + public BigDecimal filledQty; + public BigDecimal avgPrice; + public BigDecimal volume; + + public OrderStatus status; +} diff --git a/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/Side.java b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/Side.java new file mode 100644 index 000000000..972f2f8b1 --- /dev/null +++ b/server_extensions_extra/src/main/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/dto/Side.java @@ -0,0 +1,23 @@ +/************************************************************************************* + * Copyright (C) 2014-2023 GENERAL BYTES s.r.o. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as published by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * GENERAL BYTES s.r.o. + * Web : http://www.generalbytes.com + * + ************************************************************************************/ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital.dto; + +public enum Side { + BUY, + SELL +} diff --git a/server_extensions_extra/src/main/resources/batm-extensions.xml b/server_extensions_extra/src/main/resources/batm-extensions.xml index a0baec433..e97882634 100644 --- a/server_extensions_extra/src/main/resources/batm-extensions.xml +++ b/server_extensions_extra/src/main/resources/batm-extensions.xml @@ -819,6 +819,19 @@ ETH LTC + + + + BTC + ETH + https://www.stillmandigital.com + + + + + BTC + ETH + @@ -2170,7 +2183,6 @@ - @@ -2357,16 +2369,4 @@ - - - - - - - - - - - - diff --git a/server_extensions_extra/src/test/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanDigitalExchangeTest.java b/server_extensions_extra/src/test/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanDigitalExchangeTest.java new file mode 100644 index 000000000..17fe7511a --- /dev/null +++ b/server_extensions_extra/src/test/java/com/generalbytes/batm/server/extensions/extra/bitcoin/exchanges/stillmandigital/StillmanDigitalExchangeTest.java @@ -0,0 +1,58 @@ +package com.generalbytes.batm.server.extensions.extra.bitcoin.exchanges.stillmandigital; + +import com.generalbytes.batm.server.extensions.ITask; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import java.math.BigDecimal; +import java.security.GeneralSecurityException; + +import static org.junit.Assert.assertNotNull; + +@Ignore // requires online resources - for manual run only +public class StillmanDigitalExchangeTest { + private static final String PUBLIC_KEY = "9QU20A1IO3QN2L6ND90JBG80"; + private static final String PRIVATE_KEY = "A2CBOQMJKJ69O59ZC9SKVY58M9NCNQQXEOF9W1Y0DSF56GBI"; + private static final String BASE_URL = "https://sandbox-api.stillmandigital.com"; + + private static StillmanDigitalExchange exchange; + + @BeforeClass + public static void createExchange() throws GeneralSecurityException { + exchange = new StillmanDigitalExchange(PUBLIC_KEY, PRIVATE_KEY, BASE_URL); + } + + @Test + public void getFiatBalanceTest() { + System.out.println("USD balance: " + exchange.getFiatBalance("USD")); + } + + @Test + public void getCryptoBalanceTest() { + System.out.println("Crypto balance: " + exchange.getFiatBalance("BTC")); + } + + @Test + public void getRatesTest() { + System.out.println("Buy rate: " + exchange.getExchangeRateForBuy("BTC", "USD")); + System.out.println("Sell rate: " + exchange.getExchangeRateForSell("BTC", "USD")); + System.out.println("Buy rate for 1 BTC: " + exchange.calculateBuyPrice("BTC", "USD", BigDecimal.ONE)); + System.out.println("Sell rate for 1 BTC: " + exchange.calculateSellPrice("BTC", "USD", BigDecimal.ONE)); + } + + + @Test + public void createOrderTest() throws InterruptedException { + ITask task = exchange.createPurchaseCoinsTask(BigDecimal.valueOf(0.01), "BTC", "USD", null); + task.onCreate(); + for (int i = 0; i < 10 && !task.isFinished(); i++) { + Thread.sleep(1000L); + task.onDoStep(); + } + assertNotNull(task.getResult()); + System.out.println("Task result: " + task.getResult()); + } + + +} diff --git a/server_extensions_template/build.gradle b/server_extensions_template/build.gradle new file mode 100644 index 000000000..32493ee0b --- /dev/null +++ b/server_extensions_template/build.gradle @@ -0,0 +1,25 @@ +plugins { + id("shared-build-conventions") + id("shared-repositories-ext-conventions") +} + +group = projectGroup +version = projectVersion + +jar { + archiveFileName = "myfirstextension.${archiveExtension.get()}" +} + +configurations { + artifactOnly +} + +artifacts { + artifactOnly jar +} + +dependencies { + implementation("org.slf4j:slf4j-api:1.7.28") + 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..446451dee --- /dev/null +++ b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyFirstExtension.java @@ -0,0 +1,25 @@ +package com.mygreatcompany.batm.server.extensions.myfirstextension; + +import com.generalbytes.batm.server.extensions.AbstractExtension; +import com.generalbytes.batm.server.extensions.IExtensionContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MyFirstExtension extends AbstractExtension { + + protected final Logger log = LoggerFactory.getLogger("batm.master.myextension"); + + + @Override + public String getName() { + return "My first extension"; + } + + + @Override + public void init(IExtensionContext ctx) { + super.init(ctx); + log.debug("MyFirst extension initialized. Adding listener"); + 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..274645f0c --- /dev/null +++ b/server_extensions_template/src/main/java/com/mygreatcompany/batm/server/extensions/myfirstextension/MyTransactionListener.java @@ -0,0 +1,31 @@ +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 org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; + +public class MyTransactionListener implements ITransactionListener { + private IExtensionContext ctx; + protected final Logger log = LoggerFactory.getLogger("batm.master.myextension"); + + + public MyTransactionListener(IExtensionContext ctx) { + this.ctx = ctx; + } + + @Override + public Map onTransactionCreated(ITransactionDetails transactionDetails) { + log.info("Bravo! Transaction has been created! Here are the details: = " + transactionDetails); + return null; + } + + @Override + public Map onTransactionUpdated(ITransactionDetails transactionDetails) { + log.info("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..1f15e385b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,8 @@ include ':server_extensions_api' include ':server_extensions_extra' include ':server_extensions_test' +include ':server_extensions_examples' +include ':server_extensions_template' include ':currencies' include ':batm_ssh_tunnel' include ':operators_sample_website'