diff options
-rw-r--r-- | anime/anime.go | 10 | ||||
-rw-r--r-- | anime/client.go | 10 | ||||
-rw-r--r-- | anime/request_handler.go | 2 | ||||
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 2 | ||||
-rw-r--r-- | user/client.go | 2 | ||||
-rw-r--r-- | user/request_handler.go | 2 | ||||
-rw-r--r-- | user/user.go | 2 |
8 files changed, 12 insertions, 20 deletions
diff --git a/anime/anime.go b/anime/anime.go index 3330c16..01dbbb5 100644 --- a/anime/anime.go +++ b/anime/anime.go @@ -31,7 +31,7 @@ const BASE_URL string = "https://api.myanimelist.net/v2/anime" const maxAnimeLimit int = 500 // in MAL documentation this is named Get Anime List -func (c AnimeClient) SearchAnime(searchString string, limit, offset int, fields []string) (AnimeSearch, error) { +func (c Client) SearchAnime(searchString string, limit, offset int, fields []string) (AnimeSearch, error) { var searchResults AnimeSearch // error handling for limit and offset @@ -75,7 +75,7 @@ func (c AnimeClient) SearchAnime(searchString string, limit, offset int, fields } // Each anime has its own ID on MAL -func (c AnimeClient) GetAnimeById(animeId int, fields []string) (Anime, error) { +func (c Client) GetAnimeById(animeId int, fields []string) (Anime, error) { var anime Anime // handle all the errors for the fields @@ -101,7 +101,7 @@ func (c AnimeClient) GetAnimeById(animeId int, fields []string) (Anime, error) { } // Ranking is a list of anime sorted by their rank -func (c AnimeClient) GetAnimeRanking(rankingType string, limit, offset int, fields []string) (AnimeRanking, error) { +func (c Client) GetAnimeRanking(rankingType string, limit, offset int, fields []string) (AnimeRanking, error) { var animeRanking AnimeRanking // error handling for limit and offset @@ -158,7 +158,7 @@ func (c AnimeClient) GetAnimeRanking(rankingType string, limit, offset int, fiel } // get list of animes from specified season -func (c AnimeClient) GetSeasonalAnime(year, season, sort string, limit, offset int, fields []string) (SeasonalAnime, error) { +func (c Client) GetSeasonalAnime(year, season, sort string, limit, offset int, fields []string) (SeasonalAnime, error) { var seasonalAnime SeasonalAnime // error handling for limit and offset @@ -212,7 +212,7 @@ func (c AnimeClient) GetSeasonalAnime(year, season, sort string, limit, offset i } // get anime suggestions for the user -func (c AnimeClient) GetSuggestedAnime(limit, offset int, fields []string) (SuggestedAnime, error){ +func (c Client) GetSuggestedAnime(limit, offset int, fields []string) (SuggestedAnime, error){ var suggestedAnime SuggestedAnime // error handling for limit and offset diff --git a/anime/client.go b/anime/client.go index 25c71e1..e857df2 100644 --- a/anime/client.go +++ b/anime/client.go @@ -1,4 +1,4 @@ -/* mal2go - MyAnimeList V2 API wrapper for Go +/* MAL2Go - MyAnimeList V2 API wrapper for Go * Copyright (C) 2022 Vidhu Kant Sharma <vidhukant@protonmail.ch> * This program is free software: you can redistribute it and/or modify @@ -17,11 +17,7 @@ package anime import ( - "net/http" + "github.com/MikunoNaka/MAL2Go/util" ) -// MyAnimeList Client for mal2go/anime package -type AnimeClient struct { - AuthToken, RefreshToken string - HttpClient http.Client -} +type Client util.DefaultClient diff --git a/anime/request_handler.go b/anime/request_handler.go index fe4f874..00703bc 100644 --- a/anime/request_handler.go +++ b/anime/request_handler.go @@ -24,7 +24,7 @@ import ( // Handles HTTP request with your OAuth token as a Header // TODO: Verify that this function is safe to use -func (c AnimeClient) requestHandler(endpoint string) string { +func (c Client) requestHandler(endpoint string) string { // generate request req, err := http.NewRequest("GET", endpoint, nil) if err != nil { @@ -1,5 +1,3 @@ module github.com/MikunoNaka/MAL2Go go 1.17 - -require github.com/MikunoNaka/mal2go v0.0.0-20220213112712-541c75949e86 @@ -1,2 +0,0 @@ -github.com/MikunoNaka/mal2go v0.0.0-20220213112712-541c75949e86 h1:hpz3DsUPkaznnO3a1nZZTQeIll0yKTGGWKM0fxvnCxc= -github.com/MikunoNaka/mal2go v0.0.0-20220213112712-541c75949e86/go.mod h1:fKunJNVMPoiH/yahvQDy9cFdjRkL+w+DDzeOlL4lMEU= diff --git a/user/client.go b/user/client.go index 2cdc79c..8a1105e 100644 --- a/user/client.go +++ b/user/client.go @@ -20,4 +20,4 @@ import ( "github.com/MikunoNaka/MAL2Go/util" ) -type MALUserClient util.DefaultClient +type Client util.DefaultClient diff --git a/user/request_handler.go b/user/request_handler.go index da8c5f7..47a1699 100644 --- a/user/request_handler.go +++ b/user/request_handler.go @@ -23,7 +23,7 @@ import ( ) // Handles HTTP request with your OAuth token as a Header -func (c MALUserClient) requestHandler(endpoint string) string { +func (c Client) requestHandler(endpoint string) string { // generate request req, err := http.NewRequest("GET", endpoint, nil) if err != nil { diff --git a/user/user.go b/user/user.go index 31ac8dc..9c52150 100644 --- a/user/user.go +++ b/user/user.go @@ -23,7 +23,7 @@ import ( const BASE_URL string = "https://api.myanimelist.net/v2/users" // Get info of logged in user -func (c *MALUserClient) GetSelfUserInfo() UserInfo { +func (c Client) GetSelfUserInfo() UserInfo { /* MAL only supports @me for this */ endpoint := BASE_URL + "/@me?fields=anime_statistics" |