Package com.google.api.adwords.v201008.cm

Examples of com.google.api.adwords.v201008.cm.CampaignAdExtensionServiceInterface


  public void testGetMonthlyLimits() throws Exception {
    // Create selector.
    InfoSelector selector = new InfoSelector();
    selector.setApiUsageType(ApiUsageType.UNIT_COUNT);

    ApiUsageInfo apiUsageInfo = service.get(selector);

    assertNull(apiUsageInfo.getApiUsageRecords());
    assertNotNull(apiUsageInfo.getCost());
  }
View Full Code Here


    // Create selector.
    DateRange range = new DateRange(TestUtils.firstDayOfMonth(), TestUtils.today());
    InfoSelector selector = new InfoSelector("CampaignService", "mutate", Operator.ADD, range,
        new String[] {clientId}, ApiUsageType.UNIT_COUNT_FOR_CLIENTS);

    ApiUsageInfo apiUsageInfo = service.get(selector);

    assertNotNull(apiUsageInfo.getApiUsageRecords());
    assertEquals(clientId, apiUsageInfo.getApiUsageRecords()[0].getClientEmail());
    assertNotNull(apiUsageInfo.getApiUsageRecords()[0].getCost());
  }
View Full Code Here

    // Create selector.
    DateRange range = new DateRange(TestUtils.firstDayOfMonth(), TestUtils.today());
    InfoSelector selector = new InfoSelector("CampaignService", "mutate", Operator.ADD, range,
        null, ApiUsageType.METHOD_COST);

    ApiUsageInfo apiUsageInfo = service.get(selector);

    assertNull(apiUsageInfo.getApiUsageRecords());
    assertNotNull(apiUsageInfo.getCost());
  }
View Full Code Here

  /**
   * Test getting API usage.
   */
  public void testGetApiUsage() throws Exception {
    // Create selector.
    InfoSelector selector = new InfoSelector();
    selector.setServiceName("CampaignService");
    selector.setMethodName("mutate");
    selector.setOperator(Operator.ADD);
    selector.setDateRange(new DateRange(TestUtils.firstDayOfMonth(), TestUtils.today()));
    selector.setApiUsageType(ApiUsageType.UNIT_COUNT);

    ApiUsageInfo apiUsageInfo = service.get(selector);

    assertNull(apiUsageInfo.getApiUsageRecords());
    assertNotNull(apiUsageInfo.getCost());
View Full Code Here

  /**
   * Test getting monthly API usage limits.
   */
  public void testGetMonthlyLimits() throws Exception {
    // Create selector.
    InfoSelector selector = new InfoSelector();
    selector.setApiUsageType(ApiUsageType.UNIT_COUNT);

    ApiUsageInfo apiUsageInfo = service.get(selector);

    assertNull(apiUsageInfo.getApiUsageRecords());
    assertNotNull(apiUsageInfo.getCost());
View Full Code Here

   * Test getting a unit count for clients.
   */
  public void testGetntCountForClients() throws Exception {
    // Create selector.
    DateRange range = new DateRange(TestUtils.firstDayOfMonth(), TestUtils.today());
    InfoSelector selector = new InfoSelector("CampaignService", "mutate", Operator.ADD, range,
        new String[] {clientId}, ApiUsageType.UNIT_COUNT_FOR_CLIENTS);

    ApiUsageInfo apiUsageInfo = service.get(selector);

    assertNotNull(apiUsageInfo.getApiUsageRecords());
View Full Code Here

   * Test getting the cost of a method.
   */
  public void testGetMethodCost() throws Exception {
    // Create selector.
    DateRange range = new DateRange(TestUtils.firstDayOfMonth(), TestUtils.today());
    InfoSelector selector = new InfoSelector("CampaignService", "mutate", Operator.ADD, range,
        null, ApiUsageType.METHOD_COST);

    ApiUsageInfo apiUsageInfo = service.get(selector);

    assertNull(apiUsageInfo.getApiUsageRecords());
View Full Code Here

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

      // Get the CampaignAdExtensionService.
      CampaignAdExtensionServiceInterface campaignAdExtensionService =
          user.getService(AdWordsService.V201306.CAMPAIGN_AD_EXTENSION_SERVICE);

      Long campaignId = Long.parseLong("INSERT_CAMPAIGN_ID_HERE");

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

      // Create predicates.
      Predicate campaignIdPredicate =
          new Predicate("CampaignId", PredicateOperator.IN, new String[] {campaignId.toString()});
      selector.setPredicates(new Predicate[] {campaignIdPredicate});

      // Get all campaign ad extensions.
      CampaignAdExtensionPage page = campaignAdExtensionService.get(selector);

      // Display campaign ad extensions.
      if (page.getEntries() != null && page.getEntries().length > 0) {
        for (CampaignAdExtension campaignAdExtension : page.getEntries()) {
          System.out.println("Campaign ad extension with campaign id \""
View Full Code Here

    runExample(user, campaignIds);
  }

  public static void runExample(AdWordsUser user, long[] campaignIds) throws Exception {
    // Get the CampaignAdExtensionService.
    CampaignAdExtensionServiceInterface campaignExtensionService =
        user.getService(AdWordsService.V201306.CAMPAIGN_AD_EXTENSION_SERVICE);
    // Get the FeedMappingService.
    FeedMappingServiceInterface feedMappingService =
        user.getService(AdWordsService.V201306.FEED_MAPPING_SERVICE);
    // Get the FeedService.
View Full Code Here

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

      // Get the CampaignAdExtensionService.
      CampaignAdExtensionServiceInterface campaignAdExtensionService =
          user.getService(AdWordsService.V201306.CAMPAIGN_AD_EXTENSION_SERVICE);

      // Get the GeoLocationService.
      GeoLocationServiceInterface geoLocationService =
          user.getService(AdWordsService.V201306.GEO_LOCATION_SERVICE);

      long campaignId = Long.parseLong("INSERT_CAMPAIGN_ID_HERE");

      // Create address.
      Address address = new Address();
      address.setStreetAddress("1600 Amphitheatre Parkway");
      address.setCityName("Mountain View");
      address.setProvinceCode("US-CA");
      address.setPostalCode("94043");
      address.setCountryCode("US");

      // Create geo location selector.
      GeoLocationSelector selector = new GeoLocationSelector();
      selector.setAddresses(new Address[] {address});

      // Get geo location.
      GeoLocation[] geoLocationResult = geoLocationService.get(selector);
      GeoLocation geoLocation = geoLocationResult[0];

      // Create location extension.
      LocationExtension locationExtension = new LocationExtension();
      locationExtension.setAddress(geoLocation.getAddress());
      locationExtension.setGeoPoint(geoLocation.getGeoPoint());
      locationExtension.setEncodedLocation(geoLocation.getEncodedLocation());
      locationExtension.setCompanyName("Google");
      locationExtension.setPhoneNumber("650-253-0000");
      locationExtension.setSource(LocationExtensionSource.ADWORDS_FRONTEND);

      // Create campaign ad extension.
      CampaignAdExtension campaignAdExtension = new CampaignAdExtension();
      campaignAdExtension.setCampaignId(campaignId);
      campaignAdExtension.setAdExtension(locationExtension);

      // Create operations.
      CampaignAdExtensionOperation operation = new CampaignAdExtensionOperation();
      operation.setOperand(campaignAdExtension);
      operation.setOperator(Operator.ADD);

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

      // Add campaign ad extension.
      CampaignAdExtensionReturnValue result = campaignAdExtensionService.mutate(operations);

      // Display campaign ad extensions.
      if (result != null && result.getValue() != null) {
        for (CampaignAdExtension campaignAdExtensionResult : result.getValue()) {
          System.out.println("Campaign ad extension with campaign id \""
View Full Code Here

TOP

Related Classes of com.google.api.adwords.v201008.cm.CampaignAdExtensionServiceInterface

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.