|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jakewharton.apibuilder.ApiBuilder
com.jakewharton.trakt.TraktApiBuilder<T>
T
- Native class type of the HTTP method call result.public abstract class TraktApiBuilder<T>
Trakt-specific API builder extension which provides helper methods for adding fields, parameters, and post-parameters commonly used in the API.
Nested Class Summary | |
---|---|
protected static class |
TraktApiBuilder.HttpMethod
Valid HTTP request methods. |
Field Summary | |
---|---|
protected static String |
FIELD_API_KEY
API key field name. |
protected static String |
FIELD_DATE
|
protected static String |
FIELD_DAYS
|
protected static String |
FIELD_EPISODE
|
protected static String |
FIELD_EXTENDED
|
protected static String |
FIELD_QUERY
|
protected static String |
FIELD_SEASON
|
protected static String |
FIELD_TITLE
|
protected static String |
FIELD_USERNAME
|
Fields inherited from class com.jakewharton.apibuilder.ApiBuilder |
---|
API_URL_DELIMITER_END, API_URL_DELIMITER_START |
Constructor Summary | |
---|---|
TraktApiBuilder(TraktApiService service,
com.google.gson.reflect.TypeToken<T> token,
String methodUri)
Initialize a new builder for an HTTP GET call. |
|
TraktApiBuilder(TraktApiService service,
com.google.gson.reflect.TypeToken<T> token,
String urlFormat,
TraktApiBuilder.HttpMethod method)
Initialize a new builder for the specified HTTP method call. |
Method Summary | ||
---|---|---|
protected static long |
dateToUnixTimestamp(Date date)
Convert a Date to its Unix timestamp equivalent. |
|
protected com.google.gson.JsonElement |
execute()
Execute the remote API method and return the JSON object result. |
|
protected com.jakewharton.apibuilder.ApiBuilder |
field(String name,
Date date)
Add a URL field value. |
|
protected
|
field(String name,
K value)
Add a URL field value. |
|
T |
fire()
Execute remote API method and unmarshall the result to its native type. |
|
protected boolean |
hasPostParameter(String name)
|
|
protected void |
includeDebugStrings()
Mark current builder as Trakt developer method. |
|
protected com.jakewharton.apibuilder.ApiBuilder |
parameter(String name,
Date value)
Add a URL parameter value. |
|
protected
|
parameter(String name,
K value)
Add a URL parameter value. |
|
protected
|
parameter(String name,
List<K> valueList)
Add a URL parameter value. |
|
protected void |
performValidation()
Perform any required validation before firing off the request. |
|
protected void |
postFireCallback(T result)
Perform any required actions before returning the request result. |
|
protected TraktApiBuilder<T> |
postParameter(String name,
int value)
|
|
protected TraktApiBuilder<T> |
postParameter(String name,
com.google.gson.JsonElement value)
|
|
protected
|
postParameter(String name,
K value)
|
|
protected TraktApiBuilder<T> |
postParameter(String name,
String value)
|
|
protected void |
preFireCallback()
Perform any required actions before validating the request. |
|
void |
print()
Print the HTTP request that would be made |
Methods inherited from class com.jakewharton.apibuilder.ApiBuilder |
---|
buildUrl, buildUrl, encodeUrl, field, field, field, field, field, hasField, hasParameter, parameter, parameter, parameter, parameter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String FIELD_API_KEY
protected static final String FIELD_USERNAME
protected static final String FIELD_DATE
protected static final String FIELD_DAYS
protected static final String FIELD_QUERY
protected static final String FIELD_SEASON
protected static final String FIELD_TITLE
protected static final String FIELD_EPISODE
protected static final String FIELD_EXTENDED
Constructor Detail |
---|
public TraktApiBuilder(TraktApiService service, com.google.gson.reflect.TypeToken<T> token, String methodUri)
service
- Service to bind to.token
- Return type token.methodUri
- URI method format string.public TraktApiBuilder(TraktApiService service, com.google.gson.reflect.TypeToken<T> token, String urlFormat, TraktApiBuilder.HttpMethod method)
service
- Service to bind to.token
- Return type token.urlFormat
- URL format string.method
- HTTP method.Method Detail |
---|
public final T fire()
com.jakewharton.apibuilder.ApiException
- if validation fails.protected void preFireCallback()
protected void performValidation()
protected void postFireCallback(T result)
result
- Request result.protected final void includeDebugStrings()
protected final com.google.gson.JsonElement execute()
Execute the remote API method and return the JSON object result.
This method can be overridden to select a specific subset of the JSON object. The overriding implementation should still call 'super.execute()' and then perform the filtering from there.
public final void print()
protected final com.jakewharton.apibuilder.ApiBuilder parameter(String name, Date value)
name
- Name.value
- Value.
protected final <K extends TraktEnumeration> com.jakewharton.apibuilder.ApiBuilder parameter(String name, K value)
name
- Name.value
- Value.
protected final <K> com.jakewharton.apibuilder.ApiBuilder parameter(String name, List<K> valueList)
name
- Name.valueList
- List of values.
protected final com.jakewharton.apibuilder.ApiBuilder field(String name, Date date)
name
- Name.date
- Value.
protected final <K extends TraktEnumeration> com.jakewharton.apibuilder.ApiBuilder field(String name, K value)
name
- Name.value
- Value.
protected final boolean hasPostParameter(String name)
protected final TraktApiBuilder<T> postParameter(String name, String value)
protected final TraktApiBuilder<T> postParameter(String name, int value)
protected final <K extends TraktEnumeration> TraktApiBuilder<T> postParameter(String name, K value)
protected final TraktApiBuilder<T> postParameter(String name, com.google.gson.JsonElement value)
protected static final long dateToUnixTimestamp(Date date)
Date
to its Unix timestamp equivalent.
date
- Date value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |