Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // Copyright 2012 Google Inc. All Rights Reserved.
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //       http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
 package com.google.api.ads.adwords.axis.utility.extension;
 
 
 import java.util.List;

ExtendedMcc encapsulates the MCC Level operations.

This class does not guard its mutable reference for AdWordsSession

Author(s):
Julian Toledo
 
 public final class ExtendedMcc {
 
   private final AdWordsSession adWordsSession;
 
   private final DelegateLocator delegateLocator;
 
   private final String clientCustomerId;

  
Constructs an ExtendedMcc from a AdWordsSession.

Parameters:
adWordsSession the AdWordsSession for the MCC
 
   public ExtendedMcc(AdWordsSession adWordsSession) {
      = new DelegateLocator(adWordsSession);
     // Using clientCustomerId from builder
   }

  
Constructs an ExtendedMcc from a AdWordsSession.

Parameters:
delegateLocator the DelegateLocator for the MCC
 
   public ExtendedMcc(DelegateLocator delegateLocator) {
     this. = delegateLocator.getAdWordsSession();
     this. = delegateLocator;
     // Using clientCustomerId from DelegateLocator' builder
      = delegateLocator.getClientCustomerId();
   }

  
Constructs an ExtendedMcc from a AdWordsSession and a clientCustomerId.

Parameters:
adWordsSession the AdWordsSession for the MCC
clientCustomerId the clientCustomerId as String
 
   public ExtendedMcc(AdWordsSession adWordsSessionString clientCustomerId) {
     this. = clientCustomerId;
      = new DelegateLocator(adWordsSessionclientCustomerId);
   }

  
Constructs an ExtendedMcc from a AdWordsSession and a ManagedCustomer.

Parameters:
adWordsSession the AdWordsSession for the MCC
managedCustomer the ManagedCustomer to use in the session
 
   public ExtendedMcc(AdWordsSession adWordsSessionManagedCustomer managedCustomer) {
     this. = managedCustomer.getCustomerId().toString();
      = new DelegateLocator(adWordsSessionmanagedCustomer);
   }

  
Creates a new ExtendedMcc using the ads.properties file and using OAuth2.

Returns:
the ExtendedMcc associated with the file
Throws:
com.google.api.ads.common.lib.exception.OAuthException if problem with OAuth2
com.google.api.ads.common.lib.conf.ConfigurationLoadException if problems loading the ad.properties file
com.google.api.ads.common.lib.exception.ValidationException if the AdWordsSession did not validate
  public static ExtendedMcc withOAuth2FromFile()
    return new ExtendedMcc(AdWordsSessionUtil.fromFileWithOAuth2());
  }

  
Transforms a regular list of (MCC) ManagedCustomer into a list of ExtendedManagedCustomers.

Note: managedCustomer needs to be a MCC.

Parameters:
managedCustomers a list of (MCC) ManagedCustomers to convert
Returns:
the converted list of ExtendedManagedCustomers
  public static List<ExtendedMccas(List<ManagedCustomermanagedCustomers,
      AdWordsSession adWordsSession) {
    List<ExtendedMcclistExtended = Lists.newArrayListWithCapacity(managedCustomers.size());
    for (ManagedCustomer managedCustomer : managedCustomers) {
      // Creating a specific DelegateLocator for the CustomerId
      listExtended.add(new ExtendedMcc(adWordsSessionmanagedCustomer));
    }
    return listExtended;
  }

  
Retrieves the AdWordsSession for MCC.

Returns:
the AdWordsSession for the MCC
    return ;
  }

  
Retrieves the DelegateLocator for the MCC.

Returns:
the DelegateLocator for the MCC
    return ;
  }

  
Retrieves the clientCustomerId for the MCC.

Returns:
the clientCustomerId for the MCC
  public String getClientCustomerId() {
    return ;
  }

  
Gets the (sub)MCCs for the ExtendedMcc for a list of customerIds.

Parameters:
customerIds the list of MCCs to retrieve
Returns:
a list of (sub) MCCs for the ExtendedMcc from the customerIds list
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
  public List<ManagedCustomergetMccs(List<LongcustomerIdsthrows RemoteException {
        customerIdstrue);
  }

  
Gets the (sub)MCCs for the ExtendedMcc for a list of customerIds.

Parameters:
customerIds the list of MCCs to retrieve
Returns:
a list of (sub) MCCs for the ExtendedMcc from the customerIds list
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
  public List<ExtendedMccgetExtendedMccs(List<LongcustomerIds)
      throws RemoteException {
        customerIdstrue), );
  }

  
Gets the (sub)MCCs for the ExtendedMcc.

Returns:
all the (sub) MCCs for the ExtendedMcc
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
  public List<ManagedCustomergetMccs() throws RemoteException {
    return getMccs(null);
  }

  
Gets the (sub)MCCs for the ExtendedMcc.

Returns:
all the (sub) MCCs for the ExtendedMcc
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
    return getExtendedMccs(null);
  }

  
Gets the (sub)MCCs for the ExtendedMcc for a list of customerIds.

Parameters:
customerId the id of the MCC to retrieve
Returns:
a (sub) MCCs for the ExtendedMcc for the customerId
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
  public ManagedCustomer getMcc(Long customerIdthrows RemoteException {
    ManagedCustomer mcc = getManagedCustomer(customerId);
    if (mcc.getCanManageClients()) {
      return mcc;
    } else {
      throw new UtilityLibraryException("Error: result empty for getMcc(Long customerId)");
    }
  }

  
Gets the (sub)MCCs for the ExtendedMcc for a list of customerIds.

Parameters:
customerId the id of the MCC to retrieve
Returns:
a (sub) MCCs for the ExtendedMcc for the customerId
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
  public ExtendedMcc getExtendedMcc(Long customerIdthrows RemoteException {
      return new ExtendedMcc(mcc.getManagedCustomer());
    } else {
      throw new UtilityLibraryException("Error: result empty for getMcc(Long customerId)");
    }
  }

  
Gets the ManagedCustomers for the ExtendedMcc in the customerIds list.

Parameters:
customerIds the list of ids of the ManagedCustomers to retrieve
Returns:
a list of ManagedCustomer for the ExtendedMcc from the customerIds list
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
  public List<ManagedCustomergetManagedCustomers(List<LongcustomerIdsthrows RemoteException {
        customerIdsfalse);
  }

  
Gets the ManagedCustomers for the ExtendedMcc in the customerIds list.

Parameters:
customerIds the list of ids of the ManagedCustomers to retrieve
Returns:
a list of ExtendedManagedCustomer for the ExtendedMcc from the customerIds list
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
      throws RemoteException {
    return ExtendedManagedCustomer.as(.getManagedCustomerDelegate()
        .getByCustomerIdCanManageClients(customerIdsfalse), );
  }

  
Gets the ManagedCustomers for the ExtendedMcc in the customerIds list.

Note: returns subMccs' ManagedCustomers as well.

Returns:
all the ManagedCustomer for the ExtendedMcc
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
    return getManagedCustomers(null);
  }

  
Gets the ManagedCustomers for the ExtendedMcc between startIndex and numberResults.

Note: returns subMccs' ManagedCustomers as well.

Parameters:
startIndex index of the first result to retrieve
numberResults total number of result to retrieve
Returns:
all the ManagedCustomer for the ExtendedMcc
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
  public List<ManagedCustomergetManagedCustomers(int startIndexint numberResults)
      throws RemoteException {
    return .getManagedCustomerDelegate().get(startIndexnumberResults);
  }

  
Gets the ManagedCustomers for the ExtendedMcc in the customerIds list.

Note: returns subMccs' ManagedCustomers as well.

Returns:
all the ExtendedManagedCustomer for the ExtendedMcc
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
      throws RemoteException {
    return getExtendedManagedCustomers(null);
  }

  
Gets the ManagedCustomers for the ExtendedMcc between startIndex and numberResults.

Note: returns subMccs' ManagedCustomers as well.

Parameters:
startIndex index of the first result to retrieve
numberResults total number of result to retrieve
Returns:
all the ExtendedManagedCustomer for the ExtendedMcc
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
      int startIndexint numberResultsthrows RemoteException {
    return ExtendedManagedCustomer.as(
        getManagedCustomers(startIndexnumberResults), );
  }

  
Gets the ManagedCustomers for the ExtendedMcc in the customerIds list.

Parameters:
customerId the customerId of the ManagedCustomer to retrieve
Returns:
the ManagedCustomer for the customerId
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
  public ManagedCustomer getManagedCustomer(Long customerIdthrows RemoteException {
    return getManagedCustomer(String.valueOf(customerId));
  }

  
Gets the ManagedCustomers for the ExtendedMcc in the customerIds list.

Parameters:
customerId the customerId of the ManagedCustomer to retrieve
Returns:
the ManagedCustomer for the customerId
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
  public ManagedCustomer getManagedCustomer(String customerIdthrows RemoteException {
  }

  
Gets the ManagedCustomers for the ExtendedMcc in the customerIds list.

Parameters:
customerId the customerId of the ManagedCustomer to retrieve
Returns:
the ExtendedManagedCustomer for the customerId
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
      throws RemoteException {
        .getByCustomerId(customerId), );
  }

  
Inserts ManagedCustomers into the ExtendedMcc.

Note: ManagedCustomers cannot be updated/removed.

Parameters:
apiManagedCustomers the list of ManagedCustomers to be inserted
Returns:
the updated list of ExtendedManagedCustomers
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
      List<ManagedCustomerapiManagedCustomersthrows RemoteException {
    return ExtendedManagedCustomer.as(
        .getManagedCustomerDelegate().insert(apiManagedCustomers), );
  }

  
Inserts a ManagedCustomer into the ExtendedMcc.

Note: ManagedCustomers cannot be updated/removed.

Parameters:
apiManagedCustomer the ManagedCustomer to be inserted
Returns:
the updated ExtendedManagedCustomer
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
      throws RemoteException {
    return new ExtendedManagedCustomer(
        .getManagedCustomerDelegate().insert(apiManagedCustomer), );
  }

  
Inserts a ManagedCustomer into the ExtendedMcc.

Note: ManagedCustomers cannot be updated/removed.

Parameters:
name the ManagedCustomer's name
companyName the ManagedCustomer's company name
dateTimeZone the ManagedCustomer's time zone in POSIX: https://developers.google.com/adwords/api/docs/appendix/timezones
currencyCode the ManagedCustomer's currency in ISO 4217 format: https://developers.google.com/adwords/api/docs/appendix/currencycodes
Returns:
the updated ExtendedManagedCustomer
Throws:
com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException if there is an error in the reflection call
java.rmi.RemoteException for communication-related exceptions
      String dateTimeZoneString currencyCodethrows RemoteException {
    ManagedCustomer newManagedCustomer = new ManagedCustomer();
    newManagedCustomer.setName(name);
    newManagedCustomer.setCompanyName(companyName);
    newManagedCustomer.setDateTimeZone(dateTimeZone);
    newManagedCustomer.setCurrencyCode(currencyCode);
    return new ExtendedManagedCustomer(
        .getManagedCustomerDelegate().insert(newManagedCustomer), );
  }

  
Gets all the BillingAccounts for the ExtendedMcc.

Returns:
all the BillingAccounts for the ExtendedMcc
Throws:
java.rmi.RemoteException for communication-related exceptions
  }
New to GrepCode? Check out our FAQ X