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

de.adorsys.multibanking.ing.http.RequestBuilderImpl Maven / Gradle / Ivy

There is a newer version: 5.5.34
Show newest version
package de.adorsys.multibanking.ing.http;

import de.adorsys.multibanking.ing.model.Response;

import java.util.LinkedHashMap;
import java.util.Map;

public class RequestBuilderImpl implements Request.Builder {
    private final HttpClient httpClient;
    private String method;
    private String uri;
    private Map headers = new LinkedHashMap<>();
    private String body;
    private boolean emptyBody;
    private Map formData;

    RequestBuilderImpl(HttpClient httpClient, String method, String uri) {
        this.httpClient = httpClient;
        this.method = method;
        this.uri = uri;
    }

    @Override
    public String method() {
        return method;
    }

    @Override
    public String uri() {
        return uri;
    }

    @Override
    public Request.Builder headers(Map headers) {
        this.headers = headers;
        return this;
    }

    @Override
    public Map headers() {
        return headers;
    }

    @Override
    public Request.Builder header(String name, String value) {
        headers.put(name, value);
        return this;
    }

    @Override
    public Request.Builder jsonBody(String body) {
        this.body = body;
        return this;
    }

    @Override
    public String jsonBody() {
        return body;
    }

    @Override
    public Request.Builder emptyBody(boolean emptyBody) {
        this.emptyBody = emptyBody;
        return this;
    }

    @Override
    public boolean emptyBody() {
        return emptyBody;
    }

    @Override
    public Request.Builder urlEncodedBody(Map formData) {
        this.formData = formData;
        return this;
    }

    @Override
    public Map urlEncodedBody() {
        return formData;
    }

    @Override
    public  Response send(Interceptor interceptor, HttpClient.ResponseHandler responseHandler) {
        return httpClient.send(interceptor != null ? interceptor.apply(this) : this, responseHandler);
    }

    @Override
    public String content() {
        return httpClient.content(this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy