Closed ryaustin closed 3 months ago
From a class design perspective, do you forsee any issues calling your endpoints from the movieapi class? You might create one function to manage all calls using requests.
Imagine the MovieAPIUtils is the official python SDK to interact with TMDB. What key design decisions would make that would make your tool enjoyable to use.
I am blocked on this issue. I understand what you mean by the context provided, however, based on your second comment you seem to be suggesting I use a single function to manage all calls.
Based on this information, I take it that:
But I'm finding myself needing direction with:
Hey Kevin, were we able to address this adequately enough during our session yesterday to move forward? As a review:
Class
CONSTANTS
...
def init
...
self.authenticate
def authenticate
# place any logic around authentication and potential errors/ exceptions here
def get(url, params/kwargs)
#any exception handling around get requests occur in this function
response = requests.get(url, params, self.header)
# check the response status, is it a 200? does it have json?, are there errors?
return response
def movies_currently_playing(*args, **kwargs)
url=f"{self.BASE_URL}/specific_endpoint"
#pass kwargs directly to the get function or for more robustness perform any transformations, cleanup on the kwargs then pass on in a dict called params. This may not be necessary so is up to you.
params={} #add any specific params here
return self.get(url, params)
def other_endpoint(*args, **kwargs)
#same pattern as above
return self.get(url, params)
In a nutshell, all of the work to consume various endpoints happens in the class. This pattern puts most of your effort in the class. In your view, you will most likely define the class in the global scope and call the endpoints in your context functions and passing in any specific params required by the individual functions.
_Originally posted by @ryaustin in https://github.com/kjcioffi/django-movies/pull/14#discussion_r1633923512_