com.sponsorpay.sdk.android
Class UrlBuilder

java.lang.Object
  extended by com.sponsorpay.sdk.android.UrlBuilder

public class UrlBuilder
extends java.lang.Object

Contains utility methods to build URLs used to access the SponsorPay's back-end API.


Field Summary
private static java.lang.String ANDROID_ID_KEY
          The Android ID key for encoding the corresponding URL parameter.
private static java.lang.String APPID_KEY
          The App ID key for encoding the corresponding URL parameter.
private static java.lang.String LANGUAGE_KEY
          The default language setting key for encoding the corresponding URL parameter.
private static java.lang.String OS_VERSION_KEY
          The OS version key for encoding the corresponding URL parameter.
private static java.lang.String PHONE_VERSION_KEY
          The phone model key for encoding the corresponding URL parameter.
private static java.lang.String SDK_RELEASE_VERSION_KEY
          The SDK release version key for encoding the corresponding URL parameter.
private static java.lang.String UDID_KEY
          The unique device ID (for url-encoding).
static java.lang.String URL_PARAM_ALLOW_CAMPAIGN_KEY
           
static java.lang.String URL_PARAM_CURRENCY_NAME_KEY
           
static java.lang.String URL_PARAM_OFFSET_KEY
           
private static java.lang.String URL_PARAM_SIGNATURE
          Request signature parameter key.
static java.lang.String URL_PARAM_VALUE_ON
           
private static java.lang.String USERID_KEY
          The user id key for encoding the corresponding URL parameter.
private static java.lang.String WIFI_MAC_ADDRESS_KEY
          The WiFi MAC Address ID key for encoding the corresponding URL parameter.
 
Constructor Summary
UrlBuilder()
           
 
Method Summary
static java.lang.String buildUrl(java.lang.String resourceUrl, HostInfo hostInfo, java.util.Map<java.lang.String,java.lang.String> extraKeysValues)
          Builds a String URL with information gathered from the device and the specified parameters.
static java.lang.String buildUrl(java.lang.String resourceUrl, java.lang.String userId, HostInfo hostInfo, java.util.Map<java.lang.String,java.lang.String> extraKeysValues)
          Builds a String URL with information gathered from the device and the specified parameters.
static java.lang.String buildUrl(java.lang.String resourceUrl, java.lang.String userId, HostInfo hostInfo, java.util.Map<java.lang.String,java.lang.String> extraKeysValues, java.lang.String secretKey)
          Builds a String URL with information gathered from the device and the specified parameters.
static java.util.Map<java.lang.String,java.lang.String> mapKeysToValues(java.lang.String[] keys, java.lang.String[] values)
          Constructs a Map of key / value parameters given an array of keys and an array of values.
static void validateKeyValueParams(java.util.Map<java.lang.String,java.lang.String> kvParams)
          Checks that the passed Map of key/value parameters doesn't contain empty or null keys or values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UDID_KEY

private static final java.lang.String UDID_KEY
The unique device ID (for url-encoding).

See Also:
Constant Field Values

USERID_KEY

private static final java.lang.String USERID_KEY
The user id key for encoding the corresponding URL parameter.

See Also:
Constant Field Values

APPID_KEY

private static final java.lang.String APPID_KEY
The App ID key for encoding the corresponding URL parameter.

See Also:
Constant Field Values

OS_VERSION_KEY

private static final java.lang.String OS_VERSION_KEY
The OS version key for encoding the corresponding URL parameter.

See Also:
Constant Field Values

PHONE_VERSION_KEY

private static final java.lang.String PHONE_VERSION_KEY
The phone model key for encoding the corresponding URL parameter.

See Also:
Constant Field Values

LANGUAGE_KEY

private static final java.lang.String LANGUAGE_KEY
The default language setting key for encoding the corresponding URL parameter.

See Also:
Constant Field Values

SDK_RELEASE_VERSION_KEY

private static final java.lang.String SDK_RELEASE_VERSION_KEY
The SDK release version key for encoding the corresponding URL parameter.

See Also:
Constant Field Values

ANDROID_ID_KEY

private static final java.lang.String ANDROID_ID_KEY
The Android ID key for encoding the corresponding URL parameter.

See Also:
Constant Field Values

WIFI_MAC_ADDRESS_KEY

private static final java.lang.String WIFI_MAC_ADDRESS_KEY
The WiFi MAC Address ID key for encoding the corresponding URL parameter.

See Also:
Constant Field Values

URL_PARAM_SIGNATURE

private static final java.lang.String URL_PARAM_SIGNATURE
Request signature parameter key.

See Also:
Constant Field Values

URL_PARAM_ALLOW_CAMPAIGN_KEY

public static final java.lang.String URL_PARAM_ALLOW_CAMPAIGN_KEY
See Also:
Constant Field Values

URL_PARAM_VALUE_ON

public static final java.lang.String URL_PARAM_VALUE_ON
See Also:
Constant Field Values

URL_PARAM_OFFSET_KEY

public static final java.lang.String URL_PARAM_OFFSET_KEY
See Also:
Constant Field Values

URL_PARAM_CURRENCY_NAME_KEY

public static final java.lang.String URL_PARAM_CURRENCY_NAME_KEY
See Also:
Constant Field Values
Constructor Detail

UrlBuilder

public UrlBuilder()
Method Detail

buildUrl

public static java.lang.String buildUrl(java.lang.String resourceUrl,
                                        java.lang.String userId,
                                        HostInfo hostInfo,
                                        java.util.Map<java.lang.String,java.lang.String> extraKeysValues)
Builds a String URL with information gathered from the device and the specified parameters.

Parameters:
resourceUrl - The base for the URL to be built and returned, including schema and host.
userId - The user id parameter to encode in the result URL. It can be left to null and no user ID parameter key will be included in the request parameters.
hostInfo - A HostInfo instance used to retrieve data about the application id and the host device.
extraKeysValues - A map of extra key/value pairs to add to the result URL.
Returns:
The built URL as a String with the provided parameters encoded.

buildUrl

public static java.lang.String buildUrl(java.lang.String resourceUrl,
                                        HostInfo hostInfo,
                                        java.util.Map<java.lang.String,java.lang.String> extraKeysValues)
Builds a String URL with information gathered from the device and the specified parameters.

Parameters:
resourceUrl - The base for the URL to be built and returned, including schema and host.
hostInfo - A HostInfo instance used to retrieve data about the application id and the host device.
extraKeysValues - A map of extra key/value pairs to add to the result URL.
Returns:
The built URL as a String with the provided parameters encoded.

buildUrl

public static java.lang.String buildUrl(java.lang.String resourceUrl,
                                        java.lang.String userId,
                                        HostInfo hostInfo,
                                        java.util.Map<java.lang.String,java.lang.String> extraKeysValues,
                                        java.lang.String secretKey)
Builds a String URL with information gathered from the device and the specified parameters.

Parameters:
resourceUrl - The base for the URL to be built and returned, including schema and host.
userId - The user id parameter to encode in the result URL. It can be left to null and no user ID parameter key will be included in the request parameters.
hostInfo - A HostInfo instance used to retrieve data about the application id and the host device.
extraKeysValues - A map of extra key/value pairs to add to the result URL.
secretKey - The publisher's secret token which will be used to sign the request. If left to null the request will be sent unsigned.
Returns:
The built URL as a String with the provided parameters encoded.

validateKeyValueParams

public static void validateKeyValueParams(java.util.Map<java.lang.String,java.lang.String> kvParams)
Checks that the passed Map of key/value parameters doesn't contain empty or null keys or values. If it does, triggers an IllegalArgumentException.

Parameters:
kvParams -

mapKeysToValues

public static java.util.Map<java.lang.String,java.lang.String> mapKeysToValues(java.lang.String[] keys,
                                                                               java.lang.String[] values)
Constructs a Map of key / value parameters given an array of keys and an array of values. If any of the arrays contains empty of null values, an IllegalArgumentException will be triggered.

Parameters:
keys - An array of keys
values - an array of values in the same order than the provided array of keys
Returns:
a Map of keys / values