Package com.google.api.ads.adwords.jaxws.v201406.mcm

Examples of com.google.api.ads.adwords.jaxws.v201406.mcm.ManagedCustomerPage


    // Create selector.
    Selector selector = new Selector();
    selector.setFields(new String[]{"Login", "CustomerId""Name"});

    // Get results.
    ManagedCustomerPage page = managedCustomerService.get(selector);

    // Display serviced account graph.
    if (page.getEntries() != null) {
      // Create map from customerId to customer node.
      Map<Long, ManagedCustomerTreeNode> customerIdToCustomerNode =
          new HashMap<Long, ManagedCustomerTreeNode>();

      // Create account tree nodes for each customer.
      for (ManagedCustomer customer : page.getEntries()) {
        ManagedCustomerTreeNode node = new ManagedCustomerTreeNode();
        node.account = customer;
        customerIdToCustomerNode.put(customer.getCustomerId(), node);
      }

      // For each link, connect nodes in tree.
      if (page.getLinks() != null) {
        for (ManagedCustomerLink link : page.getLinks()) {
          ManagedCustomerTreeNode managerNode = customerIdToCustomerNode.get(
              link.getManagerCustomerId());
          ManagedCustomerTreeNode childNode = customerIdToCustomerNode.get(
              link.getClientCustomerId());
          childNode.parentNode = managerNode;
          if (managerNode != null) {
            managerNode.childAccounts.add(childNode);
          }
        }
      }

      // Find the root account node in the tree.
      ManagedCustomerTreeNode rootNode = null;
      for (ManagedCustomer account : page.getEntries()) {
        if (customerIdToCustomerNode.get(account.getCustomerId()).parentNode == null) {
          rootNode = customerIdToCustomerNode.get(account.getCustomerId());
          break;
        }
      }
View Full Code Here


    // Create selector.
    Selector selector = new Selector();
    selector.setFields(new String[]{"Login", "CustomerId""Name"});

    // Get results.
    ManagedCustomerPage page = managedCustomerService.get(selector);

    // Display serviced account graph.
    if (page.getEntries() != null) {
      // Create map from customerId to customer node.
      Map<Long, ManagedCustomerTreeNode> customerIdToCustomerNode =
          new HashMap<Long, ManagedCustomerTreeNode>();

      // Create account tree nodes for each customer.
      for (ManagedCustomer customer : page.getEntries()) {
        ManagedCustomerTreeNode node = new ManagedCustomerTreeNode();
        node.account = customer;
        customerIdToCustomerNode.put(customer.getCustomerId(), node);
      }

      // For each link, connect nodes in tree.
      if (page.getLinks() != null) {
        for (ManagedCustomerLink link : page.getLinks()) {
          ManagedCustomerTreeNode managerNode = customerIdToCustomerNode.get(
              link.getManagerCustomerId());
          ManagedCustomerTreeNode childNode = customerIdToCustomerNode.get(
              link.getClientCustomerId());
          childNode.parentNode = managerNode;
          if (managerNode != null) {
            managerNode.childAccounts.add(childNode);
          }
        }
      }

      // Find the root account node in the tree.
      ManagedCustomerTreeNode rootNode = null;
      for (ManagedCustomer account : page.getEntries()) {
        if (customerIdToCustomerNode.get(account.getCustomerId()).parentNode == null) {
          rootNode = customerIdToCustomerNode.get(account.getCustomerId());
          break;
        }
      }
View Full Code Here

    Selector selector = new SelectorBuilder()
        .fields("Login", "CustomerId", "Name")
        .build();

    // Get results.
    ManagedCustomerPage page = managedCustomerService.get(selector);

    // Display serviced account graph.
    if (page.getEntries() != null) {
      // Create map from customerId to customer node.
      Map<Long, ManagedCustomerTreeNode> customerIdToCustomerNode =
          new HashMap<Long, ManagedCustomerTreeNode>();

      // Create account tree nodes for each customer.
      for (ManagedCustomer customer : page.getEntries()) {
        ManagedCustomerTreeNode node = new ManagedCustomerTreeNode();
        node.account = customer;
        customerIdToCustomerNode.put(customer.getCustomerId(), node);
      }

      // For each link, connect nodes in tree.
      if (page.getLinks() != null) {
        for (ManagedCustomerLink link : page.getLinks()) {
          ManagedCustomerTreeNode managerNode = customerIdToCustomerNode.get(
              link.getManagerCustomerId());
          ManagedCustomerTreeNode childNode = customerIdToCustomerNode.get(
              link.getClientCustomerId());
          childNode.parentNode = managerNode;
          if (managerNode != null) {
            managerNode.childAccounts.add(childNode);
          }
        }
      }

      // Find the root account node in the tree.
      ManagedCustomerTreeNode rootNode = null;
      for (ManagedCustomer account : page.getEntries()) {
        if (customerIdToCustomerNode.get(account.getCustomerId()).parentNode == null) {
          rootNode = customerIdToCustomerNode.get(account.getCustomerId());
          break;
        }
      }
View Full Code Here

    Selector selector = new SelectorBuilder()
        .fields("Login", "CustomerId", "Name")
        .build();

    // Get results.
    ManagedCustomerPage page = managedCustomerService.get(selector);

    // Display serviced account graph.
    if (page.getEntries() != null) {
      // Create map from customerId to customer node.
      Map<Long, ManagedCustomerTreeNode> customerIdToCustomerNode =
          new HashMap<Long, ManagedCustomerTreeNode>();

      // Create account tree nodes for each customer.
      for (ManagedCustomer customer : page.getEntries()) {
        ManagedCustomerTreeNode node = new ManagedCustomerTreeNode();
        node.account = customer;
        customerIdToCustomerNode.put(customer.getCustomerId(), node);
      }

      // For each link, connect nodes in tree.
      if (page.getLinks() != null) {
        for (ManagedCustomerLink link : page.getLinks()) {
          ManagedCustomerTreeNode managerNode = customerIdToCustomerNode.get(
              link.getManagerCustomerId());
          ManagedCustomerTreeNode childNode = customerIdToCustomerNode.get(
              link.getClientCustomerId());
          childNode.parentNode = managerNode;
          if (managerNode != null) {
            managerNode.childAccounts.add(childNode);
          }
        }
      }

      // Find the root account node in the tree.
      ManagedCustomerTreeNode rootNode = null;
      for (ManagedCustomer account : page.getEntries()) {
        if (customerIdToCustomerNode.get(account.getCustomerId()).parentNode == null) {
          rootNode = customerIdToCustomerNode.get(account.getCustomerId());
          break;
        }
      }
View Full Code Here

   */
  private void retrieveAccounts(Selector selector, List<ManagedCustomer> accountList) throws ApiException
       {

    int startIndex = 0;
    Paging paging = new Paging();
    selector.setPaging(paging);
    ManagedCustomerPage managedCustomerPage;
    do {
      paging.setStartIndex(startIndex);
      paging.setNumberResults(NUMBER_OF_RESULTS);

      LOGGER.info("Retrieving next " + NUMBER_OF_RESULTS + " accounts.");

      try {
        managedCustomerPage = managedCustomerService.get(selector);
View Full Code Here

   *
   * @return the list of accounts.
   * @throws ApiException error retrieving the accounts.
   */
  public List<ManagedCustomer> getAccounts() throws ApiException {
    Selector selector = createAccountSelectorFields();

    // Paging results to avoid RESPONSE_SIZE_LIMIT_EXCEEDED
    List<ManagedCustomer> accountList = Lists.newArrayList();
    try {
      this.retrieveAccounts(selector, accountList);
View Full Code Here

   * Creates a Generic Selector for Managed Customers queries.
   *
   * @return the default {@link Selector} to retrieve the accounts
   */
  private Selector createAccountSelectorFields() {
    Selector selector = new Selector();
    selector.getFields().add("CustomerId");
    selector.getFields().add("CanManageClients");
    selector.getFields().add("Name");
    selector.getFields().add("CompanyName");
    selector.getFields().add("CurrencyCode");
    selector.getFields().add("DateTimeZone");
    return selector;
  }
View Full Code Here

      this.retrieveAccounts(selector, accountList);
    } catch (Exception e) {
      LOGGER.error("Error on managedCustomerService.get(selector), probably an AuthenticationError: "
          + e.getMessage());
      e.printStackTrace();
      throw new ApiException(
          "Error on managedCustomerService.get(selector), probably an AuthenticationError: " + e.getMessage(),
          new com.google.api.ads.adwords.jaxws.v201406.cm.ApiException());
    }
    return accountList;
  }
View Full Code Here

    kratuProcessor.setPersister(mockedEntitiesPersister);
    kratuProcessor.setReportProcessor(mockedReportProcessor);
    storageHelper.setPersister(mockedEntitiesPersister);

    Customer customer1 = new Customer();
    customer1.setCustomerId(1L);
    Customer customer2 = new Customer();
    customer2.setCustomerId(2L);
    List<Customer> customers = ImmutableList.of(customer1, customer2);
    when(mockedReportProcessor.getAccountsInfo(
        Mockito.anyString(), Mockito.anyString(), Mockito.anySetOf(Long.class))).thenReturn(customers);
  }
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.jaxws.v201406.mcm.ManagedCustomerPage

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.