You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CleverClient is a Java 11+ library that makes it easy to use the standard [HttpClient](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html)component to call http services by using annotated interfaces.
26
+
CleverClient is a Java library that simplifies requesting client-side Http services using annotated interfaces and methods. CleverClient uses behind the scenes the well-known Http client libraries: [Java's HttpClient](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html)(by default) or [Square's OkHttp](https://square.github.io/okhttp/).
26
27
27
28
For example, if we want to use the public API [JsonPlaceHolder](https://jsonplaceholder.typicode.com/) and call its endpoint ```/posts```, we just have to create an entity ```Post```, an interface ```PostService``` with special annotatons, and call the API through ```CleverClient```:
28
29
@@ -54,7 +55,7 @@ public interface PostService {
54
55
55
56
// Use CleverClient to call the API
56
57
var cleverClient =CleverClient.builder()
57
-
.baseUrl("https://jsonplaceholder.typicode.com/")
58
+
.baseUrl("https://jsonplaceholder.typicode.com")
58
59
.build();
59
60
60
61
var postService = cleverClient.create(PostService.class);
@@ -83,21 +84,28 @@ System.out.println(newPost);
83
84
84
85
## ⚙ Installation
85
86
86
-
You can install CleverClient by adding the following dependency to your Maven project:
87
-
87
+
You can install CleverClient by adding the following dependencies to your Maven project:
88
88
```xml
89
89
<dependency>
90
90
<groupId>io.github.sashirestela</groupId>
91
91
<artifactId>cleverclient</artifactId>
92
-
<version>[latest version]</version>
92
+
<version>[cleverclient_latest_version]</version>
93
+
</dependency>
94
+
<!-- OkHttp dependency is optional if you decide to use it with CleverClient -->
With CleverClient you have two Http client alternatives: Java's HttpClient or OkHttp. The Builder attribute ```clientAdapter``` is used to indicate which to use. If you don't indicate any Http client, the Java's HttpClient will be used by default:
@@ -337,12 +363,9 @@ Some examples have been created in the folder [example](https://github.com/sashi
337
363
338
364
Where:
339
365
340
-
*```<className>``` is mandatory and must be one of the values:
341
-
* BasicExample
342
-
* FileDownloadExample
343
-
* HeaderExample
344
-
* MultiServiceExample
345
-
* StreamExample (This requires you have an OpenAI account and set the env variable OPENAI_API_TOKEN)
366
+
*```<className>``` is mandatory and must be one of the Java files in the folder example: BasicExample, BasicExampleOkHttp, StreamExample, StreamExampleOkHttp, etc.
367
+
368
+
Some examples require you have an OpenAI account and set the env variable OPENAI_API_TOKEN, such as Multipart*, Stream*.
346
369
347
370
*```[logOptions]``` are optional and you can you use them to set:
0 commit comments