private static CampaignAdExtension getLegacySitelinksForCampaign(
CampaignAdExtensionService campaignExtensionService, long campaignId)
{
// Create the selector.
Selector selector = new Selector();
selector.fields = new string[] {"CampaignId", "AdExtensionId", "Status", "DisplayText",
"DestinationUrl"};
// Filter the results for specified campaign id.
Predicate campaignPredicate = new Predicate();
campaignPredicate.@operator = PredicateOperator.EQUALS;
campaignPredicate.field = "CampaignId";
campaignPredicate.values = new string[] {campaignId.ToString()};
// Filter the results for active campaign ad extensions. You may add
// additional filtering conditions here as required.
Predicate statusPredicate = new Predicate();
statusPredicate.@operator = PredicateOperator.EQUALS;
statusPredicate.field = "Status";
statusPredicate.values = new string[] {CampaignAdExtensionStatus.ACTIVE.ToString()};
// Filter for sitelinks ad extension type.
Predicate typePredicate = new Predicate();
typePredicate.@operator = PredicateOperator.EQUALS;
typePredicate.field = "AdExtensionType";
typePredicate.values = new string[] {"SITELINKS_EXTENSION"};
selector.predicates = new Predicate[] {campaignPredicate, statusPredicate, typePredicate};
CampaignAdExtensionPage page = campaignExtensionService.get(selector);
if (page.entries != null && page.entries.Length > 0) {
return page.entries[0];
} else {
return null;
}
}