io.electrum.suv.api.models.ErrorDetail Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of suv-service-interface Show documentation
Show all versions of suv-service-interface Show documentation
Single Use Voucher Service Interface
package io.electrum.suv.api.models;
import java.util.Objects;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.electrum.vas.Utils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* Represents the reasons an operation has failed.
*/
@ApiModel(description = "Represents the reasons an operation has failed.")
public class ErrorDetail {
private String id = null;
private String originalId = null;
private ErrorType errorType = null;
private String errorMessage = null;
private String providerErrorCode = null;
private String providerErrorMessage = null;
private Object detailMessage = null;
public ErrorDetail id(String id) {
this.id = id;
return this;
}
/**
* The randomly generated UUID identifying this errorDetail, as defined for a variant 4 UUID in [RFC
* 4122](https://tools.ietf.org/html/rfc4122)
*
* @return id
**/
@JsonProperty("id")
@ApiModelProperty(required = true, value = "The randomly generated UUID identifying the message which caused the ErrorDetail, as defined for a variant 4 UUID in [RFC 4122](https://tools.ietf.org/html/rfc4122)")
@NotNull
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public ErrorDetail originalId(String originalId) {
this.originalId = originalId;
return this;
}
/**
* The UUID of the original request message in the case of an error occurring for an advice message
*
* @return originalId
**/
@JsonProperty("originalId")
@ApiModelProperty(value = "The UUID of the original request message in the case of an error occurring for an advice message")
public String getOriginalId() {
return originalId;
}
public void setOriginalId(String originalId) {
this.originalId = originalId;
}
public ErrorDetail errorType(ErrorType errorType) {
this.errorType = errorType;
return this;
}
/**
* The type of error that occurred
*
* @return errorType
**/
@JsonProperty("errorType")
@ApiModelProperty(required = true, value = "The type of error that occurred")
@NotNull
public ErrorType getErrorType() {
return errorType;
}
public void setErrorType(ErrorType errorType) {
this.errorType = errorType;
}
public ErrorDetail errorMessage(String errorMessage) {
this.errorMessage = errorMessage;
return this;
}
/**
* A short description of the error
*
* @return errorMessage
**/
@JsonProperty("errorMessage")
@ApiModelProperty(required = true, value = "A short description of the error")
@NotNull
@Size(min = 0, max = 80)
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public ErrorDetail providerErrorCode(String providerErrorCode) {
this.providerErrorCode = providerErrorCode;
return this;
}
/**
* The response code received from the voucher vendor in response to an operation.
*
* @return providerErrorCode
**/
@JsonProperty("providerErrorCode")
@ApiModelProperty(value = "The response code received from the voucher vendor in response to an operation.")
public String getProviderErrorCode() {
return providerErrorCode;
}
public void setProviderErrorCode(String providerErrorCode) {
this.providerErrorCode = providerErrorCode;
}
public ErrorDetail providerErrorMessage(String providerErrorMessage) {
this.providerErrorMessage = providerErrorMessage;
return this;
}
/**
* The error message received from the voucher vendor in response to an operation.
*
* @return providerErrorMessage
**/
@JsonProperty("providerErrorMessage")
@ApiModelProperty(value = "The error message received from the voucher vendor in response to an operation.")
public String getProviderErrorMessage() {
return providerErrorMessage;
}
public void setProviderErrorMessage(String providerErrorMessage) {
this.providerErrorMessage = providerErrorMessage;
}
public ErrorDetail detailMessage(Object detailMessage) {
this.detailMessage = detailMessage;
return this;
}
/**
* A free form detailed description of a particular failure condition may optionally be supplied
*
* @return detailMessage
**/
@JsonProperty("detailMessage")
@ApiModelProperty(value = "A free form detailed description of a particular failure condition may optionally be "
+ "supplied")
public Object getDetailMessage() {
return detailMessage;
}
public void setDetailMessage(Object detailMessage) {
this.detailMessage = detailMessage;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ErrorDetail errorDetail = (ErrorDetail) o;
return Objects.equals(this.id, errorDetail.id) && Objects.equals(this.originalId, errorDetail.originalId)
&& Objects.equals(this.errorType, errorDetail.errorType)
&& Objects.equals(this.errorMessage, errorDetail.errorMessage)
&& Objects.equals(this.providerErrorCode, errorDetail.providerErrorCode)
&& Objects.equals(this.providerErrorMessage, errorDetail.providerErrorMessage)
&& Objects.equals(this.detailMessage, errorDetail.detailMessage);
}
@Override
public int hashCode() {
return Objects
.hash(id, originalId, errorType, errorMessage, providerErrorCode, providerErrorMessage, detailMessage);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ErrorDetail {\n");
sb.append(" id: ").append(Utils.toIndentedString(id)).append("\n");
sb.append(" originalId: ").append(Utils.toIndentedString(originalId)).append("\n");
sb.append(" errorType: ").append(Utils.toIndentedString(errorType)).append("\n");
sb.append(" errorMessage: ").append(Utils.toIndentedString(errorMessage)).append("\n");
sb.append(" providerErrorCode: ").append(Utils.toIndentedString(providerErrorCode)).append("\n");
sb.append(" providerErrorMessage: ").append(Utils.toIndentedString(providerErrorMessage)).append("\n");
sb.append(" detailMessage: ").append(Utils.toIndentedString(detailMessage)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* The type of error that occurred
*/
public enum ErrorType {
DUPLICATE_RECORD("DUPLICATE_RECORD"),
FORMAT_ERROR("FORMAT_ERROR"),
FUNCTION_NOT_SUPPORTED("FUNCTION_NOT_SUPPORTED"),
GENERAL_ERROR("GENERAL_ERROR"),
INVALID_AMOUNT("INVALID_AMOUNT"),
ROUTING_ERROR("ROUTING_ERROR"),
TRANSACTION_NOT_SUPPORTED("TRANSACTION_NOT_SUPPORTED"),
UNABLE_TO_LOCATE_RECORD("UNABLE_TO_LOCATE_RECORD"),
UPSTREAM_UNAVAILABLE("UPSTREAM_UNAVAILABLE"),
VOUCHER_ALREADY_REDEEMED("VOUCHER_ALREADY_REDEEMED"),
VOUCHER_ALREADY_PROVISIONED("VOUCHER_ALREADY_PROVISIONED"),
VOUCHER_NOT_REDEEMABLE("VOUCHER_NOT_REDEEMABLE"),
INVALID_MERCHANT("INVALID_MERCHANT"),
INVALID_VOUCHER("INVALID_VOUCHER"),
AUTHENTICATION_ERROR("AUTHENTICATION_ERROR");
private String value;
ErrorType(String value) {
this.value = value;
}
@JsonCreator
public static ErrorType fromValue(String text) {
for (ErrorType b : ErrorType.values()) {
if (String.valueOf(b.value).equals(text)) {
return b;
}
}
return null;
}
@Override
@JsonValue
public String toString() {
return String.valueOf(value);
}
}
}