io.hcxprotocol.utils.HttpUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hcx-integrator-sdk Show documentation
Show all versions of hcx-integrator-sdk Show documentation
The SDK for HCX Participant System to help in integrating with HCX Gateway easily.
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());
}
}