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

io.hcxprotocol.utils.HttpUtils Maven / Gradle / Ivy

Go to download

The SDK for HCX Participant System to help in integrating with HCX Gateway easily.

There is a newer version: 1.0.8
Show newest version
package io.hcxprotocol.utils;

import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import lombok.experimental.UtilityClass;

import java.util.Map;

/**
 * The REST API Util using Unirest library.
 */

@UtilityClass
public class HttpUtils {


    public static io.hcxprotocol.dto.HttpResponse post(String url, Map headers, String requestBody){
        headers.put("Content-Type","application/json");
        HttpResponse response = Unirest.post(url).headers(headers).body(requestBody).asString();
        return new io.hcxprotocol.dto.HttpResponse(response.getStatus(), response.getBody());
    }

    public static io.hcxprotocol.dto.HttpResponse post(String url, Map headers, Map fields) {
        HttpResponse response =  Unirest.post(url).headers(headers).fields(fields).asString();
        return new io.hcxprotocol.dto.HttpResponse(response.getStatus(), response.getBody());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy