Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_data_from_identifier(self, identifier):
self._ad_group_negative_sites = _CAMPAIGN_OBJECT_FACTORY.create('AdGroupNegativeSites')
self._ad_group_negative_sites.AdGroupId = identifier.ad_group_id
self._ad_group_name = identifier.ad_group_name
self._campaign_name = identifier.campaign_name
def _convert_bulk_entities_to_target(self):
self.age_target = _CAMPAIGN_OBJECT_FACTORY.create('AgeTarget')
for bid in self.child_entities:
self.age_target.Bids.AgeTargetBid.append(bid.age_target_bid)
self.ensure_location_target()
for bulk_bid in self.child_entities:
if bulk_bid.location_type == 'City':
bid = _CAMPAIGN_OBJECT_FACTORY.create('CityTargetBid')
bid.City = bulk_bid.location
bid.BidAdjustment = bulk_bid.bid_adjustment
bid.IsExcluded = False
self.city_target.Bids.CityTargetBid.append(bid)
elif bulk_bid.location_type == 'MetroArea':
bid = _CAMPAIGN_OBJECT_FACTORY.create('MetroAreaTargetBid')
bid.MetroArea = bulk_bid.location
bid.BidAdjustment = bulk_bid.bid_adjustment
bid.IsExcluded = False
self.metro_area_target.Bids.MetroAreaTargetBid.append(bid)
elif bulk_bid.location_type == 'State':
bid = _CAMPAIGN_OBJECT_FACTORY.create('StateTargetBid')
bid.State = bulk_bid.location
bid.BidAdjustment = bulk_bid.bid_adjustment
bid.IsExcluded = False
self.state_target.Bids.StateTargetBid.append(bid)
elif bulk_bid.location_type == 'Country':
bid = _CAMPAIGN_OBJECT_FACTORY.create('CountryTargetBid')
bid.CountryAndRegion = bulk_bid.location
bid.BidAdjustment = bulk_bid.bid_adjustment
bid.IsExcluded = False
self.country_target.Bids.CountryTargetBid.append(bid)
elif bulk_bid.location_type == 'PostalCode':
bid = _CAMPAIGN_OBJECT_FACTORY.create('PostalCodeTargetBid')
bid.PostalCode = bulk_bid.location
bid.BidAdjustment = bulk_bid.bid_adjustment
bid.IsExcluded = False
self.postal_code_target.Bids.PostalCodeTargetBid.append(bid)
product_partition.Type = 'ProductPartition'
negative_ad_group_criterion = _CAMPAIGN_OBJECT_FACTORY.create('NegativeAdGroupCriterion')
negative_ad_group_criterion.Criterion = product_partition
negative_ad_group_criterion.Type = 'NegativeAdGroupCriterion'
entity.ad_group_criterion = negative_ad_group_criterion
else:
product_partition = _CAMPAIGN_OBJECT_FACTORY.create('ProductPartition')
product_partition.Condition = _CAMPAIGN_OBJECT_FACTORY.create('ProductCondition')
product_partition.Type = 'ProductPartition'
fixed_bid = _CAMPAIGN_OBJECT_FACTORY.create('FixedBid')
fixed_bid.Type = 'FixedBid'
biddable_ad_group_criterion = _CAMPAIGN_OBJECT_FACTORY.create('BiddableAdGroupCriterion')
biddable_ad_group_criterion.Criterion = product_partition
biddable_ad_group_criterion.CriterionBid = fixed_bid
biddable_ad_group_criterion.Type = 'BiddableAdGroupCriterion'
entity.ad_group_criterion = biddable_ad_group_criterion
def _prepare_process_mapping_from_row_values(self):
self._gender_target_bid = _CAMPAIGN_OBJECT_FACTORY.create('GenderTargetBid')
def process_mappings_from_row_values(self, row_values):
self._ad_extension_id_to_entity_id_association = _CAMPAIGN_OBJECT_FACTORY.create('AdExtensionIdToEntityIdAssociation')
row_values.convert_to_entity(self, _BulkAdExtensionAssociation._MAPPINGS)
self._performance_data = PerformanceData.read_from_row_values_or_null(row_values)
def _read_campaign_type(c, v):
if not v:
return []
campaign_type = v
c.campaign.CampaignType = [campaign_type]
if campaign_type.lower() == 'shopping':
c.campaign.Settings = _CAMPAIGN_OBJECT_FACTORY.create('ArrayOfSetting')
shopping_setting = _CAMPAIGN_OBJECT_FACTORY.create('ShoppingSetting')
shopping_setting.Type = 'ShoppingSetting'
c.campaign.Settings.Setting = [shopping_setting]
def set_data_from_identifier(self, identifier):
self._campaign_negative_sites = _CAMPAIGN_OBJECT_FACTORY.create('CampaignNegativeSites')
self.campaign_negative_sites.CampaignId = identifier.campaign_id
self._campaign_name = identifier.campaign_name
def _convert_bulk_entities_to_target(self):
self.gender_target = _CAMPAIGN_OBJECT_FACTORY.create('GenderTarget')
for bid in self.child_entities:
self.gender_target.Bids.GenderTargetBid.append(bid.gender_target_bid)
def process_mappings_from_row_values(self, row_values):
self.call_ad_extension = _CAMPAIGN_OBJECT_FACTORY.create('CallAdExtension')
self.call_ad_extension.Type = 'CallAdExtension'
super(BulkCallAdExtension, self).process_mappings_from_row_values(row_values)
row_values.convert_to_entity(self, BulkCallAdExtension._MAPPINGS)