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

com.banxa.model.request.GetRequest Maven / Gradle / Ivy

The newest version!
package com.banxa.model.request;

import java.util.Map;

public abstract class GetRequest implements Request {
    @Override
    public String getMethod() {
        return "GET";
    }

    @Override
    public String getPayload() {
        return null;
    }

    protected void addUriParam(Map params, String key, String value) {
        if (value != null) {
            params.put(key, value);
        }
    }

    protected void addUriParam(Map params, String key, Double value) {
        if (value != null) {
            params.put(key, value.toString());
        }
    }
    
    protected void addUriParam(Map params, String key, Integer value) {
        if (value != null) {
            params.put(key, value.toString());
        }
    }

    protected String appendUriParams(String uri, Map params) {
        String appender = "?";
        StringBuilder uriBuilder = new StringBuilder(uri);
        for (Map.Entry param : params.entrySet()) {
            uriBuilder.append(appender).append(param.getKey()).append("=").append(param.getValue());
            appender = "&";
        }
        return uriBuilder.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy