public void Run(AdWordsUser user, long adGroupId)
{
// Get the DataService.
DataService dataService = (DataService) user.GetService(AdWordsService.v201306.DataService);
// Create the selector.
Selector selector = new Selector();
selector.fields = new string[] {"AdGroupId", "LandscapeType", "LandscapeCurrent", "StartDate",
"EndDate", "Bid", "LocalClicks", "LocalCost", "MarginalCpc", "LocalImpressions"};
// Set the filters.
Predicate adGroupPredicate = new Predicate();
adGroupPredicate.field = "AdGroupId";
adGroupPredicate.@operator = PredicateOperator.IN;
adGroupPredicate.values = new string[] {adGroupId.ToString()};
selector.predicates = new Predicate[] {adGroupPredicate};
try {
// Get bid landscape for ad group.
AdGroupBidLandscapePage page = dataService.getAdGroupBidLandscape(selector);
if (page != null && page.entries != null && page.entries.Length > 0) {
foreach (AdGroupBidLandscape bidLandscape in page.entries) {
Console.WriteLine("Found ad group bid landscape with ad group id '{0}', type '{1}', " +
"current: '{2}', start date '{3}', end date '{4}', and landscape points",
bidLandscape.adGroupId, bidLandscape.type, bidLandscape.landscapeCurrent,
bidLandscape.startDate, bidLandscape.endDate);
foreach (BidLandscapeLandscapePoint point in bidLandscape.landscapePoints) {
Console.WriteLine("- bid: {0} => clicks: {1}, cost: {2}, marginalCpc: {3}, " +
"impressions: {4}", point.bid.microAmount, point.bid.microAmount,
point.clicks, point.cost.microAmount, point.marginalCpc.microAmount,
point.impressions);
}
}
} else {
Console.WriteLine("No ad group bid landscapes were found.");
}
} catch (Exception ex) {
throw new System.ApplicationException("Failed to get ad group bid landscapes.", ex);
}
}