Skip to content

Commit

Permalink
Sync changes from 1.3.0 to master
Browse files Browse the repository at this point in the history
  • Loading branch information
filipocelka authored Jan 10, 2024
2 parents d638fa4 + 94e20c4 commit a7bc6cc
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# buildscript - project id
projectGroup=com.generalbytes.batm.public
projectVersion=1.4.0
projectVersion=1.4.1

# buildscript - common dependency versions
bitrafaelVersion=1.0.44
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
* Australia province identifiers.
* <p>
* Usage e.g.:
* CountryAustralia.AU-NSW.getProvinceName()
* CountryAustralia.valueOf("AU-NSW").getProvinceName()
* CountryAustralia.NSW.getProvinceName()
* CountryAustralia.valueOf("NSW").getProvinceName()
*/
public enum CountryAustralia {

AU_NSW("AU-NSW", "New South Wales"),
AU_QLD("AU-QLD", "Queensland"),
AU_SA("AU-SA", "South Australia"),
AU_TAS("AU-TAS", "Tasmania"),
AU_VIC("AU-VIC", "Victoria"),
AU_WA("AU-WA", "Western Australia"),
AU_ACT("AU-ACT", "Australian Capital Territory"),
AU_NT("AU-NT", "Northern Territory");
NSW("NSW", "New South Wales"),
QLD("QLD", "Queensland"),
SA("SA", "South Australia"),
TAS("TAS", "Tasmania"),
VIC("VIC", "Victoria"),
WA("WA", "Western Australia"),
ACT("ACT", "Australian Capital Territory"),
NT("NT", "Northern Territory");

private final String iso;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ default ITransactionPreparation overrideTransactionPreparation(ITransactionPrepa
return preparation;
}

/**
* Allows the operator to override following values in {@link ITransactionRequest}.
* <ul>
* <li>cryptoAmount</li>
* </ul>
* This method is called for both BUY and SELL transactions.
*
* @param request The transaction request initialized by server
* @return {@link ITransactionRequest} that may contain modified transaction request.
*/
default ITransactionRequest overrideTransactionRequest(ITransactionRequest request) {
return request;
}

/**
* Callback method that is called by server before transaction is executed - however the cash is already inserted in machine in case of buy transaction.
* If your method returns false than transaction will not take place and will fail with error ERROR_NOT_APPROVED.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*************************************************************************************
* Copyright (C) 2014-2020 GENERAL BYTES s.r.o. All rights reserved.
* Copyright (C) 2014-2024 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
Expand All @@ -18,8 +18,11 @@

package com.generalbytes.batm.server.extensions;

import com.generalbytes.batm.server.extensions.quiz.QuizResult;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface ITransactionPreparation {
Expand Down Expand Up @@ -201,5 +204,11 @@ public interface ITransactionPreparation {
*/
void setWithdrawalReason(int reason);

/**
* Returns quiz results if any quiz has been activated.
*
* @return List of {@link QuizResult}. Can be null.
*/
List<QuizResult> getQuizResults();

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
************************************************************************************/
package com.generalbytes.batm.server.extensions;

import com.generalbytes.batm.server.extensions.quiz.QuizResult;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public interface ITransactionRequest {

Expand Down Expand Up @@ -156,8 +159,11 @@ public interface ITransactionRequest {
*/
BigDecimal getDiscountQuotient();




/**
* Returns quiz results if any quiz has been activated.
*
* @return List of {@link QuizResult}. Can be null.
*/
List<QuizResult> getQuizResults();

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.generalbytes.batm.server.extensions.customfields.value.ChoiceCustomFieldValue;
import com.generalbytes.batm.server.extensions.customfields.value.CustomFieldValue;
import com.generalbytes.batm.server.extensions.customfields.value.FileCustomFieldValue;
import com.generalbytes.batm.server.extensions.customfields.value.LocalDateCustomFieldValue;
import com.generalbytes.batm.server.extensions.customfields.value.StringCustomFieldValue;

/**
Expand Down Expand Up @@ -39,7 +40,12 @@ public enum CustomFieldDefinitionType {
/**
* Document scan or other file
*/
DOCUMENT(FileCustomFieldValue.class);
DOCUMENT(FileCustomFieldValue.class),
/**
* A date value.
* Presented as date picker.
*/
DATE(LocalDateCustomFieldValue.class);

private final Class<? extends CustomFieldValue> allowedValueType;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.generalbytes.batm.server.extensions.customfields.value;

import com.generalbytes.batm.server.extensions.customfields.CustomFieldDefinitionType;

import java.time.LocalDate;

/**
* used with {@link CustomFieldDefinitionType#DATE}
*/
public class LocalDateCustomFieldValue implements CustomFieldValue {
private final LocalDate localDateValue;

public LocalDateCustomFieldValue(LocalDate localDateValue) {
this.localDateValue = localDateValue;
}

public LocalDate getLocalDateValue() {
return localDateValue;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*************************************************************************************
* 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.quiz;

import com.generalbytes.batm.server.extensions.customfields.CustomFieldDefinition;
import com.generalbytes.batm.server.extensions.customfields.CustomFieldDefinitionType;

/**
* An object representing the question and answer data in the {@link QuizResult}.
*/
public class QuestionAnswer {

/**
* ID of {@link CustomFieldDefinition} representing a question.
* May be null if the Custom Field has been deleted on the server.
*/
private Long customFieldDefinitionId;

private String question;

/**
* ID of {@link CustomFieldDefinition.Element} representing an answer for a type {@link CustomFieldDefinitionType#DROPDOWN} and {@link CustomFieldDefinitionType#RADIO_BTN}.
* May be null if it is not one of the above types or if the Custom Field Element has been deleted on the server.
*/
private Long customFieldElementId;

private String answer;

public QuestionAnswer() {

}

public QuestionAnswer(Long customFieldDefinitionId, String question, Long customFieldElementId, String answer) {
this.customFieldDefinitionId = customFieldDefinitionId;
this.question = question;
this.customFieldElementId = customFieldElementId;
this.answer = answer;
}

public Long getCustomFieldDefinitionId() {
return customFieldDefinitionId;
}

public void setCustomFieldDefinitionId(Long customFieldDefinitionId) {
this.customFieldDefinitionId = customFieldDefinitionId;
}

public String getQuestion() {
return question;
}

public void setQuestion(String question) {
this.question = question;
}

public Long getCustomFieldElementId() {
return customFieldElementId;
}

public void setCustomFieldElementId(Long customFieldElementId) {
this.customFieldElementId = customFieldElementId;
}

public String getAnswer() {
return answer;
}

public void setAnswer(String answer) {
this.answer = answer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*************************************************************************************
* 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.quiz;

import java.util.List;

/**
* An object representing data about quiz result.
*/
public class QuizResult {

private String quizName;

private List<QuestionAnswer> answers;

public QuizResult() {

}

public QuizResult(String quizName, List<QuestionAnswer> answers) {
this.quizName = quizName;
this.answers = answers;
}

public String getQuizName() {
return quizName;
}

public void setQuizName(String quizName) {
this.quizName = quizName;
}

public List<QuestionAnswer> getAnswers() {
return answers;
}

public void setAnswers(List<QuestionAnswer> answers) {
this.answers = answers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public void isValueTypeAllowed() {
assertFalse(CustomFieldDefinitionType.CHECKBOX.isValueTypeAllowed(str.getClass()));
assertFalse(CustomFieldDefinitionType.IMAGE.isValueTypeAllowed(str.getClass()));
assertFalse(CustomFieldDefinitionType.DOCUMENT.isValueTypeAllowed(str.getClass()));
assertFalse(CustomFieldDefinitionType.DATE.isValueTypeAllowed(str.getClass()));
}
}

0 comments on commit a7bc6cc

Please sign in to comment.