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_address_part(bulk_ad_extension, set_func):
if bulk_ad_extension.location_ad_extension.Address is None:
bulk_ad_extension.location_ad_extension.Address = _CAMPAIGN_OBJECT_FACTORY_V12.create('Address')
set_func(bulk_ad_extension.location_ad_extension.Address)
def parse_fixed_bid(value):
if not value:
return None
fixed_bid = _CAMPAIGN_OBJECT_FACTORY_V12.create('FixedBid')
fixed_bid.Amount = float(value)
return fixed_bid
def process_mappings_from_row_values(self, row_values):
self.responsive_search_ad = _CAMPAIGN_OBJECT_FACTORY_V12.create('ResponsiveSearchAd')
self.responsive_search_ad.Type = 'ResponsiveSearch'
super(BulkResponsiveSearchAd, self).process_mappings_from_row_values(row_values)
row_values.convert_to_entity(self, BulkResponsiveSearchAd._MAPPINGS)
if is_excluded:
product_partition = _CAMPAIGN_OBJECT_FACTORY_V12.create('ProductPartition')
product_partition.Condition = _CAMPAIGN_OBJECT_FACTORY_V12.create('ProductCondition')
product_partition.Type = 'ProductPartition'
negative_ad_group_criterion = _CAMPAIGN_OBJECT_FACTORY_V12.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_V12.create('ProductPartition')
product_partition.Condition = _CAMPAIGN_OBJECT_FACTORY_V12.create('ProductCondition')
product_partition.Type = 'ProductPartition'
bid = _CAMPAIGN_OBJECT_FACTORY_V12.create('FixedBid')
bid.Type = 'FixedBid'
biddable_ad_group_criterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('BiddableAdGroupCriterion')
biddable_ad_group_criterion.Criterion = product_partition
success, bid_value = row_values.try_get_value(_StringTable.Bid)
if success and bid_value is not None and bid_value != '':
bid.Amount = float(bid_value)
else:
success, bid_value = row_values.try_get_value(_StringTable.BidAdjustment)
if success and bid_value is not None and bid_value != '':
bid = _CAMPAIGN_OBJECT_FACTORY_V12.create('BidMultiplier')
bid.Type = 'BidMultiplier'
bid.Multiplier = float(bid_value)
biddable_ad_group_criterion.CriterionBid = bid
def process_mappings_from_row_values(self, row_values):
self._biddable_ad_group_criterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('BiddableAdGroupCriterion')
self._biddable_ad_group_criterion.Type = 'BiddableAdGroupCriterion'
self._biddable_ad_group_criterion.Criterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('Webpage')
self._biddable_ad_group_criterion.Criterion.Type = 'Webpage'
self._biddable_ad_group_criterion.CriterionBid = _CAMPAIGN_OBJECT_FACTORY_V12.create('FixedBid')
self._biddable_ad_group_criterion.CriterionBid.Type = 'FixedBid'
row_values.convert_to_entity(self, BulkAdGroupDynamicSearchAdTarget._MAPPINGS)
self._performance_data = PerformanceData.read_from_row_values_or_null(row_values)
custom_param_pattern = "^\\{_(.*?)\\}=(.*$)"
BudgetLimitType = _CAMPAIGN_OBJECT_FACTORY_V12.create('BudgetLimitType')
DynamicSearchAdsSetting = _CAMPAIGN_OBJECT_FACTORY_V12.create('DynamicSearchAdsSetting')
Webpage = _CAMPAIGN_OBJECT_FACTORY_V12.create('Webpage')
WebpageConditionOperand = _CAMPAIGN_OBJECT_FACTORY_V12.create('WebpageConditionOperand')
RemarketingRule = _CAMPAIGN_OBJECT_FACTORY_V12.create('RemarketingRule')
PageVisitorsRule = _CAMPAIGN_OBJECT_FACTORY_V12.create('PageVisitorsRule')
PageVisitorsWhoVisitedAnotherPageRule = _CAMPAIGN_OBJECT_FACTORY_V12.create('PageVisitorsWhoVisitedAnotherPageRule')
PageVisitorsWhoDidNotVisitAnotherPageRule = _CAMPAIGN_OBJECT_FACTORY_V12.create('PageVisitorsWhoDidNotVisitAnotherPageRule')
CustomEventsRule = _CAMPAIGN_OBJECT_FACTORY_V12.create('CustomEventsRule')
StringOperator = _CAMPAIGN_OBJECT_FACTORY_V12.create('StringOperator')
NumberOperator = _CAMPAIGN_OBJECT_FACTORY_V12.create('NumberOperator')
AudienceCriterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('AudienceCriterion')
BidMultiplier = _CAMPAIGN_OBJECT_FACTORY_V12.create('BidMultiplier')
AgeCriterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('AgeCriterion')
DayTimeCriterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('DayTimeCriterion')
DeviceCriterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('DeviceCriterion')
GenderCriterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('GenderCriterion')
LocationCriterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('LocationCriterion')
LocationIntentCriterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('LocationIntentCriterion')
RadiusCriterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('RadiusCriterion')
TargetSetting_Type = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('TargetSetting'))
CoOpSetting_Type = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('CoOpSetting'))
TextAsset_Type = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('TextAsset'))
ImageAsset_Type = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('ImageAsset'))
def bulk_str(value):
if value is None or (hasattr(value, 'value') and value.value is None):
from bingads.v12.bulk.entities import PerformanceData
from bingads.service_client import _CAMPAIGN_OBJECT_FACTORY_V12
from bingads.v12.internal.bulk.string_table import _StringTable
from bingads.v12.internal.bulk.entities.single_record_bulk_entity import _SingleRecordBulkEntity
from bingads.v12.internal.bulk.mappings import _SimpleBulkMapping
from bingads.v12.internal.extensions import *
# Define type used
ProductAd = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('ProductAd'))
TextAd = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('TextAd'))
AppInstallAd = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('AppInstallAd'))
ExpandedTextAd = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('ExpandedTextAd'))
DynamicSearchAd = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('DynamicSearchAd'))
ResponsiveSearchAd = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('ResponsiveSearchAd'))
ResponsiveAd = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('ResponsiveAd'))
class _BulkAd(_SingleRecordBulkEntity):
""" This abstract base class provides properties that are shared by all bulk ad classes.
*See also:*
* :class:`.BulkProductAd`
* :class:`.BulkTextAd`
* :class:`.BulkAppInstallAd`
def parse_date(d_str):
if not d_str:
return None
parsed_date = datetime.strptime(d_str, _BULK_DATE_FORMAT)
bing_ads_date = _CAMPAIGN_OBJECT_FACTORY_V12.create('Date')
bing_ads_date.Day = parsed_date.day
bing_ads_date.Month = parsed_date.month
bing_ads_date.Year = parsed_date.year
return bing_ads_date
def process_mappings_from_row_values(self, row_values):
self._biddable_campaign_criterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('BiddableCampaignCriterion')
self._biddable_campaign_criterion.Type = 'BiddableCampaignCriterion'
self._biddable_campaign_criterion.Criterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('ProductScope')
self._biddable_campaign_criterion.Criterion.Type = 'ProductScope'
row_values.convert_to_entity(self, BulkCampaignProductScope._MAPPINGS)
def process_mappings_from_row_values(self, row_values):
self._campaign = _CAMPAIGN_OBJECT_FACTORY_V12.create('Campaign')
row_values.convert_to_entity(self, BulkCampaign._MAPPINGS)
self._quality_score_data = QualityScoreData.read_from_row_values_or_null(row_values)
self._performance_data = PerformanceData.read_from_row_values_or_null(row_values)