Search in sources :

Example 1 with AdCustomizerFeedServiceInterface

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

the class AddAdCustomizer method createCustomizerFeed.

/**
 * Creates a new AdCustomizerFeed.
 *
 * @param feedName the name of the new AdCustomizerFeed
 * @return The new AdCustomizerFeed
 */
private static AdCustomizerFeed createCustomizerFeed(AdWordsServicesInterface adWordsServices, AdWordsSession session, String feedName) throws RemoteException {
    // Get the AdCustomizerFeedService.
    AdCustomizerFeedServiceInterface adCustomizerFeedService = adWordsServices.get(session, AdCustomizerFeedServiceInterface.class);
    AdCustomizerFeed customizerFeed = new AdCustomizerFeed();
    customizerFeed.setFeedName(feedName);
    AdCustomizerFeedAttribute nameAttribute = new AdCustomizerFeedAttribute();
    nameAttribute.setName("Name");
    nameAttribute.setType(AdCustomizerFeedAttributeType.STRING);
    AdCustomizerFeedAttribute priceAttribute = new AdCustomizerFeedAttribute();
    priceAttribute.setName("Price");
    priceAttribute.setType(AdCustomizerFeedAttributeType.STRING);
    AdCustomizerFeedAttribute dateAttribute = new AdCustomizerFeedAttribute();
    dateAttribute.setName("Date");
    dateAttribute.setType(AdCustomizerFeedAttributeType.DATE_TIME);
    customizerFeed.setFeedAttributes(new AdCustomizerFeedAttribute[] { nameAttribute, priceAttribute, dateAttribute });
    AdCustomizerFeedOperation feedOperation = new AdCustomizerFeedOperation();
    feedOperation.setOperand(customizerFeed);
    feedOperation.setOperator(Operator.ADD);
    AdCustomizerFeed addedFeed = adCustomizerFeedService.mutate(new AdCustomizerFeedOperation[] { feedOperation }).getValue()[0];
    System.out.printf("Created ad customizer feed with ID %d, name '%s' and attributes:%n", addedFeed.getFeedId(), addedFeed.getFeedName());
    for (AdCustomizerFeedAttribute feedAttribute : addedFeed.getFeedAttributes()) {
        System.out.printf("  ID: %d, name: '%s', type: %s%n", feedAttribute.getId(), feedAttribute.getName(), feedAttribute.getType());
    }
    return addedFeed;
}
Also used : AdCustomizerFeedAttribute(com.google.api.ads.adwords.axis.v201809.cm.AdCustomizerFeedAttribute) AdCustomizerFeedServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.AdCustomizerFeedServiceInterface) AdCustomizerFeed(com.google.api.ads.adwords.axis.v201809.cm.AdCustomizerFeed) AdCustomizerFeedOperation(com.google.api.ads.adwords.axis.v201809.cm.AdCustomizerFeedOperation)

Aggregations

AdCustomizerFeed (com.google.api.ads.adwords.axis.v201809.cm.AdCustomizerFeed)1 AdCustomizerFeedAttribute (com.google.api.ads.adwords.axis.v201809.cm.AdCustomizerFeedAttribute)1 AdCustomizerFeedOperation (com.google.api.ads.adwords.axis.v201809.cm.AdCustomizerFeedOperation)1 AdCustomizerFeedServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdCustomizerFeedServiceInterface)1