* @param adWordsSession to copy from
* @param userAgent the new User Agent for the session
* @return a new copy of the AdWordsSession
*/
public static AdWordsSession copy(AdWordsSession adWordsSession, String userAgent) {
AdWordsSession.Builder builder = new Builder();
if (adWordsSession.getEndpoint() != null) {
builder = builder.withEndpoint(adWordsSession.getEndpoint());
}
if (userAgent != null) {
builder = builder.withUserAgent(userAgent);
} else {
builder = builder.withUserAgent(USER_AGENT);
}
if (adWordsSession.getDeveloperToken() != null) {
builder = builder.withDeveloperToken(adWordsSession.getDeveloperToken());
}
if (adWordsSession.getClientCustomerId() != null) {
builder = builder.withClientCustomerId(adWordsSession.getClientCustomerId());
}
if (adWordsSession.getOAuth2Credential() != null) {
builder = builder.withOAuth2Credential(adWordsSession.getOAuth2Credential());
}
try {
AdWordsSession newAdWordsSession;
newAdWordsSession = builder.build();
newAdWordsSession.setPartialFailure(adWordsSession.isPartialFailure());
newAdWordsSession.setValidateOnly(adWordsSession.isValidateOnly());
newAdWordsSession.setReportMoneyInMicros(adWordsSession.isReportMoneyInMicros());
return newAdWordsSession;
} catch (ValidationException e) {