com.mastercard.masterpass.merchant.impl.APITrackerImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mastercard-masterpass-merchant Show documentation
Show all versions of mastercard-masterpass-merchant Show documentation
Masterpass Merchant Checkout SDK on MasterCard Developer Zone (https://developer.mastercard.com)
The newest version!
package com.mastercard.masterpass.merchant.impl;
import com.mastercard.sdk.core.interfaces.APITracker;
import com.mastercard.sdk.core.MasterCardApiConfig;
/**
* Log API tracking information for all api.
*
*/
public class APITrackerImpl implements APITracker{
private static final String JAVA_VERSION = "java.version";
private static final String CLIENT_SDK_VERSION = "client_sdk_version=";
private static final String LANG_VERSION = "lang_version=";
private static final String PROGRAMMING_LANG = "lang_name=";
private static final String PLUGIN_VERSION = "plugin_version=";
private static final String JAVA = "java";
private static final String COMMA = ",";
private static final String USER_AGENT_HEADER = "MC Open API OAuth Framework v1.0-Java";
private static final String KEY_PLUGIN_VERSION = "pluginVersion";
/**
* Returns client tracking information.
*
* @return the client tracking information.
*/
public String getAPITrackingHeader(){
StringBuilder trackingHeader = new StringBuilder();
Package clientPackage = Package.getPackage("com.mastercard.masterpass.merchant");
trackingHeader.append(CLIENT_SDK_VERSION + clientPackage.getImplementationVersion() + COMMA);
trackingHeader.append(PROGRAMMING_LANG + JAVA + COMMA);
trackingHeader.append(LANG_VERSION + System.getProperty(JAVA_VERSION));
if (!MasterCardApiConfig.additionalProperties.isEmpty()
&& MasterCardApiConfig.additionalProperties.containsKey(KEY_PLUGIN_VERSION)) {
trackingHeader
.append(COMMA + PLUGIN_VERSION + MasterCardApiConfig.additionalProperties.get(KEY_PLUGIN_VERSION));
}
return trackingHeader.toString();
}
/**
* Returns user agent header value.
*
* @return the user agent header value.
*/
@Override
public String getUserAgentHeader() {
return USER_AGENT_HEADER;
}
}