Package com.google.api.ads.adwords.awreporting.util

Examples of com.google.api.ads.adwords.awreporting.util.CustomerDelegate


  public List<Customer> getAccountsInfo(String userId, String mccAccountId, Set<Long> accountIds) throws OAuthException, ValidationException, IOException {
    List<Customer> accounts = Lists.newArrayList();
    AdWordsSession adWordsSession = authenticator.authenticate(userId, mccAccountId, false).build();

    CustomerDelegate customerDelegate = new CustomerDelegate(adWordsSession);
    for (Long accountId : accountIds) {
      adWordsSession.setClientCustomerId(String.valueOf(accountId));
      try {
        accounts.add(customerDelegate.getCustomer());
      } catch (ApiException e) {
        if (e.getMessage().contains("AuthenticationError")) {
          // retries Auth once for expired Tokens
          LOGGER.info("AuthenticationError, Getting a new Token...");
          adWordsSession = authenticator.authenticate(userId, mccAccountId, false).build();
          customerDelegate = new CustomerDelegate(adWordsSession);
          try {
            accounts.add(customerDelegate.getCustomer());
          } catch (ApiException e2) {
            LOGGER.error("Skipping Account " + accountId + " error while getting it's information: " + e2.getMessage());          }
        } else {
          LOGGER.error("Skipping Account " + accountId + " error while getting it's information: " + e.getMessage());
        }
View Full Code Here


         
          // Try to get the MCC Company Name and DescriptiveName
          String name = "";
          try {
            AdWordsSession adWordsSession = authenticate(null, mccAccountId, credential).build();
            CustomerDelegate customerDelegate = new CustomerDelegate(adWordsSession);         
            Customer customer = customerDelegate.getCustomer();
            name = customer.getCompanyName() + " (" + customer.getDescriptiveName() + ")";
          } catch (ValidationException e) {
            LOGGER.error("Error trying to get MCC Name " + e.getMessage());
          } catch (ApiException e) {
            LOGGER.error("Error trying to get MCC Name " + e.getMessage());
View Full Code Here

TOP

Related Classes of com.google.api.ads.adwords.awreporting.util.CustomerDelegate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.