aboutsummaryrefslogtreecommitdiff
path: root/utils/api/jikan/jikan.go
diff options
context:
space:
mode:
Diffstat (limited to 'utils/api/jikan/jikan.go')
-rw-r--r--utils/api/jikan/jikan.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/api/jikan/jikan.go b/utils/api/jikan/jikan.go
index 507130a..c5bb2c8 100644
--- a/utils/api/jikan/jikan.go
+++ b/utils/api/jikan/jikan.go
@@ -335,3 +335,22 @@ func GetCharacterByMALID(id int) (*types.JikanCharacterFullResponse, error) {
}
return &response, nil
}
+
+func GetPersonByMALID(id int) (*types.JikanPersonFullResponse, error) {
+ url := fmt.Sprintf("%s/people/%d/full", jikanAPIBaseURL, id)
+ ctx, cancel := context.WithTimeout(context.Background(), contextTimeout)
+ defer cancel()
+
+ bytes, err := clientInstance.makeRequest(ctx, url)
+ if err != nil {
+ logger.Errorf("JikanClient", "GetPersonByMALID failed for ID %d: %v", id, err)
+ return nil, errors.New("failed to fetch person data from Jikan API")
+ }
+
+ var response types.JikanPersonFullResponse
+ if err := json.Unmarshal(bytes, &response); err != nil {
+ logger.Errorf("JikanClient", "Failed to unmarshal person response for ID %d: %v", id, err)
+ return nil, errors.New("failed to parse person data from Jikan API")
+ }
+ return &response, nil
+}