Module gg.xp.xivapi
Package gg.xp.xivapi

Class XivApiClient

java.lang.Object
gg.xp.xivapi.XivApiClient
All Implemented Interfaces:
AutoCloseable

public class XivApiClient extends Object implements AutoCloseable
The main xivapi client class.
  • Constructor Details

  • Method Details

    • getSettings

      public XivApiSettings getSettings()
      Returns:
      The settings used to construct this XivApiClient
    • getBaseUri

      public URI getBaseUri()
      Returns:
      The base URI for this client
    • sendGET

      public com.fasterxml.jackson.databind.JsonNode sendGET(URI uri)
      Send a raw request
      Parameters:
      uri - The URI
      Returns:
      The root JSON node.
    • buildUri

      public org.apache.hc.core5.net.URIBuilder buildUri()
      Returns:
      A URI builder, initialized to the base URI plus default query params
    • buildUri

      public URI buildUri(Consumer<org.apache.hc.core5.net.URIBuilder> func)
      Given a lambda, configure a URIBuilder with that lambda. Starts with buildUri().
      Parameters:
      func - The lambda to use to configure the builder
      Returns:
      the built URI
    • getById

      public <X extends XivApiObject> X getById(Class<X> cls, int id)
      Retrieve a single item by primary key/row ID
      Type Parameters:
      X - The type/sheet to retrieve
      Parameters:
      cls - The type/sheet to retrieve
      id - The ID to retrieve
      Returns:
      The mapped object
    • setDefaultListOpts

      public void setDefaultListOpts(ListOptions<XivApiObject> defaultListOpts)
    • getListIterator

      public <X extends XivApiObject> XivApiPaginator<X> getListIterator(Class<X> cls)
      getListIterator(Class, ListOptions) with default ListOptions.
      Type Parameters:
      X - The element type of the list
      Parameters:
      cls - The element type of the list
      Returns:
      An iterator for the list.
    • getListIterator

      public <X extends XivApiObject> XivApiPaginator<X> getListIterator(Class<X> cls, ListOptions<? super X> options)
      Get a list iterator for an entire sheet. Note that by default, this returns a fairly dumb paginator implementation. It does not do any prefetching or buffering, so its Iterator.hasNext() method will block whenever a new sheet needs to be retrieved.
      Type Parameters:
      X - The element type of the list
      Parameters:
      cls - The element type of the list
      options - List options to configure number per page, stop condition, and other future settings.
      Returns:
      An iterator for the list.
    • getSearchIterator

      public <X extends XivApiObject> XivApiPaginator<X> getSearchIterator(Class<X> cls, SearchFilter filter)
    • getSearchIterator

      public <X extends XivApiObject> XivApiPaginator<X> getSearchIterator(Class<X> cls, SearchFilter filter, ListOptions<? super X> options)
      Get a list iterator for a search query. Note that by default, this returns a fairly dumb paginator implementation. It does not do any prefetching or buffering, so its Iterator.hasNext() method will block whenever a new sheet needs to be retrieved.

      This does not support querying across multiple sheets.

      Type Parameters:
      X - The element type of the list
      Parameters:
      cls - The element type of the list
      filter - The search filter to use for the query.
      options - List options to configure number per page, stop condition, and other future settings.
      Returns:
      An iterator for the list.
    • getGameVersions

      public List<String> getGameVersions()
    • close

      public void close()
      Shut down this client.
      Specified by:
      close in interface AutoCloseable