Skip to content

Commit dba6136

Browse files
authored
Changes for release v0_2 (#13)
- Regenerate from the latest protos. - Updates to Hotel Ads examples for PercentCpc bidding strategy.
1 parent 2b95332 commit dba6136

32 files changed

Lines changed: 2473 additions & 250 deletions

google-ads-examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<dependency>
5656
<groupId>com.google.api-ads</groupId>
5757
<artifactId>google-ads</artifactId>
58-
<version>0.2.0</version>
58+
<version>0.2.1-SNAPSHOT</version>
5959
</dependency>
6060
<dependency>
6161
<groupId>com.beust</groupId>

google-ads-examples/src/main/java/com/google/ads/googleads/examples/hotelads/AddHotelAd.java

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.google.ads.googleads.lib.GoogleAdsException;
2222
import com.google.ads.googleads.v0.common.Ad;
2323
import com.google.ads.googleads.v0.common.HotelAdInfo;
24-
import com.google.ads.googleads.v0.common.ManualCpc;
24+
import com.google.ads.googleads.v0.common.PercentCpc;
2525
import com.google.ads.googleads.v0.enums.AdGroupAdStatusEnum.AdGroupAdStatus;
2626
import com.google.ads.googleads.v0.enums.AdGroupStatusEnum.AdGroupStatus;
2727
import com.google.ads.googleads.v0.enums.AdGroupTypeEnum.AdGroupType;
@@ -72,6 +72,9 @@ private static class AddHotelAdParams extends CodeSampleParams {
7272

7373
@Parameter(names = ArgumentNames.HOTEL_CENTER_ACCOUNT_ID, required = true)
7474
private Long hotelCenterAccountId;
75+
76+
@Parameter(names = ArgumentNames.CPC_BID_CEILING_MICRO_AMOUNT)
77+
private Long cpcBidCeilingMicroAmount = 20_000_000L;
7578
}
7679

7780
public static void main(String[] args) {
@@ -82,6 +85,7 @@ public static void main(String[] args) {
8285
// into the code here. See the parameter class definition above for descriptions.
8386
params.customerId = Long.parseLong("INSERT_CUSTOMER_ID_HERE");
8487
params.hotelCenterAccountId = Long.parseLong("INSERT_HOTEL_CENTER_ACCOUNT_ID_HERE");
88+
params.cpcBidCeilingMicroAmount = Long.parseLong("INSERT_CPC_BID_CEILING_MICRO_AMOUNT_HERE");
8589
}
8690

8791
GoogleAdsClient googleAdsClient;
@@ -97,7 +101,12 @@ public static void main(String[] args) {
97101
}
98102

99103
try {
100-
new AddHotelAd().runExample(googleAdsClient, params.customerId, params.hotelCenterAccountId);
104+
new AddHotelAd()
105+
.runExample(
106+
googleAdsClient,
107+
params.customerId,
108+
params.hotelCenterAccountId,
109+
params.cpcBidCeilingMicroAmount);
101110
} catch (GoogleAdsException gae) {
102111
// GoogleAdsException is the base class for most exceptions thrown by an API request.
103112
// Instances of this exception have a message and a GoogleAdsFailure that contains a
@@ -119,17 +128,27 @@ public static void main(String[] args) {
119128
* @param googleAdsClient the Google Ads API client.
120129
* @param customerId the client customer ID.
121130
* @param hotelCenterAccountId the Hotel Center account ID.
131+
* @param cpcBidCeilingMicroAmount the maximum bid limit that can be set when creating a campaign
132+
* using the Percent CPC bidding strategy.
122133
* @throws GoogleAdsException if an API request failed with one or more service errors.
123134
*/
124135
private void runExample(
125-
GoogleAdsClient googleAdsClient, long customerId, long hotelCenterAccountId) {
136+
GoogleAdsClient googleAdsClient,
137+
long customerId,
138+
long hotelCenterAccountId,
139+
long cpcBidCeilingMicroAmount) {
126140

127141
// Creates a budget to be used by the campaign that will be created below.
128142
String budgetResourceName = addCampaignBudget(googleAdsClient, customerId);
129143

130144
// Creates a hotel campaign.
131145
String campaignResourceName =
132-
addHotelCampaign(googleAdsClient, customerId, budgetResourceName, hotelCenterAccountId);
146+
addHotelCampaign(
147+
googleAdsClient,
148+
customerId,
149+
budgetResourceName,
150+
hotelCenterAccountId,
151+
cpcBidCeilingMicroAmount);
133152

134153
// Creates a hotel ad group.
135154
String adGroupResourceName = addHotelAdGroup(googleAdsClient, customerId, campaignResourceName);
@@ -174,14 +193,17 @@ private String addCampaignBudget(GoogleAdsClient googleAdsClient, long customerI
174193
* @param customerId the client customer ID.
175194
* @param budgetResourceName the resource name of the budget for the campaign.
176195
* @param hotelCenterAccountId the Hotel Center account ID.
196+
* @param cpcBidCeilingMicroAmount the maximum bid limit that can be set when creating a campaign
197+
* using the Percent CPC bidding strategy.
177198
* @return resource name of the newly created campaign.
178199
* @throws GoogleAdsException if an API request failed with one or more service errors.
179200
*/
180201
private String addHotelCampaign(
181202
GoogleAdsClient googleAdsClient,
182203
long customerId,
183204
String budgetResourceName,
184-
long hotelCenterAccountId) {
205+
long hotelCenterAccountId,
206+
long cpcBidCeilingMicroAmount) {
185207

186208
// Configures the hotel settings.
187209
HotelSettingInfo hotelSettingInfo =
@@ -204,8 +226,12 @@ private String addHotelCampaign(
204226
// the ads from immediately serving. Set to ENABLED once you've added
205227
// targeting and the ads are ready to serve
206228
.setStatus(CampaignStatus.PAUSED)
207-
// Sets the bidding strategy. Only Manual CPC can be used for hotel campaigns.
208-
.setManualCpc(ManualCpc.newBuilder().build())
229+
// Sets the bidding strategy to Percent CPC. Only Manual CPC and Percent CPC can be used
230+
// for hotel campaigns.
231+
.setPercentCpc(
232+
PercentCpc.newBuilder()
233+
.setCpcBidCeilingMicros(Int64Value.of(cpcBidCeilingMicroAmount))
234+
.build())
209235
// Sets the budget.
210236
.setCampaignBudget(StringValue.of(budgetResourceName))
211237
// Adds the networkSettings configured above.

google-ads-examples/src/main/java/com/google/ads/googleads/examples/utils/ArgumentNames.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public final class ArgumentNames {
2323
public static final String CRITERION_ID = "--criterionId";
2424
public static final String CAMPAIGN_BUDGET_ID = "--campaignBudgetId";
2525
public static final String CPC_BID_MICRO_AMOUNT = "--cpcBidMicroAmount";
26+
public static final String CPC_BID_CEILING_MICRO_AMOUNT = "--cpcBidCeilingMicroAmount";
2627
public static final String ARTIFACT_NAME = "--artifactName";
2728
public static final String KEYWORD_TEXT = "--keywordText";
2829
public static final String RECOMMENDATION_ID = "--recommendationId";

google-ads/src/main/java/com/google/ads/googleads/v0/common/BiddingProto.java

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)