From f1a83e9b5cf1931adcdccef9db4586eeab987700 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Thu, 17 Feb 2022 21:55:42 +0530 Subject: actually fixed all the errors with broken imports and clients --- anime/anime.go | 10 +++++----- anime/client.go | 10 +++------- anime/request_handler.go | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) (limited to 'anime') 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 * 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 { -- cgit v1.2.3