I'm kinda new to this "pattern" thing so I made up a repository to help me to consume and test an API in python. Then I showed it to a friend who said it wasn't a repository pattern but an adapter. Once he is an older and better programmer than me I can't argue against, also I have no clue what is the difference between both.
So, here is the code (I'm very proud about this one)
# imports
from repository.utils import factory_getter
from typing import Union
# return objects containing lists of animes
class Animes(object):
# get anime list for a given days of the week
def get_day_schedule(self, day: str):
return factory_getter("schedule", day)
# return a object containing a list of animes airing in the current day
def get_today_schedule(self):
return factory_getter("schedule")
# get anime list for a given year and season
def get_early_season(self, season: Union[str, int], year: Union[str, int]):
return factory_getter("season", str(season), str(year))
# get animes airing in the current season
def get_current_season(self):
return factory_getter("season")
# get animes that have been announced for the upcoming seasons
def get_later_season(self):
return factory_getter("season", "later")
# get the best rated animes of the season
def get_top_airing(self, page: Union[str, int] = 1):
return factory_getter("top", "anime", str(page), "airing")
# get the best rated movies
def get_top_movies(self, page: Union[str, int] = 1):
return factory_getter("top", "anime", str(page), "airing")
# get animes of a certain genre
def get_genre(self, genre, page: Union[str, int] = 1):
return factory_getter("genre", "anime", str(genre), str(page))
That's it.
I would also be very grateful if you could direct me to some study material. Thanks
Aucun commentaire:
Enregistrer un commentaire