Skip to content

Commit f997dcc

Browse files
committed
feat: add dtos
1 parent bbe0fac commit f997dcc

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public Response apply(Request request) {
4040
.header("accept", "application/json")
4141
.header("Authorization", "Bearer "+this.apiKey)
4242
.retrieve()
43-
.body(String.class);
43+
.body(Response.class);
4444
LOG.info("Response from TMDB: {}", response);
45-
return new Response(response);
45+
return response;
4646
}
4747

4848
}

backend/src/main/java/ch/xxx/aidoclibchat/domain/client/TmdbClient.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package ch.xxx.aidoclibchat.domain.client;
77

8+
import java.util.Map;
89
import java.util.function.Function;
910

1011
import org.springframework.ai.tool.annotation.ToolParam;
@@ -14,10 +15,34 @@
1415
* @author sven
1516
*/
1617
public interface TmdbClient extends Function<TmdbClient.Request, TmdbClient.Response> {
18+
public static final Map<Integer, String> GENRE_MAP = Map.ofEntries(
19+
Map.entry(28, "Action"),
20+
Map.entry(12, "Adventure"),
21+
Map.entry(16, "Animation"),
22+
Map.entry(35, "Comedy"),
23+
Map.entry(80, "Crime"),
24+
Map.entry(99, "Documentary"),
25+
Map.entry(18, "Drama"),
26+
Map.entry(10751, "Family"),
27+
Map.entry(14, "Fantasy"),
28+
Map.entry(36, "History"),
29+
Map.entry(27, "Horror"),
30+
Map.entry(10402, "Music"),
31+
Map.entry(9648, "Mystery"),
32+
Map.entry(10749, "Romance"),
33+
Map.entry(878, "Science Fiction"),
34+
Map.entry(10770, "TV Movie"),
35+
Map.entry(53, "Thriller"),
36+
Map.entry(10752, "War"),
37+
Map.entry(37, "Western")
38+
);
1739

1840
record Request(@ToolParam(description = "The movie title") String query) {
1941
}
2042

21-
record Response(String response) {
22-
}
43+
record Response(Integer page, Integer total_pages, Integer total_results, Movie[] results) { }
44+
45+
record Movie(boolean adult, String backdrop_path, Integer[] genere_ids, Long id, String original_language,
46+
String original_title, String overview, Double popularity, String poster_path, String release_date, String title,
47+
boolean video, Double vote_average, Integer vote_count) { }
2348
}

0 commit comments

Comments
 (0)