Add this in build.gradle
allprojects {
repositories {
maven {
url 'https://jitpack.io'
}
}
}
In dependencies add this line
implementation 'com.github.SergeyAvetisyan:ApiEasyRequest:{Last Version}'
Request is designed to be the simplest way possible to make http or https calls.
In first step you must init RequestManager by passing context and BASE_URL
RequestManager.init(this,"https://example.com");
Adding headers and params are optional. Params are HashMap<String,Object> ,headers are HashMap<String,String> , you just need add key and value and pass them to RequestManager
RequestManager.getInstance().doGetRequest(
"getNumbers/integers",
paramsMap,
headersMap,
new Response() {
@Override
public void onError(String s) {
}
@Override
public void onResponse(String s) {
}
}
);
"getNumbers/integers" is a path of your url.
After success or error it will call onResponse or onError function. You will receive response in String format and can easily parse it to JSON or other object.
You can do Post,Get requests super easy and also doing post request can choose between FormBody and JSON