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

es.iti.wakamiti.api.util.http.HttpClientInterface Maven / Gradle / Ivy

/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */
package es.iti.wakamiti.api.util.http;


import com.fasterxml.jackson.databind.JsonNode;

import java.net.http.HttpResponse;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;


public interface HttpClientInterface> {

    String AUTHORIZATION = "Authorization";

    @SuppressWarnings("unchecked")
    default SELF self() {
        return (SELF) this;
    }

    SELF queryParam(String name, Object value);

    default SELF queryParams(Map params) {
        params.forEach(this::queryParam);
        return self();
    }

    SELF pathParam(String name, Object value);

    default SELF pathParams(Map params) {
        params.forEach(this::pathParam);
        return self();
    }

    SELF header(String name, Object value);

    default SELF headers(Map params) {
        params.forEach(this::header);
        return self();
    }

    SELF body(String body);

    SELF basicAuth(String username, String password);

    SELF bearerAuth(String token);

    HttpResponse> post(String uri);

    HttpResponse> get(String uri);

    HttpResponse> delete(String uri);

    HttpResponse> put(String uri);

    HttpResponse> patch(String uri);

    HttpResponse> options(String uri);

    HttpResponse> head(String uri);

    HttpResponse> content(String uri);

    HttpResponse> trace(String uri);

    CompletableFuture>> postAsync(String uri);

    CompletableFuture>> getAsync(String uri);

    CompletableFuture>> deleteAsync(String uri);

    CompletableFuture>> putAsync(String uri);

    CompletableFuture>> patchAsync(String uri);

    CompletableFuture>> optionsAsync(String uri);

    CompletableFuture>> headAsync(String uri);

    CompletableFuture>> contentAsync(String uri);

    CompletableFuture>> traceAsync(String uri);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy