@LevelUpApi(contract=PUBLIC) public class LevelUpRequest extends AbstractRequest
1) All POST parameters will be in JSON. 2) Any access token parameter will be passed in an authorization header. 3) .json URLS will no longer be used, must set accepts header.
AbstractRequest.BadRequestExceptionParcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>| Modifier and Type | Field and Description |
|---|---|
static String |
API_VERSION_CODE_V14
API version code for v14.
|
static String |
API_VERSION_CODE_V15
API version code for v15.
|
static Parcelable.Creator<LevelUpRequest> |
CREATOR
Creator for parceling.
|
static String |
HEADER_AUTHORIZATION
Header key for the authorized user's access token.
|
static String |
HEADER_LEVELUP_API_KEY
Header key for sending the application's API key for LevelUp.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE| Constructor and Description |
|---|
LevelUpRequest(Context context,
HttpMethod method,
String apiVersion,
String endpoint,
Map<String,String> queryParams,
Map<String,String> headers,
RequestBody body,
AccessTokenRetriever retriever)
Creates a new
LevelUpRequest. |
LevelUpRequest(Context context,
HttpMethod method,
String apiVersion,
String endpoint,
Map<String,String> queryParams,
RequestBody body)
Creates a new
LevelUpRequest. |
LevelUpRequest(Context context,
HttpMethod method,
String apiVersion,
String endpoint,
Map<String,String> queryParams,
RequestBody body,
AccessTokenRetriever retriever)
Creates a new
LevelUpRequest. |
LevelUpRequest(Context context,
HttpMethod method,
Uri url,
RequestBody body,
AccessTokenRetriever retriever)
Creates a new
LevelUpRequest. |
LevelUpRequest(Parcel in)
Constructor for parceling.
|
| Modifier and Type | Method and Description |
|---|---|
int |
describeContents() |
boolean |
equals(Object obj) |
AccessToken |
getAccessToken(Context context) |
String |
getBody(Context context) |
int |
getBodyLength(Context context) |
static String |
getFullUrl(Context context,
String apiVersion,
String endpoint)
Gets the full endpoint URL.
|
Map<String,String> |
getRequestHeaders(Context context) |
int |
hashCode() |
String |
toString() |
void |
writeBodyToStream(Context context,
OutputStream stream)
Subclasses must implement this write the POST body (if it has one) to the
OutputStream passed. |
void |
writeToParcel(Parcel dest,
int flags) |
getMethod, getQueryParams, getUrl, getUrlStringpublic static final String API_VERSION_CODE_V14
public static final String API_VERSION_CODE_V15
public static final Parcelable.Creator<LevelUpRequest> CREATOR
public static final String HEADER_AUTHORIZATION
public static final String HEADER_LEVELUP_API_KEY
public LevelUpRequest(Context context, HttpMethod method, String apiVersion, String endpoint, Map<String,String> queryParams, RequestBody body)
LevelUpRequest. This variant of the constructor is only for
non-authenticated requests.context - the Application context.method - the HttpMethod for this request.apiVersion - the version of the LevelUp web service API to hit.endpoint - the API endpoint to request.queryParams - the query string parameters.body - the request body to POST/PUT.public LevelUpRequest(Context context, HttpMethod method, String apiVersion, String endpoint, Map<String,String> queryParams, RequestBody body, AccessTokenRetriever retriever)
LevelUpRequest. This variant of the constructor takes the optional
AccessTokenRetriever for authenticated requests.context - the Application context.method - the HttpMethod for this request.apiVersion - the version of the LevelUp web service API to hit.endpoint - the API endpoint to request.queryParams - the query string parameters.body - the request body to POST/PUT.retriever - implementation of AccessTokenRetriever to use to try to append the
access token to this request.public LevelUpRequest(Context context, HttpMethod method, String apiVersion, String endpoint, Map<String,String> queryParams, Map<String,String> headers, RequestBody body, AccessTokenRetriever retriever)
LevelUpRequest. This variant of the constructor takes the optional
AccessTokenRetriever for authenticated requests.context - the Application context.method - the HttpMethod for this request.apiVersion - the version of the LevelUp web service API to hit.endpoint - the API endpoint to request.queryParams - the query string parameters.headers - allows for specifying request headers.body - the request body to POST/PUT.retriever - implementation of AccessTokenRetriever to use to try to append the
access token to this request.public LevelUpRequest(Context context, HttpMethod method, Uri url, RequestBody body, AccessTokenRetriever retriever) throws IllegalArgumentException
LevelUpRequest. This variant of the constructor takes a Uri
which must be the complete URL of the request.context - the Application context.method - the HttpMethod for this request.url - the request URL. This can include query parameters.body - the request body to POST/PUT.retriever - implementation of AccessTokenRetriever to use to try to append the
access token to this request.IllegalArgumentException - if the URI passed in isn't an absolute URL.public LevelUpRequest(Parcel in)
in - the parcel to read from.public static String getFullUrl(Context context, String apiVersion, String endpoint)
context - Application context.apiVersion - the version of the API to hit.endpoint - the endpoint to hit.public int describeContents()
describeContents in interface ParcelabledescribeContents in class AbstractRequestpublic final AccessToken getAccessToken(Context context)
context - the Application context.AccessToken.public final String getBody(Context context)
context - the context to use to get context dependent parameterspublic final int getBodyLength(Context context)
getBodyLength in class AbstractRequestcontext - the Application context.public final Map<String,String> getRequestHeaders(Context context)
getRequestHeaders in class AbstractRequestcontext - the context to use to get context dependent headers.Collections.unmodifiableMap(Map).public boolean equals(Object obj)
equals in class AbstractRequestpublic int hashCode()
hashCode in class AbstractRequestpublic String toString()
toString in class AbstractRequestpublic void writeBodyToStream(Context context, OutputStream stream) throws IOException
AbstractRequestOutputStream passed.writeBodyToStream in class AbstractRequestcontext - the Application context.stream - the OutputStream to write the POST body to.IOException - if writing to the OutputStream failspublic void writeToParcel(Parcel dest, int flags)
writeToParcel in interface ParcelablewriteToParcel in class AbstractRequest