Package com.google.api.adwords.v201306.cm

Examples of com.google.api.adwords.v201306.cm.CampaignServiceInterface


  public void testCreateServiceAccountantRemote() throws Exception {
    ServiceAccountantManager instance = ServiceAccountantManager.getInstance();
    instance.setAutoCreateAccountant(false);

    AdWordsUser testUser = new AdWordsUser("test_data/test.properties");
    CampaignServiceInterface campaignService =
        testUser.getService(AdWordsService.V200909.CAMPAIGN_SERVICE);
    campaignService.get(new CampaignSelector());

    assertNull("No service accountant should be created.", instance
        .getServiceAccountant(campaignService));

    ServiceAccountant serviceAccountant =
        ServiceAccountantManager.createServiceAccountant(campaignService);
    assertTrue("Service accountant should be empty.", serviceAccountant.getTotalUnitCount() == 0);

    campaignService.get(new CampaignSelector());

    long totalUnits = serviceAccountant.getTotalUnitCount();
    assertTrue("Service accountant not used.", totalUnits > 0);

    instance.clear();

    campaignService.get(new CampaignSelector());

    assertEquals("Service accountant still used.", totalUnits, serviceAccountant
        .getTotalUnitCount());
  }
View Full Code Here


  public void testCreateServiceAccountantService() throws Exception {
    ServiceAccountantManager instance = ServiceAccountantManager.getInstance();
    instance.setAutoCreateAccountant(false);

    AdWordsUser testUser = new AdWordsUser("test_data/test.properties");
    CampaignServiceInterface campaignService =
        testUser.getService(AdWordsService.V200909.CAMPAIGN_SERVICE);
    campaignService.get(new CampaignSelector());

    assertNull("No service accountant should be created.", instance
        .getServiceAccountant(campaignService));

    ServiceAccountant serviceAccountant =
        ServiceAccountantManager.createServiceAccountant(((Stub) campaignService)._getService());
    assertTrue("Service accountant should be empty.", serviceAccountant.getTotalUnitCount() == 0);

    campaignService.get(new CampaignSelector());

    long totalUnits = serviceAccountant.getTotalUnitCount();
    assertTrue("Service accountant not used.", totalUnits > 0);

    instance.clear();

    campaignService.get(new CampaignSelector());

    assertEquals("Service accountant still used.", totalUnits, serviceAccountant
        .getTotalUnitCount());
  }
View Full Code Here

        public void run() {
          try {
            AdWordsUser testUser = new AdWordsUser("test_data/test.properties");
            ServiceAccountantManager.getInstance().setAutoCreateAccountant(true);

            CampaignServiceInterface campaignService =
                testUser.getService(AdWordsService.V200909.CAMPAIGN_SERVICE);
            AdGroupServiceInterface adGroupService =
                testUser.getService(AdWordsService.V200909.ADGROUP_SERVICE);

            campaignService.get(new CampaignSelector());
            adGroupService.get(new AdGroupSelector());

            ServiceAccountant campaignServiceAccountant =
                ServiceAccountantManager.getInstance().getServiceAccountant(campaignService);
View Full Code Here

   * Performs some API methods via v200909.
   */
  private void performOperations() throws Exception {
    AdWordsUser testUser = new AdWordsUser("test_data/test.properties");

    CampaignServiceInterface campaignService =
        testUser.getService(AdWordsService.V200909.CAMPAIGN_SERVICE);
    AdGroupServiceInterface adGroupService =
        testUser.getService(AdWordsService.V200909.ADGROUP_SERVICE);

    campaignService.get(new CampaignSelector());
    adGroupService.get(new AdGroupSelector());
  }
View Full Code Here

   *
   * @return the ID of the created campaign
   */
  public long createCampaign() throws Exception {
    // Get CampaignService
    CampaignServiceInterface campaignService =
        user.getService(AdWordsService.V201008.CAMPAIGN_SERVICE);

    // Create campaign.
    Campaign campaign = new Campaign();
    campaign.setName("Test Campaign #" + System.currentTimeMillis());
    campaign.setBiddingStrategy(new ManualCPC());
    campaign.setStatus(CampaignStatus.PAUSED);

    // Create budget
    Budget budget = new Budget();
    budget.setPeriod(BudgetBudgetPeriod.DAILY);
    budget.setAmount(new Money(null, 50000000L));
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    campaign.setBudget(budget);

    // Create operations.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);

    CampaignOperation[] operations = new CampaignOperation[] {operation};

    // Add campaign and return campaign ID
    return campaignService.mutate(operations).getValue()[0].getId();
  }
View Full Code Here

   *
   * @param campaignId the id of the campaign
   */
  public void deleteCampaign(long campaignId) throws Exception {
    // Get CampaignService
    CampaignServiceInterface campaignService;

    campaignService = user.getService(AdWordsService.V201008.CAMPAIGN_SERVICE);

    // Create campaign with DELETED status.
    Campaign campaign = new Campaign();
    campaign.setId(campaignId);
    campaign.setStatus(CampaignStatus.DELETED);

    // Create operations.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.SET);

    CampaignOperation[] operations = new CampaignOperation[] {operation};

    // Delete campaign.
    CampaignReturnValue result = campaignService.mutate(operations);
  }
View Full Code Here

          user.getService(AdWordsService.V201306.ADGROUP_SERVICE);

      long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

      // Create ad group with DELETED status.
      AdGroup adGroup = new AdGroup();
      adGroup.setId(adGroupId);
      adGroup.setStatus(AdGroupStatus.DELETED);

      // Create operations.
      AdGroupOperation operation = new AdGroupOperation();
      operation.setOperand(adGroup);
      operation.setOperator(Operator.SET);
View Full Code Here

      Predicate adGroupIdPredicate =
          new Predicate("AdGroupId", PredicateOperator.IN, new String[] {adGroupId.toString()});
      selector.setPredicates(new Predicate[] {adGroupIdPredicate});

      // Get bid landscape for ad group criteria.
      AdGroupBidLandscapePage page = dataService.getAdGroupBidLandscape(selector);

      // Display bid landscapes.
      if (page.getEntries() != null) {
        for (AdGroupBidLandscape adGroupBidLandscape : page.getEntries()) {
          System.out.println("Ad group bid landscape with ad group id \""
              + adGroupBidLandscape.getAdGroupId() + "\", type \""
              + adGroupBidLandscape.getType() + "\", current \""
              + adGroupBidLandscape.getLandscapeCurrent() + "\", start date \""
              + adGroupBidLandscape.getStartDate() + "\", end date \""
View Full Code Here

      Predicate adGroupIdPredicate =
          new Predicate("AdGroupId", PredicateOperator.IN, new String[] {adGroupId.toString()});
      selector.setPredicates(new Predicate[] {statusPredicate, adGroupIdPredicate});

      // Get all active ad group criteria.
      AdGroupCriterionPage page = adGroupCriterionService.get(selector);

      // Display ad group criteria.
      if (page.getEntries() != null && page.getEntries().length > 0) {
        for (AdGroupCriterion adGroupCriterion : page.getEntries()) {
          if (adGroupCriterion instanceof BiddableAdGroupCriterion) {
            BiddableAdGroupCriterion biddableAdGroupCriterion =
                (BiddableAdGroupCriterion) adGroupCriterion;
            System.out.println("Ad group criterion with ad group id \""
                + biddableAdGroupCriterion.getAdGroupId() + "\", criterion id \""
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201306.ADGROUP_CRITERION_SERVICE);

      Long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

      // Create selector.
      Selector selector = new Selector();
      selector.setFields(new String[] {"Id", "AdGroupId", "Status"});
      selector.setOrdering(new OrderBy[] {new OrderBy("Id", SortOrder.ASCENDING)});

      // Create predicates.
      Predicate statusPredicate =
          new Predicate("Status", PredicateOperator.IN, new String[] {"ACTIVE"});
      Predicate adGroupIdPredicate =
          new Predicate("AdGroupId", PredicateOperator.IN, new String[] {adGroupId.toString()});
      selector.setPredicates(new Predicate[] {statusPredicate, adGroupIdPredicate});

      // Get all active ad group criteria.
      AdGroupCriterionPage page = adGroupCriterionService.get(selector);

      // Display ad group criteria.
      if (page.getEntries() != null && page.getEntries().length > 0) {
        for (AdGroupCriterion adGroupCriterion : page.getEntries()) {
          if (adGroupCriterion instanceof BiddableAdGroupCriterion) {
View Full Code Here

TOP

Related Classes of com.google.api.adwords.v201306.cm.CampaignServiceInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.