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.
    Book getBook​(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.
    Character getCharacter​(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 GameOfThronesClient getClient()
    Gets the GameOfThronesClient object to start making calls.
    static GameOfThronesClient getClientWithCache​(java.io.File cacheFile, int cacheSize)
    Gets the GameOfThronesClient object with caching enabled.
    House getHouse​(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getClient

      public static GameOfThronesClient getClient()
      Gets the GameOfThronesClient object to start making calls.
      Returns:
      the GameOfThronesClient object
    • getClientWithCache

      public static GameOfThronesClient getClientWithCache​(java.io.File cacheFile, int cacheSize)
      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 file
      cacheSize - the size of the cache
      Returns:
      the GameOfTHronesClient object
    • getAllBooks

      public java.util.List<Book> getAllBooks() throws java.io.IOException
      Returns all books.
      Returns:
      a list of Book objects
      Throws:
      java.io.IOException
    • getAllCharacters

      public java.util.List<Character> getAllCharacters() throws java.io.IOException
      Returns all characters.
      Returns:
      a list of Character objects
      Throws:
      java.io.IOException
    • getAllHouses

      public java.util.List<House> getAllHouses() throws java.io.IOException
      Returns all houses.
      Returns:
      a list of House objects
      Throws:
      java.io.IOException
    • getBook

      public Book getBook​(int id) throws java.io.IOException
      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

      public Character getCharacter​(int id) throws java.io.IOException
      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

      public House getHouse​(int id) throws java.io.IOException
      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

      public java.util.List<Book> getBooksByPage​(int page, int pageSize) throws java.io.IOException
      Returns a list of Books from the given page and page size.
      Parameters:
      page - the page for pagination
      pageSize - 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.IOException
      Returns a list of Characters from the given page and page size.
      Parameters:
      page - the page for pagination
      pageSize - 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.IOException
      Returns a list of Houses from the given page and page size.
      Parameters:
      page - the page for pagination
      pageSize - 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.IOException
      Returns 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 book
      fromReleasedDate - the books that were released after or on the given date
      toReleasedDate - 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.IOException
      Returns 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 character
      gender - the gender of the character. Can be "male" or "female"
      culture - the culture of the character
      born - the year in which the character was born
      died - the year in which the character has died
      isAlive - 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.IOException
      Returns 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 house
      region - the region in which the house belongs to
      words - the words of the house
      hasWords - whether the house has words. Can be true or false
      hasTitles - whether the house has titles. Can be true or false
      hasSeats - whether the house has seats. Can be true or false
      hasDiedOut - whether the house has died. Can be true or false
      hasAncestralWeapons - 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