|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sponsorpay.sdk.android.advertiser.AdvertiserCallbackSender
public class AdvertiserCallbackSender
Runs in the background the Advertiser Callback HTTP request.
| Nested Class Summary | |
|---|---|
static interface |
AdvertiserCallbackSender.APIResultListener
Interface to be implemented by parties interested in the response from the SponsorPay server for the advertiser callback. |
| Field Summary | |
|---|---|
private static java.lang.String |
API_PRODUCTION_RESOURCE_URL
The API resource URL to contact when talking to the SponsorPay Advertiser API |
private static java.lang.String |
API_STAGING_RESOURCE_URL
|
private static java.lang.String |
INSTALL_SUBID_KEY
SubID URL parameter key |
private java.util.Map<java.lang.String,java.lang.String> |
mCustomParams
Map of custom parameters to be sent in the callback request. |
private HostInfo |
mHostInfo
Used to extract required information for the host application and device. |
private HttpClient |
mHttpClient
The HTTP client employed to call the Sponsorpay API |
private HttpUriRequest |
mHttpRequest
The HTTP request that will be executed to contact the API with the callback request |
private HttpResponse |
mHttpResponse
The response returned by the SponsorPay API |
private java.lang.String |
mInstallSubId
Install subID to report on the advertiser callback |
private AdvertiserCallbackSender.APIResultListener |
mListener
Registered listener for the result of the advertiser callback request. |
private boolean |
mWasAlreadySuccessful
True if the advertiser callback was sent and received a successful response in a previous invocation. |
private static int |
SUCCESFUL_HTTP_STATUS_CODE
HTTP status code that the response should have in order to determine that the API has been contacted successfully. |
private static java.lang.String |
SUCCESSFUL_ANSWER_RECEIVED_KEY
The key for encoding the parameter corresponding to whether a previous invocation of the advertiser callback had received a successful response. |
| Constructor Summary | |
|---|---|
AdvertiserCallbackSender(HostInfo hostInfo,
AdvertiserCallbackSender.APIResultListener listener)
Constructor. |
|
| Method Summary | |
|---|---|
private java.lang.String |
buildUrl()
|
protected java.lang.Boolean |
doInBackground(java.lang.String... params)
Method overridden from AsyncTask. |
protected void |
onPostExecute(java.lang.Boolean requestWasSuccessful)
This method is called by the Android AsyncTask implementation in the UI thread (or
the thread which invoked trigger()) when
#doInBackground(AdvertiserHostInfo...) returns. |
void |
setCustomParams(java.util.Map<java.lang.String,java.lang.String> customParams)
Sets the map of custom parameters to be sent in the callback request. |
void |
setInstallSubId(java.lang.String subIdValue)
Sets the install subID to report on the advertiser callback. |
void |
setWasAlreadySuccessful(boolean value)
Sets whether a previous invocation of the advertiser callback had received a successful response. |
void |
trigger()
Triggers the callback request that contacts the Sponsorpay Advertiser API. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int SUCCESFUL_HTTP_STATUS_CODE
private static final java.lang.String API_PRODUCTION_RESOURCE_URL
private static final java.lang.String API_STAGING_RESOURCE_URL
private static final java.lang.String SUCCESSFUL_ANSWER_RECEIVED_KEY
private static final java.lang.String INSTALL_SUBID_KEY
private HttpUriRequest mHttpRequest
private HttpResponse mHttpResponse
private HttpClient mHttpClient
private boolean mWasAlreadySuccessful
private java.lang.String mInstallSubId
private java.util.Map<java.lang.String,java.lang.String> mCustomParams
private AdvertiserCallbackSender.APIResultListener mListener
private HostInfo mHostInfo
| Constructor Detail |
|---|
public AdvertiserCallbackSender(HostInfo hostInfo,
AdvertiserCallbackSender.APIResultListener listener)
Constructor. Sets the request callback listener and stores the host information.
SeeAdvertiserHostInfo and AdvertiserCallbackSender.APIResultListener.
hostInfo - the host information for the given devicelistener - the callback listener| Method Detail |
|---|
public void setCustomParams(java.util.Map<java.lang.String,java.lang.String> customParams)
public void setInstallSubId(java.lang.String subIdValue)
subIdValue - The install subID received on the app instalation.public void setWasAlreadySuccessful(boolean value)
public void trigger()
AdvertiserCallbackSender.APIResultListener registered
through the constructor #AsyncAPICaller(AdvertiserHostInfo, APIResultListener) will
be notified.
private java.lang.String buildUrl()
protected java.lang.Boolean doInBackground(java.lang.String... params)
Method overridden from AsyncTask. Executed on a background thread, runs the API
contact request.
Encodes the host information in the request URL, runs the request, waits for the response,
parses its status code and lets the UI thread receive the result and notify the registered
AdvertiserCallbackSender.APIResultListener.
params - Only one parameter of type String containing the request URL is expected.
AsyncTask implementation.protected void onPostExecute(java.lang.Boolean requestWasSuccessful)
AsyncTask implementation in the UI thread (or
the thread which invoked trigger()) when
#doInBackground(AdvertiserHostInfo...) returns. It will invoke the registered
AdvertiserCallbackSender.APIResultListener
requestWasSuccessful - true if the response has a successful status code (equal to
SUCCESFUL_HTTP_STATUS_CODE). false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||