Search in sources :

Example 1 with Attribute

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;
}
Also used : FeedItem(com.google.api.ads.adwords.axis.v201809.cm.FeedItem) ExtensionFeedItem(com.google.api.ads.adwords.axis.v201809.cm.ExtensionFeedItem) SitelinkFeedItem(com.google.api.ads.adwords.axis.v201809.cm.SitelinkFeedItem) FeedItemAttributeValue(com.google.api.ads.adwords.axis.v201809.cm.FeedItemAttributeValue)

Example 2 with Attribute

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());
}
Also used : ProductCustomAttribute(com.google.api.ads.adwords.axis.v201809.cm.ProductCustomAttribute) Test(org.junit.Test)

Example 3 with Attribute

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());
}
Also used : AdGroupBidLandscapePage(com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage) Test(org.junit.Test)

Example 4 with Attribute

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());
}
Also used : CriterionBidLandscapePage(com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscapePage) Test(org.junit.Test)

Example 5 with Attribute

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;
}
Also used : ArrayList(java.util.ArrayList) CustomParameter(com.google.api.ads.adwords.axis.v201809.cm.CustomParameter) CustomParameters(com.google.api.ads.adwords.axis.v201809.cm.CustomParameters)

Aggregations

ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 FeedItem (com.google.api.ads.adwords.axis.v201809.cm.FeedItem)2 FeedItemAttributeValue (com.google.api.ads.adwords.axis.v201809.cm.FeedItemAttributeValue)2 ProductCustomAttribute (com.google.api.ads.adwords.axis.v201809.cm.ProductCustomAttribute)2 SelectorBuilder (com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder)1 AdGroupBidLandscapePage (com.google.api.ads.adwords.axis.v201809.cm.AdGroupBidLandscapePage)1 AttributeFieldMapping (com.google.api.ads.adwords.axis.v201809.cm.AttributeFieldMapping)1 CampaignCriterion (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterion)1 CampaignCriterionOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionOperation)1 CampaignCriterionReturnValue (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionReturnValue)1 CampaignCriterionServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionServiceInterface)1 ConstantDataServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.ConstantDataServiceInterface)1 CriterionBidLandscapePage (com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscapePage)1 CustomParameter (com.google.api.ads.adwords.axis.v201809.cm.CustomParameter)1 CustomParameters (com.google.api.ads.adwords.axis.v201809.cm.CustomParameters)1 ExtensionFeedItem (com.google.api.ads.adwords.axis.v201809.cm.ExtensionFeedItem)1 FeedItemOperation (com.google.api.ads.adwords.axis.v201809.cm.FeedItemOperation)1 FeedMapping (com.google.api.ads.adwords.axis.v201809.cm.FeedMapping)1 FeedMappingPage (com.google.api.ads.adwords.axis.v201809.cm.FeedMappingPage)1