
io.sphere.sdk.requests.HttpRequest Maven / Gradle / Ivy
package io.sphere.sdk.requests;
import java.util.Optional;
import net.jcip.annotations.Immutable;
@Immutable
public class HttpRequest implements Requestable {
private final HttpMethod httpMethod;
private final String path;
private final Optional body;
private HttpRequest(final HttpMethod httpMethod, final String path) {
this(httpMethod, path, Optional.empty());
}
private HttpRequest(final HttpMethod httpMethod, final String path, final Optional body) {
this.httpMethod = httpMethod;
this.path = path;
this.body = body;
}
public static HttpRequest of(final HttpMethod httpMethod, final String path) {
return new HttpRequest(httpMethod, path);
}
public static HttpRequest of(final HttpMethod httpMethod, final String path, final String body) {
return new HttpRequest(httpMethod, path, Optional.of(body));
}
public HttpMethod getHttpMethod() {
return httpMethod;
}
public String getPath() {
return path;
}
public Optional getBody() {
return body;
}
@Override
public HttpRequest httpRequest() {
return this;
}
@Override
public String toString() {
return "HttpRequest{" +
"httpMethod=" + httpMethod +
", path='" + path + '\'' +
", body=" + body +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy