Package com.GameOfThronesClient
Class GameOfThronesClient
java.lang.Object
com.GameOfThronesClient.GameOfThronesClient
public class GameOfThronesClient
extends java.lang.Object
Wraps around of the Game of Thrones API.
Has a wrapper for every single endpoint of the API.
-
Method Summary
Modifier and Type Method Description java.util.List<Book>getAllBooks()Returns all books.java.util.List<Character>getAllCharacters()Returns all characters.java.util.List<House>getAllHouses()Returns all houses.BookgetBook(int id)Returns a Book with the given id.java.util.List<Book>getBooksByPage(int page, int pageSize)Returns a list of Books from the given page and page size.CharactergetCharacter(int id)Returns a Character with the given id.java.util.List<Character>getCharactersByPage(java.lang.Integer page, java.lang.Integer pageSize)Returns a list of Characters from the given page and page size.static GameOfThronesClientgetClient()Gets the GameOfThronesClient object to start making calls.static GameOfThronesClientgetClientWithCache(java.io.File cacheFile, int cacheSize)Gets the GameOfThronesClient object with caching enabled.HousegetHouse(int id)Returns a House with the given id.java.util.List<House>getHousesByPage(java.lang.Integer page, java.lang.Integer pageSize)Returns a list of Houses from the given page and page size.java.util.List<Book>searchBooks(java.lang.String name, java.lang.String fromReleasedDate, java.lang.String toReleasedDate)Returns a list of Books from the given query parameters.java.util.List<Character>searchCharacters(java.lang.String name, java.lang.String gender, java.lang.String culture, java.lang.String born, java.lang.String died, java.lang.Boolean isAlive)Returns a list of Characters from the given query parameters.java.util.List<House>searchHouses(java.lang.String name, java.lang.String region, java.lang.String words, java.lang.Boolean hasWords, java.lang.Boolean hasTitles, java.lang.Boolean hasSeats, java.lang.Boolean hasDiedOut, java.lang.Boolean hasAncestralWeapons)Returns a list of Houses from the given query parameters.
-
Method Details
-
getClient
Gets the GameOfThronesClient object to start making calls.- Returns:
- the GameOfThronesClient object
-
getClientWithCache
Gets the GameOfThronesClient object with caching enabled. Any single call made with this client will always try to use a cache first. If not found within the cache, reach out to the API and store in the cache for next time.- Parameters:
cacheFile- the path to the cache filecacheSize- the size of the cache- Returns:
- the GameOfTHronesClient object
-
getAllBooks
Returns all books.- Returns:
- a list of Book objects
- Throws:
java.io.IOException
-
getAllCharacters
Returns all characters.- Returns:
- a list of Character objects
- Throws:
java.io.IOException
-
getAllHouses
Returns all houses.- Returns:
- a list of House objects
- Throws:
java.io.IOException
-
getBook
Returns a Book with the given id.- Parameters:
id- the id the book- Returns:
- a Book object, returns nothing if a given book does not exist with that id
- Throws:
java.io.IOException
-
getCharacter
Returns a Character with the given id.- Parameters:
id- The id of the character.- Returns:
- a Character object, returns nothing if a given character does not exist with that id
- Throws:
java.io.IOException
-
getHouse
Returns a House with the given id.- Parameters:
id- the id of the house- Returns:
- a House object, returns nothing if a given house does not exist with that id
- Throws:
java.io.IOException
-
getBooksByPage
Returns a list of Books from the given page and page size.- Parameters:
page- the page for paginationpageSize- the page size for pagination- Returns:
- a list of Book objects
- Throws:
java.io.IOException
-
getCharactersByPage
public java.util.List<Character> getCharactersByPage(java.lang.Integer page, java.lang.Integer pageSize) throws java.io.IOExceptionReturns a list of Characters from the given page and page size.- Parameters:
page- the page for paginationpageSize- the page size for pagination- Returns:
- a list of Character objects
- Throws:
java.io.IOException
-
getHousesByPage
public java.util.List<House> getHousesByPage(java.lang.Integer page, java.lang.Integer pageSize) throws java.io.IOExceptionReturns a list of Houses from the given page and page size.- Parameters:
page- the page for paginationpageSize- the page size for pagination- Returns:
- a list of House objects
- Throws:
java.io.IOException
-
searchBooks
public java.util.List<Book> searchBooks(java.lang.String name, java.lang.String fromReleasedDate, java.lang.String toReleasedDate) throws java.io.IOExceptionReturns a list of Books from the given query parameters. Pass null to those parameters you do not want to include in the search.- Parameters:
name- the name of the bookfromReleasedDate- the books that were released after or on the given datetoReleasedDate- the books that were released before or on on the given date- Returns:
- a list of Book objects. Returns nothing if no books exist with the given query parameters
- Throws:
java.io.IOException
-
searchCharacters
public java.util.List<Character> searchCharacters(java.lang.String name, java.lang.String gender, java.lang.String culture, java.lang.String born, java.lang.String died, java.lang.Boolean isAlive) throws java.io.IOExceptionReturns a list of Characters from the given query parameters. Pass null to those parameters you do not want to include in the search.- Parameters:
name- the name of the charactergender- the gender of the character. Can be "male" or "female"culture- the culture of the characterborn- the year in which the character was borndied- the year in which the character has diedisAlive- whether the given character is alive. Can be true or false- Returns:
- a list of Character objects. Returns nothing if no characters exist with the given query parameters
- Throws:
java.io.IOException
-
searchHouses
public java.util.List<House> searchHouses(java.lang.String name, java.lang.String region, java.lang.String words, java.lang.Boolean hasWords, java.lang.Boolean hasTitles, java.lang.Boolean hasSeats, java.lang.Boolean hasDiedOut, java.lang.Boolean hasAncestralWeapons) throws java.io.IOExceptionReturns a list of Houses from the given query parameters. Pass null to those parameters you do not want to include in the search.- Parameters:
name- the name of the houseregion- the region in which the house belongs towords- the words of the househasWords- whether the house has words. Can be true or falsehasTitles- whether the house has titles. Can be true or falsehasSeats- whether the house has seats. Can be true or falsehasDiedOut- whether the house has died. Can be true or falsehasAncestralWeapons- whether the house has ancestral weapons. Can be true or false- Returns:
- a list of House objects, returns nothing if no houses exist with the given query parameters
- Throws:
java.io.IOException
-