String tokenString = apiContext.getApiCredential().geteBayToken();
//some api calls(GetTokenStatus, RevokeToken) need full credentials
if(enableFullCredentials) {
SOAPElement credNode = reqCred.addChildElement("Credentials", EBayConstants.EBL_PREFIX);
ApiAccount ac = apiContext.getApiCredential().getApiAccount();
credNode.addChildElement("AppId", EBayConstants.EBL_PREFIX).addTextNode(ac.getApplication());
credNode.addChildElement("DevId", EBayConstants.EBL_PREFIX).addTextNode(ac.getDeveloper());
credNode.addChildElement("AuthCert", EBayConstants.EBL_PREFIX).addTextNode(ac.getCertificate());
reqCred.addChildElement("eBayAuthToken", EBayConstants.EBL_PREFIX).addTextNode(tokenString);
return;
}
//some api calls(GetSessionID/FetchToken) only need Api Account
if(needApiAccountOnly) {
SOAPElement credNode = reqCred.addChildElement("Credentials", EBayConstants.EBL_PREFIX);
ApiAccount ac = apiContext.getApiCredential().getApiAccount();
credNode.addChildElement("AppId", EBayConstants.EBL_PREFIX).addTextNode(ac.getApplication());
credNode.addChildElement("DevId", EBayConstants.EBL_PREFIX).addTextNode(ac.getDeveloper());
credNode.addChildElement("AuthCert", EBayConstants.EBL_PREFIX).addTextNode(ac.getCertificate());
//for FetchToken call, need Username if SecretID is used
eBayAccount ec = apiContext.getApiCredential().geteBayAccount();
if (ec != null && ec.getUsername() != null) {
credNode.addChildElement("Username", EBayConstants.EBL_PREFIX).addTextNode(ec.getUsername());
}
return;
}
if (tokenString == null || tokenString.length() == 0) {
SOAPElement credNode = reqCred.addChildElement("Credentials", EBayConstants.EBL_PREFIX);
ApiAccount ac = apiContext.getApiCredential().getApiAccount();
credNode.addChildElement("AppId", EBayConstants.EBL_PREFIX).addTextNode(ac.getApplication());
credNode.addChildElement("DevId", EBayConstants.EBL_PREFIX).addTextNode(ac.getDeveloper());
credNode.addChildElement("AuthCert", EBayConstants.EBL_PREFIX).addTextNode(ac.getCertificate());
} else {
reqCred.addChildElement("eBayAuthToken", EBayConstants.EBL_PREFIX).addTextNode(tokenString);
}
}