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

com.ksc.network.eip.model.transform.AllocateAddressRequestMarshaller Maven / Gradle / Ivy

There is a newer version: 2.1.8
Show newest version
package com.ksc.network.eip.model.transform;

import com.ksc.DefaultRequest;
import com.ksc.KscClientException;
import com.ksc.Request;
import com.ksc.http.HttpMethodName;
import com.ksc.network.eip.model.AllocateAddressRequest;
import com.ksc.transform.Marshaller;
import com.ksc.util.StringUtils;

/**
 * AllocateAddressRequest Marshaller
 */

public class AllocateAddressRequestMarshaller implements
        Marshaller, AllocateAddressRequest> {

    public Request marshall(
    		AllocateAddressRequest allocateAddressRequest) {

        if (allocateAddressRequest == null) {
            throw new KscClientException(
                    "Invalid argument passed to marshall(...)");
        }

        Request request = new DefaultRequest(
        		allocateAddressRequest, "eip");
        request.addParameter("Action", "AllocateAddress");
        String version = allocateAddressRequest.getVersion();
        if (StringUtils.isNullOrEmpty(version)) {
            version = "2016-03-04";
        }
        request.addParameter("Version", version);
        request.setHttpMethod(HttpMethodName.GET);

        if (!StringUtils.isNullOrEmpty(allocateAddressRequest.getLineId())) {
            request.addParameter("LineId", allocateAddressRequest.getLineId());
        }

        if (allocateAddressRequest.getBandWidth() != null) {
            request.addParameter("BandWidth", StringUtils
                    .fromInteger(allocateAddressRequest.getBandWidth()));
        }
        if (!StringUtils.isNullOrEmpty(allocateAddressRequest.getChargeType())) {
            request.addParameter("ChargeType", allocateAddressRequest.getChargeType());
        }
        if (allocateAddressRequest.getPurchaseTime() != null) {
            request.addParameter("PurchaseTime", StringUtils
                    .fromInteger(allocateAddressRequest.getPurchaseTime()));
        }
        
        return request;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy