GithubHelp home page GithubHelp logo

didar-bhullar / gameofthronesclient Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 1.05 MB

Java API wrapper for the Game of Thrones API https://anapioficeandfire.com

License: BSD 3-Clause "New" or "Revised" License

Java 100.00%
api-client api-wrapper java-wrapper gameofthrones

gameofthronesclient's Introduction

GameOfThronesClient

Build Status codecov License

Adds a java wrapper around the GoT API

Getting Started

Get the instance of the gameOfThronesClient

 public static void main(String[] args){
        GameOfThronesClient gotClient = getClient();
    }

You can get a version of the client with automatic caching instead if you want.
This will cache all the calls to whatever directory you supply as the cacheFile.

    public static void main(String[] args){
        File cacheFile = new File("cacheFile");
        int cacheSize = 10 * 1024 * 1024; // 10 MB

        GameOfThronesClient gotClient = getClientWithCache(cacheFile, cacheSize);
    }

Those two clients are interchangable. All the method calls to them work exactly the same

Hitting the endpoints

Every endpoint of the GoT API is available through these methods.
Take a look at the gameOfThronesClient javadocs for the methods available to you.

Whenever you use one of those methods, your either going get a list Models or just a Model itself.
These models have various getters on them for easily retreiving information.
Take a look at these model javadocs

Example: Getting all Books

public static void main(String[] args) throws IOException {
        GameOfThronesClient gotClient = getClient();

        List<Book> allBooks = gotClient.getAllBooks();  //Returns a list of Book objects

        // loop through each book
        // you have access to multiple getters to get information
        for(Book book: allBooks){
            System.out.println(book.getName());
            System.out.println(book.getCharacters());
            // and so on...
        }
    }

Example: Getting Character by id

public static void main(String[] args) throws IOException {
        GameOfThronesClient gotClient = getClient();

        Character character = gotClient.getCharacter(100);  //Returns a single character

        // use various getters to get information about this character
        System.out.println(character.getBorn());
        System.out.println(character.getAllegiances());

    }

Example: Searching for Books

Pass in null to search values you do not care for. Applies to all House, and Character searches as well.

In this case I only cared that the book Im searching for was made after 1990-01-01 and before 2002-01-01.
I did not care for the name.

    public static void main(String[] args) throws IOException {
        GameOfThronesClient gotClient = getClient();

        List<Book> bookList = gotClient.searchBooks(null, "1990-01-01", "2002-01-01"); 
        for(Book book: bookList){
            System.out.println(book.getName());
            System.out.println(book.getReleased());
        }

    }

Java Docs

Javadocs link can be found here

gameofthronesclient's People

Contributors

dependabot[bot] avatar didar-bhullar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.