All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.hcxprotocol.dto.JSONRequest Maven / Gradle / Ivy

Go to download

The SDK for HCX Participant System to help in integrating with HCX Gateway easily.

There is a newer version: 1.0.8
Show newest version
package io.hcxprotocol.dto;

import io.hcxprotocol.exception.ErrorCodes;
import org.apache.commons.lang3.StringUtils;

import java.text.MessageFormat;
import java.util.Map;

import static io.hcxprotocol.utils.Constants.REDIRECT_TO;
import static io.hcxprotocol.utils.ResponseMessage.INVALID_REDIRECT_ERR_MSG;
import static io.hcxprotocol.utils.ResponseMessage.INVALID_REDIRECT_SELF_ERR_MSG;

/**
 * This is to handle json payload specific validations for error and redirect scenarios.
 */
public class JSONRequest extends BaseRequest {

    public JSONRequest(Map payload) throws Exception {
        super(payload);
    }

    public boolean validateRedirect(Map error) {
        if (validateCondition(StringUtils.isEmpty(getRedirectTo()), error, ErrorCodes.ERR_INVALID_REDIRECT_TO.toString(), MessageFormat.format(INVALID_REDIRECT_ERR_MSG, REDIRECT_TO)))
            return true;
        if (validateCondition(getHcxSenderCode().equalsIgnoreCase(getRedirectTo()), error, ErrorCodes.ERR_INVALID_REDIRECT_TO.toString(), INVALID_REDIRECT_SELF_ERR_MSG))
            return true;
        return false;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy