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

com.global.api.terminals.diamond.DiamondCloudConfig Maven / Gradle / Ivy

There is a newer version: 14.2.3
Show newest version
package com.global.api.terminals.diamond;

import com.global.api.ConfiguredServices;
import com.global.api.entities.enums.ConnectionModes;
import com.global.api.entities.enums.Environment;
import com.global.api.entities.enums.Region;
import com.global.api.entities.enums.ServiceEndpoints;
import com.global.api.entities.exceptions.ConfigurationException;
import com.global.api.terminals.ConnectionConfig;
import com.global.api.utils.StringUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

@Accessors(chain = true)
@Getter @Setter
public class DiamondCloudConfig extends ConnectionConfig {
    private String statusUrl;
    private String isvID;
    private String secretKey;
    private String region;
    private String posID;

    @Override
    public void configureContainer(ConfiguredServices services) throws ConfigurationException {
        if (StringUtils.isNullOrEmpty(serviceUrl)) {
            serviceUrl = (environment == Environment.PRODUCTION)
                    ? (Region.EU.toString().equals(this.region != null ? this.region : "")
                    ? ServiceEndpoints.DIAMOND_CLOUD_PROD_EU.getValue()
                    : ServiceEndpoints.DIAMOND_CLOUD_PROD.getValue())
                    : ServiceEndpoints.DIAMOND_CLOUD_TEST.getValue();
        }
        this.region = this.region != null ? this.region : Region.US.toString();
        super.configureContainer(services);
    }

    @Override
    public void validate() throws ConfigurationException {
        super.validate();
        if (getConnectionMode() == ConnectionModes.DIAMOND_CLOUD) {
            if (StringUtils.isNullOrEmpty(isvID) || StringUtils.isNullOrEmpty(secretKey)) {
                throw new ConfigurationException("ISV ID and secretKey are required for " + ConnectionModes.DIAMOND_CLOUD);
            }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy