Class OkHttpApiClient
- java.lang.Object
-
- cz.diribet.chystat.api.client.impl.OkHttpApiClient
-
- All Implemented Interfaces:
IApiClient
- Direct Known Subclasses:
ChystatApiClient
public class OkHttpApiClient extends Object implements IApiClient
-
-
Field Summary
Fields Modifier and Type Field Description static okhttp3.MediaTypeJSON
-
Constructor Summary
Constructors Constructor Description OkHttpApiClient(String baseUrl, @NonNull com.google.gson.Gson gson)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected okhttp3.OkHttpClient.BuilderclientBuilder()ResponsePayloaddelete(String path)Executes DELETE request and returns response if the request was successful [200..300).ResponsePayloadget(String path)Executes GET request and returns response if the request was successful [200..300).ResponsePayloadpatch(String path, Object payload)Executes PATCH request and returns response if the request was successful [200..300).ResponsePayloadpost(String path, Object payload)Executes POST request and returns response if the request was successful [200..300).ResponsePayloadput(String path, Object payload)Executes PUT request and returns response if the request was successful [200..300).protected okhttp3.Request.BuilderrequestBuilder(String path)
-
-
-
Constructor Detail
-
OkHttpApiClient
public OkHttpApiClient(String baseUrl, @NonNull @NonNull com.google.gson.Gson gson)
-
-
Method Detail
-
get
public ResponsePayload get(String path) throws IOException, InvalidResponseException
Description copied from interface:IApiClientExecutes GET request and returns response if the request was successful [200..300).- Specified by:
getin interfaceIApiClient- Returns:
- Throws:
IOException- if there was some problem during request executionInvalidResponseException- if the response code was different to [200..300)
-
post
public ResponsePayload post(String path, Object payload) throws IOException, InvalidResponseException
Description copied from interface:IApiClientExecutes POST request and returns response if the request was successful [200..300).- Specified by:
postin interfaceIApiClient- Returns:
- Throws:
IOException- if there was some problem during request executionInvalidResponseException- if the response code was different to [200..300)
-
put
public ResponsePayload put(String path, Object payload) throws IOException, InvalidResponseException
Description copied from interface:IApiClientExecutes PUT request and returns response if the request was successful [200..300).- Specified by:
putin interfaceIApiClient- Returns:
- Throws:
IOException- if there was some problem during request executionInvalidResponseException- if the response code was different to [200..300)
-
patch
public ResponsePayload patch(String path, Object payload) throws IOException, InvalidResponseException
Description copied from interface:IApiClientExecutes PATCH request and returns response if the request was successful [200..300).- Specified by:
patchin interfaceIApiClient- Returns:
- Throws:
IOException- if there was some problem during request executionInvalidResponseException- if the response code was different to [200..300)
-
delete
public ResponsePayload delete(String path) throws IOException, InvalidResponseException
Description copied from interface:IApiClientExecutes DELETE request and returns response if the request was successful [200..300).- Specified by:
deletein interfaceIApiClient- Returns:
- Throws:
IOException- if there was some problem during request executionInvalidResponseException- if the response code was different to [200..300)
-
requestBuilder
protected okhttp3.Request.Builder requestBuilder(String path)
-
clientBuilder
protected okhttp3.OkHttpClient.Builder clientBuilder()
-
-