Search in sources :

Example 1 with AdParamServiceInterface

use of com.google.api.ads.adwords.axis.v201809.cm.AdParamServiceInterface in project googleads-java-lib by googleads.

the class SetAdParameters method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @param adGroupId the ID of the ad group of the keyword.
 * @param keywordId the ID of the keyword.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session, Long adGroupId, Long keywordId) throws RemoteException {
    // Get the AdParamService.
    AdParamServiceInterface adParamService = adWordsServices.get(session, AdParamServiceInterface.class);
    // Create ad params.
    AdParam adParam1 = new AdParam();
    adParam1.setAdGroupId(adGroupId);
    adParam1.setCriterionId(keywordId);
    adParam1.setInsertionText("100");
    adParam1.setParamIndex(1);
    AdParam adParam2 = new AdParam();
    adParam2.setAdGroupId(adGroupId);
    adParam2.setCriterionId(keywordId);
    adParam2.setInsertionText("$40");
    adParam2.setParamIndex(2);
    // Create operations.
    AdParamOperation adParamOperation1 = new AdParamOperation();
    adParamOperation1.setOperand(adParam1);
    adParamOperation1.setOperator(Operator.SET);
    AdParamOperation adParamOperation2 = new AdParamOperation();
    adParamOperation2.setOperand(adParam2);
    adParamOperation2.setOperator(Operator.SET);
    AdParamOperation[] operations = new AdParamOperation[] { adParamOperation1, adParamOperation2 };
    // Set ad parameters.
    AdParam[] adParams = adParamService.mutate(operations);
    // Display ad parameters.
    for (AdParam adParam : adParams) {
        System.out.printf("Ad parameter with ad group ID %d, criterion ID %d, insertion text " + "'%s', and parameter index %d was set.%n", adParam.getAdGroupId(), adParam.getCriterionId(), adParam.getInsertionText(), adParam.getParamIndex());
    }
}
Also used : AdParam(com.google.api.ads.adwords.axis.v201809.cm.AdParam) AdParamOperation(com.google.api.ads.adwords.axis.v201809.cm.AdParamOperation) AdParamServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.AdParamServiceInterface)

Aggregations

AdParam (com.google.api.ads.adwords.axis.v201809.cm.AdParam)1 AdParamOperation (com.google.api.ads.adwords.axis.v201809.cm.AdParamOperation)1 AdParamServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdParamServiceInterface)1