Class Connection<G extends GsonFactoryBase>
java.lang.Object
com.amilesend.client.connection.Connection<G>
Wraps an 
OkHttpClient that manages parsing responses to corresponding POJO types.- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classConnection.ConnectionBuilder<G extends GsonFactoryBase, C extends Connection<G>, B extends Connection.ConnectionBuilder<G,C, B>> static final class
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionstatic <G extends GsonFactoryBase>
 Connection.ConnectionBuilder<G, ?, ?> builder()okhttp3.Responseexecute(@NonNull okhttp3.Request request) Executes the givenRequestand returns the associated HTTP response code.<T> Texecute(@NonNull okhttp3.Request request, @NonNull GsonParser<T> parser) Executes the givenRequestand parses the JSON-formatted response with givenGsonParser.@NonNull AuthManager<?> The authorization manager used to authenticate and sign requests.@NonNull StringThe base URL for the Graph API.The Gson factory used to create GSON instance that marshals request and responses to/from JSON.@NonNull okhttp3.OkHttpClientThe underlying http client.@NonNull StringThe user agent to include in request headers.booleanokhttp3.Request.BuilderCreates a newRequest.Builderwith pre-configured headers for request that expect a JSON-formatted response body.
- 
Field Details- 
FORM_DATA_CONTENT_TYPE- See Also:
 
- 
FORM_DATA_MEDIA_TYPEpublic static final okhttp3.MediaType FORM_DATA_MEDIA_TYPE
- 
JSON_CONTENT_TYPE- See Also:
 
- 
JSON_MEDIA_TYPEpublic static final okhttp3.MediaType JSON_MEDIA_TYPE
 
- 
- 
Method Details- 
newRequestBuilderpublic okhttp3.Request.Builder newRequestBuilder()Creates a newRequest.Builderwith pre-configured headers for request that expect a JSON-formatted response body.- Returns:
- the request builder
 
- 
executepublic <T> T execute(@NonNull okhttp3.Request request, @NonNull GsonParser<T> parser) throws ConnectionException Executes the givenRequestand parses the JSON-formatted response with givenGsonParser.- 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
 
- 
executeExecutes the givenRequestand returns the associated HTTP response code. This is typically used for transactions that do not expect a response in the body.- Parameters:
- request- the request
- Returns:
- the HTTP response
- Throws:
- ConnectionException- if an error occurred during the transaction
 
- 
builder
- 
getHttpClient@NonNull public @NonNull okhttp3.OkHttpClient getHttpClient()The underlying http client.
- 
getGsonFactoryThe Gson factory used to create GSON instance that marshals request and responses to/from JSON.
- 
getAuthManagerThe authorization manager used to authenticate and sign requests.
- 
getBaseUrlThe base URL for the Graph API.
- 
getUserAgentThe user agent to include in request headers.
- 
isGzipContentEncodingEnabledpublic boolean isGzipContentEncodingEnabled()
 
-