Skip to content

Commit bbe0fac

Browse files
committed
feat: add client function
1 parent 9187e13 commit bbe0fac

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

backend/src/main/java/ch/xxx/aidoclibchat/adapter/client/TmdbRestClient.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import org.springframework.stereotype.Component;
1919
import org.springframework.web.client.RestClient;
2020

21+
import ch.xxx.aidoclibchat.domain.client.TmdbClient;
22+
2123
@Component
22-
public class TmdbRestClient {
24+
public class TmdbRestClient implements TmdbClient {
2325
private static final Logger LOG = LoggerFactory.getLogger(TmdbRestClient.class);
2426
private static final String BASE_URL = "https://api.themoviedb.org/3/";
2527
private final RestClient restClient;
@@ -29,16 +31,18 @@ public class TmdbRestClient {
2931
public TmdbRestClient(RestClient restClient) {
3032
this.restClient = restClient;
3133
}
32-
33-
public void searchMovie(String query) {
34-
var url = BASE_URL + "search/movie?query=" + query;
34+
35+
@Override
36+
public Response apply(Request request) {
37+
var url = BASE_URL + "search/movie?query=" + request.query();
3538
var response = restClient.get()
3639
.uri(url)
3740
.header("accept", "application/json")
3841
.header("Authorization", "Bearer "+this.apiKey)
3942
.retrieve()
4043
.body(String.class);
4144
LOG.info("Response from TMDB: {}", response);
45+
return new Response(response);
4246
}
4347

4448
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
4+
*/
5+
6+
package ch.xxx.aidoclibchat.domain.client;
7+
8+
import java.util.function.Function;
9+
10+
import org.springframework.ai.tool.annotation.ToolParam;
11+
12+
/**
13+
*
14+
* @author sven
15+
*/
16+
public interface TmdbClient extends Function<TmdbClient.Request, TmdbClient.Response> {
17+
18+
record Request(@ToolParam(description = "The movie title") String query) {
19+
}
20+
21+
record Response(String response) {
22+
}
23+
}

0 commit comments

Comments
 (0)