use of com.google.api.ads.adwords.axis.v201809.o.Attribute in project googleads-java-lib by googleads.
the class MigrateToExtensionSettings method getSiteLinksFromFeed.
/**
* Gets the site links from a feed.
*
* @return a map of feed item ID to SiteLinkFromFeed
*/
private static Map<Long, SiteLinkFromFeed> getSiteLinksFromFeed(AdWordsServicesInterface adWordsServices, AdWordsSession session, Feed feed) throws RemoteException {
// Retrieve the feed's attribute mapping.
Multimap<Long, Integer> feedMappings = getFeedMapping(adWordsServices, session, feed, PLACEHOLDER_SITELINKS);
Map<Long, SiteLinkFromFeed> feedItems = Maps.newHashMap();
for (FeedItem feedItem : getFeedItems(adWordsServices, session, feed)) {
SiteLinkFromFeed siteLinkFromFeed = new SiteLinkFromFeed();
for (FeedItemAttributeValue attributeValue : feedItem.getAttributeValues()) {
// Skip this attribute if it hasn't been mapped to a field.
if (!feedMappings.containsKey(attributeValue.getFeedAttributeId())) {
continue;
}
for (Integer fieldId : feedMappings.get(attributeValue.getFeedAttributeId())) {
switch(fieldId) {
case PLACEHOLDER_FIELD_SITELINK_LINK_TEXT:
siteLinkFromFeed.text = attributeValue.getStringValue();
break;
case PLACEHOLDER_FIELD_SITELINK_URL:
siteLinkFromFeed.url = attributeValue.getStringValue();
break;
case PLACEHOLDER_FIELD_FINAL_URLS:
siteLinkFromFeed.finalUrls = attributeValue.getStringValues();
break;
case PLACEHOLDER_FIELD_FINAL_MOBILE_URLS:
siteLinkFromFeed.finalMobileUrls = attributeValue.getStringValues();
break;
case PLACEHOLDER_FIELD_TRACKING_URL_TEMPLATE:
siteLinkFromFeed.trackingUrlTemplate = attributeValue.getStringValue();
break;
case PLACEHOLDER_FIELD_LINE_2_TEXT:
siteLinkFromFeed.line2 = attributeValue.getStringValue();
break;
case PLACEHOLDER_FIELD_LINE_3_TEXT:
siteLinkFromFeed.line3 = attributeValue.getStringValue();
break;
default:
// Ignore attributes that do not map to a predefined placeholder field.
break;
}
}
}
feedItems.put(feedItem.getFeedItemId(), siteLinkFromFeed);
}
return feedItems;
}
use of com.google.api.ads.adwords.axis.v201809.o.Attribute in project googleads-java-lib by googleads.
the class ProductDimensionsTest method testCreateCustomAttribute.
/**
* Test method for createCustomAttribute.
*/
@Test
public void testCreateCustomAttribute() {
ProductCustomAttribute attribute = ProductDimensions.createCustomAttribute(ProductDimensionType.CUSTOM_ATTRIBUTE_2, STRING_VALUE);
assertEquals(ProductDimensionType.CUSTOM_ATTRIBUTE_2, attribute.getType());
assertEquals(STRING_VALUE, attribute.getValue());
}
use of com.google.api.ads.adwords.axis.v201809.o.Attribute in project googleads-java-lib by googleads.
the class ServiceQueryTest method testNextPageWithNullEntriesOnAdGroupBidLandscapePage.
/**
* Tests using {@link ServiceQuery#nextPage(AdGroupBidLandscapePage)} when the passed page has
* a null {@code entries} array.
*/
@Test
public void testNextPageWithNullEntriesOnAdGroupBidLandscapePage() {
AdGroupBidLandscapePage page = new AdGroupBidLandscapePage();
page.setEntries(null);
serviceQuery.nextPage(page);
assertEquals(expectedAwql, serviceQuery.toString());
// LIMIT clause stays the same as long as the page entries attribute is null.
serviceQuery.nextPage(page);
assertEquals(expectedAwql, serviceQuery.toString());
}
use of com.google.api.ads.adwords.axis.v201809.o.Attribute in project googleads-java-lib by googleads.
the class ServiceQueryTest method testNextPageWithNullEntriesOnCriterionBidLandscapePage.
/**
* Tests using {@link ServiceQuery#nextPage(CriterionBidLandscapePage)} when the passed page has
* a null {@code entries} array.
*/
@Test
public void testNextPageWithNullEntriesOnCriterionBidLandscapePage() {
CriterionBidLandscapePage page = new CriterionBidLandscapePage();
page.setEntries(null);
serviceQuery.nextPage(page);
assertEquals(expectedAwql, serviceQuery.toString());
// LIMIT clause stays the same as long as the page entries attribute is null.
serviceQuery.nextPage(page);
assertEquals(expectedAwql, serviceQuery.toString());
}
use of com.google.api.ads.adwords.axis.v201809.o.Attribute in project googleads-java-lib by googleads.
the class ProductPartitionNodeAdapter method createCustomParameters.
/**
* Creates an AdWords API {@link CustomParameters} object using the map of custom parameters
* on the node.
*
* @param node the node.
*/
private static CustomParameters createCustomParameters(ProductPartitionNode node) {
Preconditions.checkArgument(node.isBiddableUnit(), "Node is not a biddable unit. Custom parameters not supported.");
CustomParameters customParameters = new CustomParameters();
List<CustomParameter> parameters = new ArrayList<>();
for (Entry<String, String> customParamEntry : node.getCustomParameters().entrySet()) {
CustomParameter customParameter = new CustomParameter();
customParameter.setKey(customParamEntry.getKey());
customParameter.setValue(customParamEntry.getValue());
parameters.add(customParameter);
}
customParameters.setParameters(parameters.toArray(new CustomParameter[0]));
// Always replace all custom parameters. This attribute is ignored on ADD.
customParameters.setDoReplace(true);
return customParameters;
}
Aggregations