Search in sources :

Example 1 with ServiceQuery

use of com.google.api.ads.adwords.axis.utils.v201809.ServiceQuery 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 2 with ServiceQuery

use of com.google.api.ads.adwords.axis.utils.v201809.ServiceQuery in project googleads-java-lib by googleads.

the class GetCampaignsWithAwql method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @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) throws RemoteException {
    // Get the CampaignService.
    CampaignServiceInterface campaignService = adWordsServices.get(session, CampaignServiceInterface.class);
    ServiceQuery serviceQuery = new ServiceQuery.Builder().fields(CampaignField.Id, CampaignField.Name, CampaignField.Status).orderBy(CampaignField.Name).limit(0, PAGE_SIZE).build();
    CampaignPage page = null;
    do {
        serviceQuery.nextPage(page);
        // Get all campaigns.
        page = campaignService.query(serviceQuery.toString());
        // Display campaigns.
        if (page.getEntries() != null) {
            for (Campaign campaign : page.getEntries()) {
                System.out.printf("Campaign with name '%s' and ID %d was found.%n", campaign.getName(), campaign.getId());
            }
        } else {
            System.out.println("No campaigns were found.");
        }
    } while (serviceQuery.hasNext(page));
}
Also used : CampaignServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.CampaignServiceInterface) Campaign(com.google.api.ads.adwords.axis.v201809.cm.Campaign) CampaignPage(com.google.api.ads.adwords.axis.v201809.cm.CampaignPage) ServiceQuery(com.google.api.ads.adwords.axis.utils.v201809.ServiceQuery)

Example 3 with ServiceQuery

use of com.google.api.ads.adwords.axis.utils.v201809.ServiceQuery in project googleads-java-lib by googleads.

the class GetAllDisapprovedAdsWithAwql method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @param adGroupId the ID of the ad group to search for disapproved ads.
 * @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) throws RemoteException {
    // Get the AdGroupAdService.
    AdGroupAdServiceInterface adGroupAdService = adWordsServices.get(session, AdGroupAdServiceInterface.class);
    ServiceQuery serviceQuery = new ServiceQuery.Builder().fields(AdGroupAdField.Id, AdGroupAdField.PolicySummary).where(AdGroupAdField.AdGroupId).equalTo(adGroupId).where(AdGroupAdField.CombinedApprovalStatus).equalTo(PolicyApprovalStatus.DISAPPROVED.getValue()).orderBy(AdGroupAdField.Id, SortOrder.ASCENDING).limit(0, PAGE_SIZE).build();
    // Get all disapproved ads.
    AdGroupAdPage page = null;
    int disapprovedAdsCount = 0;
    do {
        serviceQuery.nextPage(page);
        page = adGroupAdService.query(serviceQuery.toString());
        // Display ads.
        for (AdGroupAd adGroupAd : page) {
            disapprovedAdsCount++;
            AdGroupAdPolicySummary policySummary = adGroupAd.getPolicySummary();
            System.out.printf("Ad with ID %d and type '%s' was disapproved with the following " + "policy topic entries:%n", adGroupAd.getAd().getId(), adGroupAd.getAd().getAdType());
            // Display the policy topic entries related to the ad disapproval.
            for (PolicyTopicEntry policyTopicEntry : policySummary.getPolicyTopicEntries()) {
                System.out.printf("  topic id: %s, topic name: '%s'%n", policyTopicEntry.getPolicyTopicId(), policyTopicEntry.getPolicyTopicName());
                // Display the attributes and values that triggered the policy topic.
                if (policyTopicEntry.getPolicyTopicEvidences() != null) {
                    for (PolicyTopicEvidence evidence : policyTopicEntry.getPolicyTopicEvidences()) {
                        System.out.printf("    evidence type: %s%n", evidence.getPolicyTopicEvidenceType());
                        if (evidence.getEvidenceTextList() != null) {
                            for (int i = 0; i < evidence.getEvidenceTextList().length; i++) {
                                System.out.printf("      evidence text[%d]: %s%n", i, evidence.getEvidenceTextList(i));
                            }
                        }
                    }
                }
            }
        }
    } while (serviceQuery.hasNext(page));
    System.out.printf("%d disapproved ads were found.%n", disapprovedAdsCount);
}
Also used : AdGroupAdPage(com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdPage) AdGroupAd(com.google.api.ads.adwords.axis.v201809.cm.AdGroupAd) PolicyTopicEvidence(com.google.api.ads.adwords.axis.v201809.cm.PolicyTopicEvidence) AdGroupAdServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdServiceInterface) PolicyTopicEntry(com.google.api.ads.adwords.axis.v201809.cm.PolicyTopicEntry) AdGroupAdPolicySummary(com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdPolicySummary) ServiceQuery(com.google.api.ads.adwords.axis.utils.v201809.ServiceQuery)

Aggregations

ServiceQuery (com.google.api.ads.adwords.axis.utils.v201809.ServiceQuery)3 AdGroupAd (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAd)1 AdGroupAdPage (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdPage)1 AdGroupAdPolicySummary (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdPolicySummary)1 AdGroupAdServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdServiceInterface)1 BidLandscapeLandscapePoint (com.google.api.ads.adwords.axis.v201809.cm.BidLandscapeLandscapePoint)1 Campaign (com.google.api.ads.adwords.axis.v201809.cm.Campaign)1 CampaignPage (com.google.api.ads.adwords.axis.v201809.cm.CampaignPage)1 CampaignServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignServiceInterface)1 CriterionBidLandscape (com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscape)1 CriterionBidLandscapePage (com.google.api.ads.adwords.axis.v201809.cm.CriterionBidLandscapePage)1 DataServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.DataServiceInterface)1 PolicyTopicEntry (com.google.api.ads.adwords.axis.v201809.cm.PolicyTopicEntry)1 PolicyTopicEvidence (com.google.api.ads.adwords.axis.v201809.cm.PolicyTopicEvidence)1