use of com.google.api.ads.adwords.axis.v201809.cm.FeedAttribute in project googleads-java-lib by googleads.
the class AddDynamicPageFeed method createFeed.
/**
* Creates the feed for DSA page URLs.
*/
private static DSAFeedDetails createFeed(AdWordsServicesInterface adWordsServices, AdWordsSession session) throws ApiException, RemoteException {
// Get the FeedService.
FeedServiceInterface feedService = adWordsServices.get(session, FeedServiceInterface.class);
// Create attributes.
FeedAttribute urlAttribute = new FeedAttribute();
urlAttribute.setType(FeedAttributeType.URL_LIST);
urlAttribute.setName("Page URL");
FeedAttribute labelAttribute = new FeedAttribute();
labelAttribute.setType(FeedAttributeType.STRING_LIST);
labelAttribute.setName("Label");
// Create the feed.
Feed dsaPageFeed = new Feed();
dsaPageFeed.setName("DSA Feed #" + System.currentTimeMillis());
dsaPageFeed.setAttributes(new FeedAttribute[] { urlAttribute, labelAttribute });
dsaPageFeed.setOrigin(FeedOrigin.USER);
// Create operation.
FeedOperation operation = new FeedOperation();
operation.setOperand(dsaPageFeed);
operation.setOperator(Operator.ADD);
// Add the feed.
Feed newFeed = feedService.mutate(new FeedOperation[] { operation }).getValue(0);
DSAFeedDetails feedDetails = new DSAFeedDetails();
feedDetails.feedId = newFeed.getId();
FeedAttribute[] savedAttributes = newFeed.getAttributes();
feedDetails.urlAttributeId = savedAttributes[0].getId();
feedDetails.labelAttributeId = savedAttributes[1].getId();
System.out.printf("Feed with name '%s' and ID %d with urlAttributeId %d" + " and labelAttributeId %d was created.%n", newFeed.getName(), feedDetails.feedId, feedDetails.urlAttributeId, feedDetails.labelAttributeId);
return feedDetails;
}
use of com.google.api.ads.adwords.axis.v201809.cm.FeedAttribute 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;
}
use of com.google.api.ads.adwords.axis.v201809.cm.FeedAttribute in project googleads-java-lib by googleads.
the class AddSiteLinksUsingFeeds method createSiteLinksFeed.
private static void createSiteLinksFeed(AdWordsServicesInterface adWordsServices, AdWordsSession session, SiteLinksDataHolder siteLinksData, String feedName) throws RemoteException {
// Get the FeedService.
FeedServiceInterface feedService = adWordsServices.get(session, FeedServiceInterface.class);
// Create attributes.
FeedAttribute textAttribute = new FeedAttribute();
textAttribute.setType(FeedAttributeType.STRING);
textAttribute.setName("Link Text");
FeedAttribute finalUrlAttribute = new FeedAttribute();
finalUrlAttribute.setType(FeedAttributeType.URL_LIST);
finalUrlAttribute.setName("Link Final URLs");
FeedAttribute line2Attribute = new FeedAttribute();
line2Attribute.setType(FeedAttributeType.STRING);
line2Attribute.setName("Line 2");
FeedAttribute line3Attribute = new FeedAttribute();
line3Attribute.setType(FeedAttributeType.STRING);
line3Attribute.setName("Line 3");
// Create the feed.
Feed siteLinksFeed = new Feed();
siteLinksFeed.setName(feedName);
siteLinksFeed.setAttributes(new FeedAttribute[] { textAttribute, finalUrlAttribute, line2Attribute, line3Attribute });
siteLinksFeed.setOrigin(FeedOrigin.USER);
// Create operation.
FeedOperation operation = new FeedOperation();
operation.setOperand(siteLinksFeed);
operation.setOperator(Operator.ADD);
// Add the feed.
FeedReturnValue result = feedService.mutate(new FeedOperation[] { operation });
Feed savedFeed = result.getValue()[0];
siteLinksData.siteLinksFeedId = savedFeed.getId();
FeedAttribute[] savedAttributes = savedFeed.getAttributes();
siteLinksData.linkTextFeedAttributeId = savedAttributes[0].getId();
siteLinksData.linkFinalUrlFeedAttributeId = savedAttributes[1].getId();
siteLinksData.line2FeedAttributeId = savedAttributes[2].getId();
siteLinksData.line3FeedAttributeId = savedAttributes[3].getId();
System.out.printf("Feed with name '%s' and ID %d with linkTextAttributeId %d" + " and linkFinalUrlAttributeId %d and line2AttributeId %d" + " and line3AttributeId %d was created.%n", savedFeed.getName(), savedFeed.getId(), savedAttributes[0].getId(), savedAttributes[1].getId(), savedAttributes[2].getId(), savedAttributes[3].getId());
}
Aggregations