Updating movies in the background
Almost all of the building blocks involved with implementing background fetch are in place. All you need now is a way to fetch movies from the movie database using their remote ID instead of using the movie database search API.
To enable this way of querying movies, another fetch method is required on MovieDBHelper
. The simplest way to do this would be to copy and paste both the fetch and URL-building methods and adjust them to enable fetching movies by ID. While it might be the easiest way to go about this, it isn't the best idea. If you add another fetch method or require more flexibility later, you will be in trouble. It's much better to refactor the movie db helper so it's better suited to multiple types of requests.
Preparing the helper struct
To maintain a clear overview of the available API endpoints, you can add a nested enum to MovieDBHelper
. Doing this will make other parts of the code more readable, help to avoid errors, and abstract away code duplication...