Search in sources :

Example 1 with CriterionBidLandscapePage

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

the class ServiceQueryTest method testHasNextWithNullEntriesOnCriterionBidLandscapePage.

/**
 * Tests {@link ServiceQuery#hasNext(CriterionBidLandscapePage)} when the page has a null {@code
 * entries} array.
 */
@Test
public void testHasNextWithNullEntriesOnCriterionBidLandscapePage() {
    CriterionBidLandscapePage page = new CriterionBidLandscapePage();
    page.setEntries(null);
    assertFalse("hasNext should return false if entries is null", serviceQuery.hasNext(page));
    assertEquals("AWQL should not change after calling hasNext", expectedAwql, serviceQuery.toString());
}
Also used : CriterionBidLandscapePage(com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscapePage) Test(org.junit.Test)

Example 2 with CriterionBidLandscapePage

use of com.google.api.ads.adwords.jaxws.v201809.cm.CriterionBidLandscapePage 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 3 with CriterionBidLandscapePage

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

the class GetKeywordBidSimulations method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @param adGroupId the ID of the ad group.
 * @param criterionId the ID of the criterion.
 * @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 adGroupId, Long criterionId) throws RemoteException {
    // Get the DataService.
    DataServiceInterface dataService = adWordsServices.get(session, DataServiceInterface.class);
    // Create a query to select all keyword bid simulations for the ad group.
    ServiceQuery query = new ServiceQuery.Builder().fields(DataField.AdGroupId, DataField.CriterionId, DataField.StartDate, DataField.EndDate, DataField.Bid, DataField.BiddableConversions, DataField.BiddableConversionsValue, DataField.LocalClicks, DataField.LocalCost, DataField.LocalImpressions).where(DataField.AdGroupId).equalTo(adGroupId).where(DataField.CriterionId).equalTo(criterionId).limit(0, PAGE_SIZE).build();
    // Display bid landscapes.
    CriterionBidLandscapePage page = null;
    do {
        query.nextPage(page);
        // Retrieve keyword bid simulations one page at a time, continuing to request pages until all
        // of them have been retrieved.
        page = dataService.queryCriterionBidLandscape(query.toString());
        if (page.getEntries() != null) {
            for (CriterionBidLandscape criterionBidLandscape : page.getEntries()) {
                System.out.printf("Criterion bid landscape with ad group ID %d, criterion ID %d, " + "start date %s, end date %s, with landscape points:%n", criterionBidLandscape.getAdGroupId(), criterionBidLandscape.getCriterionId(), criterionBidLandscape.getStartDate(), criterionBidLandscape.getEndDate());
                for (BidLandscapeLandscapePoint bidLanscapePoint : criterionBidLandscape.getLandscapePoints()) {
                    System.out.printf("\t{bid: %d clicks: %d cost: %d impressions: %d, biddable conversions: %.2f, " + "biddable conversions value: %.2f}%n", bidLanscapePoint.getBid().getMicroAmount(), bidLanscapePoint.getClicks(), bidLanscapePoint.getCost().getMicroAmount(), bidLanscapePoint.getImpressions(), bidLanscapePoint.getBiddableConversions(), bidLanscapePoint.getBiddableConversionsValue());
                }
                System.out.println(" was found.");
            }
        }
    } while (query.hasNext(page));
}
Also used : CriterionBidLandscapePage(com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscapePage) CriterionBidLandscape(com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscape) DataServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.DataServiceInterface) BidLandscapeLandscapePoint(com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint) ServiceQuery(com.google.api.ads.adwords.axis.utils.v201809.ServiceQuery)

Example 4 with CriterionBidLandscapePage

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

the class GetCampaignCriterionBidModifierSimulations method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @param campaignId the ID of the 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 DataService.
    DataServiceInterface dataService = adWordsServices.get(session, DataServiceInterface.class);
    // Create selector.
    Selector selector = new SelectorBuilder().fields(DataField.BidModifier, DataField.CampaignId, DataField.CriterionId, DataField.StartDate, DataField.EndDate, DataField.LocalClicks, DataField.LocalCost, DataField.LocalImpressions, DataField.TotalLocalClicks, DataField.TotalLocalCost, DataField.TotalLocalImpressions, DataField.RequiredBudget).equals(DataField.CampaignId, campaignId.toString()).limit(PAGE_SIZE).build();
    // Display bid landscapes.
    int landscapePointsInPreviousPage = 0;
    int startIndex = 0;
    do {
        // Offset the start index by the number of landscape points in the last retrieved page,
        // NOT the number of entries (bid landscapes) in the page.
        startIndex += landscapePointsInPreviousPage;
        selector.getPaging().setStartIndex(startIndex);
        // Reset the count of landscape points in preparation for processing the next page.
        landscapePointsInPreviousPage = 0;
        // Request the next page of bid landscapes.
        CriterionBidLandscapePage page = dataService.getCampaignCriterionBidLandscape(selector);
        if (page.getEntries() != null) {
            for (CriterionBidLandscape criterionBidLandscape : page.getEntries()) {
                System.out.printf("Found campaign-level criterion bid modifier landscape for" + " criterion with ID %d, start date '%s', end date '%s', and" + " landscape points:%n", criterionBidLandscape.getCriterionId(), criterionBidLandscape.getStartDate(), criterionBidLandscape.getEndDate());
                for (BidLandscapeLandscapePoint bidLandscapePoint : criterionBidLandscape.getLandscapePoints()) {
                    landscapePointsInPreviousPage++;
                    System.out.printf("  {bid modifier: %.2f => clicks: %d, cost: %d, impressions: %d, " + "total clicks: %d, total cost: %d, total impressions: %d, and " + "required budget: %d%n", bidLandscapePoint.getBidModifier(), bidLandscapePoint.getClicks(), bidLandscapePoint.getCost().getMicroAmount(), bidLandscapePoint.getImpressions(), bidLandscapePoint.getTotalLocalClicks(), bidLandscapePoint.getTotalLocalCost().getMicroAmount(), bidLandscapePoint.getTotalLocalImpressions(), bidLandscapePoint.getRequiredBudget().getMicroAmount());
                }
            }
        }
    } while (landscapePointsInPreviousPage >= PAGE_SIZE);
}
Also used : SelectorBuilder(com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder) CriterionBidLandscapePage(com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscapePage) CriterionBidLandscape(com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscape) DataServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.DataServiceInterface) BidLandscapeLandscapePoint(com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint) BidLandscapeLandscapePoint(com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint) Selector(com.google.api.ads.adwords.axis.v201809.cm.Selector)

Example 5 with CriterionBidLandscapePage

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

the class ServiceQueryTest method testHasNextWithEmptyEntriesOnCriterionBidLandscapePage.

/**
 * Tests {@link ServiceQuery#hasNext(CriterionBidLandscapePage)} when the page has an empty {@code
 * entries} list.
 */
@Test
public void testHasNextWithEmptyEntriesOnCriterionBidLandscapePage() {
    CriterionBidLandscapePage page = new CriterionBidLandscapePage();
    assertFalse("hasNext should return false if entries is null", serviceQuery.hasNext(page));
    assertEquals("AWQL should not change after calling hasNext", expectedAwql, serviceQuery.toString());
}
Also used : CriterionBidLandscapePage(com.google.api.ads.adwords.jaxws.v201809.cm.CriterionBidLandscapePage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 CriterionBidLandscapePage (com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscapePage)7 CriterionBidLandscapePage (com.google.api.ads.adwords.jaxws.v201809.cm.CriterionBidLandscapePage)5 BidLandscapeLandscapePoint (com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint)4 CriterionBidLandscape (com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscape)4 ArrayList (java.util.ArrayList)4 DataServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.DataServiceInterface)2 BidLandscapeLandscapePoint (com.google.api.ads.adwords.jaxws.v201809.cm.BidLandscapeLandscapePoint)2 CriterionBidLandscape (com.google.api.ads.adwords.jaxws.v201809.cm.CriterionBidLandscape)2 SelectorBuilder (com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder)1 ServiceQuery (com.google.api.ads.adwords.axis.utils.v201809.ServiceQuery)1 Selector (com.google.api.ads.adwords.axis.v201809.cm.Selector)1