use of com.google.api.ads.adwords.axis.v201809.cm.ProductBiddingCategory in project googleads-java-lib by googleads.
the class ProductBiddingCategoryComparatorTest method testDifferByLevel.
@Test
public void testDifferByLevel() {
ProductBiddingCategory category1 = ProductDimensions.createBiddingCategory(ProductDimensionType.BIDDING_CATEGORY_L1, 123L);
ProductBiddingCategory category2 = ProductDimensions.createBiddingCategory(ProductDimensionType.BIDDING_CATEGORY_L2, 123L);
assertThat("Attributes that differ in level # should yield compareTo != 0", comparator.compare(category1, category2), Matchers.not(0));
}
use of com.google.api.ads.adwords.axis.v201809.cm.ProductBiddingCategory in project googleads-java-lib by googleads.
the class ProductDimensions method createBiddingCategory.
/**
* Creates a new ProductBiddingCategory.
*
* @param productDimensionType required
* @param biddingCategoryId may be null if creating an "other" dimension
*/
public static ProductBiddingCategory createBiddingCategory(ProductDimensionType productDimensionType, @Nullable Long biddingCategoryId) {
Preconditions.checkNotNull(productDimensionType, "ProductDimensionType is required when creating a ProductBiddingCategory");
ProductBiddingCategory productBiddingCategory = new ProductBiddingCategory();
productBiddingCategory.setType(productDimensionType);
productBiddingCategory.setValue(biddingCategoryId);
return productBiddingCategory;
}
use of com.google.api.ads.adwords.axis.v201809.cm.ProductBiddingCategory in project googleads-java-lib by googleads.
the class AddProductScope method runExample.
/**
* Runs the example.
*
* @param adWordsServices the services factory.
* @param session the session.
* @param campaignId the ID of the shopping campaign.
* @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 campaignId) throws RemoteException {
// Get the campaign criterion service.
CampaignCriterionServiceInterface campaignCriterionService = adWordsServices.get(session, CampaignCriterionServiceInterface.class);
ProductScope productScope = new ProductScope();
// This set of dimensions is for demonstration purposes only. It would be
// extremely unlikely that you want to include so many dimensions in your
// product scope.
ProductBrand productBrand = new ProductBrand();
productBrand.setValue("Nexus");
ProductCanonicalCondition productCanonicalCondition = new ProductCanonicalCondition();
productCanonicalCondition.setCondition(ProductCanonicalConditionCondition.NEW);
ProductCustomAttribute productCustomAttribute = new ProductCustomAttribute();
productCustomAttribute.setType(ProductDimensionType.CUSTOM_ATTRIBUTE_0);
productCustomAttribute.setValue("my attribute value");
ProductOfferId productOfferId = new ProductOfferId();
productOfferId.setValue("book1");
ProductType productTypeLevel1Media = new ProductType();
productTypeLevel1Media.setType(ProductDimensionType.PRODUCT_TYPE_L1);
productTypeLevel1Media.setValue("Media");
ProductType productTypeLevel2Books = new ProductType();
productTypeLevel2Books.setType(ProductDimensionType.PRODUCT_TYPE_L2);
productTypeLevel2Books.setValue("Books");
// The value for the bidding category is a fixed ID for the 'Luggage & Bags'
// category. You can retrieve IDs for categories from the ConstantDataService.
// See the 'GetProductCategoryTaxonomy' example for more details.
ProductBiddingCategory productBiddingCategory = new ProductBiddingCategory();
productBiddingCategory.setType(ProductDimensionType.BIDDING_CATEGORY_L1);
productBiddingCategory.setValue(-5914235892932915235L);
productScope.setDimensions(new ProductDimension[] { productBrand, productCanonicalCondition, productCustomAttribute, productOfferId, productTypeLevel1Media, productTypeLevel2Books, productBiddingCategory });
CampaignCriterion campaignCriterion = new CampaignCriterion();
campaignCriterion.setCampaignId(campaignId);
campaignCriterion.setCriterion(productScope);
// Create operation.
CampaignCriterionOperation criterionOperation = new CampaignCriterionOperation();
criterionOperation.setOperand(campaignCriterion);
criterionOperation.setOperator(Operator.ADD);
// Make the mutate request.
CampaignCriterionReturnValue result = campaignCriterionService.mutate(new CampaignCriterionOperation[] { criterionOperation });
// Display the result.
System.out.printf("Created a ProductScope criterion with ID %d.%n", result.getValue(0).getCriterion().getId());
}
use of com.google.api.ads.adwords.axis.v201809.cm.ProductBiddingCategory in project googleads-java-lib by googleads.
the class ProductDimensionsTest method testCreateBiddingCategory.
/**
* Test method for createBiddingCategory.
*/
@Test
public void testCreateBiddingCategory() {
ProductBiddingCategory category = ProductDimensions.createBiddingCategory(ProductDimensionType.BIDDING_CATEGORY_L1, 1L);
assertEquals(ProductDimensionType.BIDDING_CATEGORY_L1, category.getType());
assertEquals(Long.valueOf(1), category.getValue());
}
Aggregations