Rest handlers example
In this article, you will learn how to apply parameters to a REST DataDescriptor, as well as how to use one. In this example, a public Rest API will be used. This is the Open Movie Database ( https://www.omdbapi.com/ ). It is a free, public movie database. You can search for movies by their title. It also stores details about the movies, such as the cast, the IMDB rating, etc.
To start, you must request a free API key here: https://www.omdbapi.com/apikey.aspx After filling out the form, you will recieve your API key shortly. This key can be tested in your browser: https://www.omdbapi.com/?apikey=<YOUR PERSONAL APIKEY>&s=Heaven
This will return the first 10 movies from the database, that have "Heaven" in their title.
In this article, we will use two Rest services, one for movie searching, and one for downloading the details about the selected movie.
We will use the following two DataDescriptors:
How to access the parameters specified in the DataDescriptor (this will be needed when implementing the handler classes):
You can find the parameters that can be specified and queried in the RestParams enum
We have specified the handler classes in the DataDescriptors. These implement the filtering, pagination (page fetching), and processing of the response. The handler classes only need to be specified and implemented, if the Rest service supports the specified functions. For example, if the Rest server does not support the Order operation, you do not have to specify the orderHandler. The responseHandler does not need to be specified, if the response is a standard JSON in a JSON array.
Here, neither response is a JSON array, so the responseHandler must be implemented.