Class Connection

java.lang.Object
com.amilesend.tvmaze.client.connection.Connection

public class Connection extends Object
Wraps a OkHttpClient that manages parsing responses to corresponding POJO types.
  • Field Details

  • Method Details

    • newDefaultInstance

      public static Connection newDefaultInstance()
    • newRequestBuilder

      public okhttp3.Request.Builder newRequestBuilder()
      Creates a new Request.Builder with pre-configured headers for request that expect a JSON-formatted response body.
      Returns:
      the request builder
    • execute

      public <T> T execute(@NonNull okhttp3.Request request, @NonNull GsonParser<T> parser) throws ConnectionException
      Executes the given Request and parses the JSON-formatted response with given GsonParser.
      Type Parameters:
      T - the POJO resource type
      Parameters:
      request - the request
      parser - the parser to decode the response body
      Returns:
      the response as a POJO resource type
      Throws:
      ConnectionException - if an error occurred during the transaction
    • builder

      public static Connection.ConnectionBuilder builder()
    • getGson

      public com.google.gson.Gson getGson()
      The configured GSON instance used for marshalling request and responses to/from JSON.
    • getBaseUrl

      public String getBaseUrl()
      The base URL for the Graph API.