File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
backend/src/main/java/ch/xxx/aidoclibchat Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 18
18
import org .springframework .stereotype .Component ;
19
19
import org .springframework .web .client .RestClient ;
20
20
21
+ import ch .xxx .aidoclibchat .domain .client .TmdbClient ;
22
+
21
23
@ Component
22
- public class TmdbRestClient {
24
+ public class TmdbRestClient implements TmdbClient {
23
25
private static final Logger LOG = LoggerFactory .getLogger (TmdbRestClient .class );
24
26
private static final String BASE_URL = "https://api.themoviedb.org/3/" ;
25
27
private final RestClient restClient ;
@@ -29,16 +31,18 @@ public class TmdbRestClient {
29
31
public TmdbRestClient (RestClient restClient ) {
30
32
this .restClient = restClient ;
31
33
}
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 ();
35
38
var response = restClient .get ()
36
39
.uri (url )
37
40
.header ("accept" , "application/json" )
38
41
.header ("Authorization" , "Bearer " +this .apiKey )
39
42
.retrieve ()
40
43
.body (String .class );
41
44
LOG .info ("Response from TMDB: {}" , response );
45
+ return new Response (response );
42
46
}
43
47
44
48
}
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments