Skip to content

Commit

Permalink
Update to Version 13.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
qitia committed May 26, 2020
1 parent 8262f24 commit 322a8ad
Show file tree
Hide file tree
Showing 16 changed files with 1,437 additions and 158 deletions.
10 changes: 10 additions & 0 deletions HISTORY.rst
@@ -1,6 +1,16 @@
.. :changelog:
Release History
13.0.3(2020-05-26)
+++++++++++++++++++++++++
* Updated Bing Ads API Version 13 service proxies to reflect recent interface changes. For details please see the Bing Ads API Release Notes: https://docs.microsoft.com/en-us/bingads/guides/release-notes.
* Add mappings for MaxConversionValueBiddingScheme and TargetRoasBiddingScheme in BulkCampaign.
* Add mapping for the 'Use Searcher Time Zone' field in BulkCampaign and BulkAdGroup.
* Add bulk mappings for promotion ad extensions i.e., BulkPromotionAdExtension, BulkAccountPromotionAdExtension, BulkAdGroupPromotionAdExtension, and BulkCampaignPromotionAdExtension.
* Add support for delete_value of EndDate in the BulkExperiment.
* Add BulkCampaignNegativeStoreCriterion for future use.


13.0.2(2019-12-08)
+++++++++++++++++++++++++
* Attempt internal sync upload for up to 1,000 bulk entities via BulkServiceManager and upload_entities.
Expand Down
3 changes: 1 addition & 2 deletions bingads/manifest.py
@@ -1,6 +1,5 @@
import sys
VERSION = '13.0.2'
BULK_FORMAT_VERSION_5 = '5.0'
VERSION = '13.0.3'
BULK_FORMAT_VERSION_6 = '6.0'
WORKING_NAME = 'BingAdsSDKPython'
USER_AGENT = '{0} {1} {2}'.format(WORKING_NAME, VERSION, sys.version_info[0:3])
1 change: 1 addition & 0 deletions bingads/v13/bulk/entities/__init__.py
Expand Up @@ -14,6 +14,7 @@
from .bulk_keyword import *
from .bulk_campaign_product_scope import *
from .bulk_ad_group_product_partition import *
from .bulk_campaign_negative_store_criterion import *
from .bulk_campaign_negative_dynamic_search_ad_target import *
from .bulk_ad_group_dynamic_search_ad_target import *
from .bulk_ad_group_negative_dynamic_search_ad_target import *
Expand Down
3 changes: 2 additions & 1 deletion bingads/v13/bulk/entities/ad_extensions/__init__.py
Expand Up @@ -9,4 +9,5 @@
from .bulk_structured_snippet_ad_extensions import *
from .bulk_sitelink_ad_extensions import *
from .bulk_price_ad_extensions import *
from .bulk_action_ad_extensions import *
from .bulk_action_ad_extensions import *
from .bulk_promotion_ad_extensions import *
@@ -0,0 +1,205 @@
from bingads.v13.internal.bulk.mappings import _SimpleBulkMapping
from bingads.v13.internal.bulk.string_table import _StringTable
from bingads.service_client import _CAMPAIGN_OBJECT_FACTORY_V13

from .common import _BulkAdExtensionBase
from .common import _BulkAdGroupAdExtensionAssociation
from .common import _BulkCampaignAdExtensionAssociation
from .common import _BulkAccountAdExtensionAssociation

from bingads.v13.internal.extensions import *


_PromotionAdExtension = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('PromotionAdExtension'))


class BulkPromotionAdExtension(_BulkAdExtensionBase):
""" Represents a promotion ad extension.
This class exposes the :attr:`promotion_ad_extension` property that can be read and written
as fields of the Promotion Ad Extension record in a bulk file.
For more information, see Promotion Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
*See also:*
* :class:`.BulkServiceManager`
* :class:`.BulkOperation`
* :class:`.BulkFileReader`
* :class:`.BulkFileWriter`
"""

def __init__(self, account_id=None, ad_extension=None):
if ad_extension and not isinstance(ad_extension, _PromotionAdExtension):
raise ValueError('The type of ad_extension is: {0}, should be: {1}'.format(
type(ad_extension),
'PromotionAdExtension'
))
super(BulkPromotionAdExtension, self).__init__(
account_id=account_id,
ad_extension=ad_extension
)


@property
def promotion_ad_extension(self):
""" The promotion ad extension.
see Promotion Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
"""

return self._ad_extension

@promotion_ad_extension.setter
def promotion_ad_extension(self, value):
self._ad_extension = value


_MAPPINGS = [
_SimpleBulkMapping(
header=_StringTable.Language,
field_to_csv=lambda c: bulk_str(c.promotion_ad_extension.Language),
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'Language', v)
),
_SimpleBulkMapping(
header=_StringTable.CurrencyCode,
field_to_csv=lambda c: bulk_str(c.promotion_ad_extension.CurrencyCode),
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'CurrencyCode', v)
),
_SimpleBulkMapping(
header=_StringTable.PromotionCode,
field_to_csv=lambda c: bulk_optional_str(c.promotion_ad_extension.PromotionCode, c.promotion_ad_extension.Id),
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'PromotionCode', v if v else '')
),
_SimpleBulkMapping(
header=_StringTable.PromotionTarget,
field_to_csv=lambda c: bulk_str(c.promotion_ad_extension.PromotionItem),
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'PromotionItem', v)
),
_SimpleBulkMapping(
header=_StringTable.PromotionStart,
field_to_csv=lambda c: field_to_csv_SchedulingDate(c.promotion_ad_extension.PromotionStartDate, c.promotion_ad_extension.Id) if c._ad_extension.Scheduling else None,
csv_to_field=lambda c, v: csv_to_field_Date(c.promotion_ad_extension, 'PromotionStartDate', v)
),
_SimpleBulkMapping(
header=_StringTable.PromotionEnd,
field_to_csv=lambda c: field_to_csv_SchedulingDate(c.promotion_ad_extension.PromotionEndDate, c.promotion_ad_extension.Id) if c._ad_extension.Scheduling else None,
csv_to_field = lambda c, v: csv_to_field_Date(c.promotion_ad_extension, 'PromotionEndDate', v)
),
_SimpleBulkMapping(
header=_StringTable.MoneyAmountOff,
field_to_csv=lambda c: c.promotion_ad_extension.MoneyAmountOff,
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'MoneyAmountOff',float(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.OrdersOverAmount,
field_to_csv=lambda c: c.promotion_ad_extension.OrdersOverAmount,
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'OrdersOverAmount',float(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.PercentOff,
field_to_csv=lambda c: c.promotion_ad_extension.PercentOff,
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'PercentOff',float(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.DiscountModifier,
field_to_csv=lambda c: bulk_str(c.promotion_ad_extension.DiscountModifier),
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'DiscountModifier', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.Occasion,
field_to_csv=lambda c: bulk_str(c.promotion_ad_extension.PromotionOccasion),
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'PromotionOccasion', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.FinalUrl,
field_to_csv=lambda c: field_to_csv_Urls(c.promotion_ad_extension.FinalUrls, c.promotion_ad_extension.Id),
csv_to_field=lambda c, v: csv_to_field_Urls(c.promotion_ad_extension.FinalUrls, v)
),
_SimpleBulkMapping(
header=_StringTable.FinalMobileUrl,
field_to_csv=lambda c: field_to_csv_Urls(c.promotion_ad_extension.FinalMobileUrls, c.promotion_ad_extension.Id),
csv_to_field=lambda c, v: csv_to_field_Urls(c.promotion_ad_extension.FinalMobileUrls, v)
),
_SimpleBulkMapping(
header=_StringTable.TrackingTemplate,
field_to_csv=lambda c: bulk_optional_str(c.promotion_ad_extension.TrackingUrlTemplate, c.promotion_ad_extension.Id),
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'TrackingUrlTemplate', v if v else '')
),
_SimpleBulkMapping(
header=_StringTable.CustomParameter,
field_to_csv=lambda c: field_to_csv_UrlCustomParameters(c.promotion_ad_extension),
csv_to_field=lambda c, v: csv_to_field_UrlCustomParameters(c.promotion_ad_extension, v)
),
_SimpleBulkMapping(
header=_StringTable.FinalUrlSuffix,
field_to_csv=lambda c: bulk_optional_str(c.promotion_ad_extension.FinalUrlSuffix, c.promotion_ad_extension.Id),
csv_to_field=lambda c, v: setattr(c.promotion_ad_extension, 'FinalUrlSuffix', v)
)
]

def process_mappings_from_row_values(self, row_values):
self.promotion_ad_extension = _CAMPAIGN_OBJECT_FACTORY_V13.create('PromotionAdExtension')
self.promotion_ad_extension.Type = 'PromotionAdExtension'
super(BulkPromotionAdExtension, self).process_mappings_from_row_values(row_values)
row_values.convert_to_entity(self, BulkPromotionAdExtension._MAPPINGS)

def process_mappings_to_row_values(self, row_values, exclude_readonly_data):
self._validate_property_not_null(self.promotion_ad_extension, 'promotion_ad_extension')
super(BulkPromotionAdExtension, self).process_mappings_to_row_values(row_values, exclude_readonly_data)
self.convert_to_values(row_values, BulkPromotionAdExtension._MAPPINGS)


class BulkAccountPromotionAdExtension(_BulkAccountAdExtensionAssociation):
""" Represents an account level promotion ad extension.
This class exposes properties that can be read and written
as fields of the Account Promotion Ad Extension record in a bulk file.
For more information, see Account Promotion Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
*See also:*
* :class:`.BulkServiceManager`
* :class:`.BulkOperation`
* :class:`.BulkFileReader`
* :class:`.BulkFileWriter`
"""

pass

class BulkCampaignPromotionAdExtension(_BulkCampaignAdExtensionAssociation):
""" Represents a campaign level promotion ad extension.
This class exposes properties that can be read and written
as fields of the Campaign Promotion Ad Extension record in a bulk file.
For more information, see Campaign Promotion Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
*See also:*
* :class:`.BulkServiceManager`
* :class:`.BulkOperation`
* :class:`.BulkFileReader`
* :class:`.BulkFileWriter`
"""

pass

class BulkAdGroupPromotionAdExtension(_BulkAdGroupAdExtensionAssociation):
""" Represents an ad group level Promotion ad extension.
This class exposes properties that can be read and written
as fields of the Ad Group Promotion Ad Extension record in a bulk file.
For more information, see Ad Group Promotion Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
*See also:*
* :class:`.BulkServiceManager`
* :class:`.BulkOperation`
* :class:`.BulkFileReader`
* :class:`.BulkFileWriter`
"""

pass
6 changes: 3 additions & 3 deletions bingads/v13/bulk/entities/ad_extensions/common.py
Expand Up @@ -61,12 +61,12 @@ def account_id(self, account_id):
),
_SimpleBulkMapping(
header=_StringTable.StartDate,
field_to_csv=lambda c: field_to_csv_SchedulingStartDate(c._ad_extension.Scheduling, c._ad_extension.Id),
field_to_csv=lambda c: field_to_csv_SchedulingDate(c._ad_extension.Scheduling.StartDate, c._ad_extension.Id) if c._ad_extension.Scheduling else None,
csv_to_field=lambda c, v: csv_to_field_Date(c._ad_extension.Scheduling, 'StartDate', v)
),
_SimpleBulkMapping(
header=_StringTable.EndDate,
field_to_csv=lambda c: field_to_csv_SchedulingEndDate(c._ad_extension.Scheduling, c._ad_extension.Id),
field_to_csv=lambda c: field_to_csv_SchedulingDate(c._ad_extension.Scheduling.EndDate, c._ad_extension.Id) if c._ad_extension.Scheduling else None,
csv_to_field = lambda c, v: csv_to_field_Date(c._ad_extension.Scheduling, 'EndDate', v)
),
_SimpleBulkMapping(
Expand All @@ -76,7 +76,7 @@ def account_id(self, account_id):
),
_SimpleBulkMapping(
header=_StringTable.UseSearcherTimeZone,
field_to_csv=lambda c: field_to_csv_UseSearcherTimeZone(c._ad_extension.Scheduling, c._ad_extension.Id),
field_to_csv=lambda c: field_to_csv_UseSearcherTimeZone(c._ad_extension.Scheduling.UseSearcherTimeZone, c._ad_extension.Id) if c._ad_extension.Scheduling else None,
csv_to_field=lambda c, v: setattr(c._ad_extension.Scheduling, 'UseSearcherTimeZone', parse_bool(v))
),
_SimpleBulkMapping(
Expand Down
9 changes: 8 additions & 1 deletion bingads/v13/bulk/entities/bulk_ad_group.py
Expand Up @@ -232,8 +232,15 @@ def quality_score_data(self):
field_to_csv=lambda c: bulk_optional_str(c.ad_group.FinalUrlSuffix, c.ad_group.Id),
csv_to_field=lambda c, v: setattr(c.ad_group, 'FinalUrlSuffix', v)
),

_SimpleBulkMapping(
header=_StringTable.AdScheduleUseSearcherTimeZone,
field_to_csv=lambda c: field_to_csv_UseSearcherTimeZone(c.ad_group.AdScheduleUseSearcherTimeZone, c.ad_group.Id),
csv_to_field=lambda c, v: setattr(c.ad_group, 'AdScheduleUseSearcherTimeZone', parse_bool(v))
),
]



def process_mappings_from_row_values(self, row_values):
self.ad_group = _CAMPAIGN_OBJECT_FACTORY_V13.create('AdGroup')

Expand Down
7 changes: 6 additions & 1 deletion bingads/v13/bulk/entities/bulk_campaign.py
Expand Up @@ -399,7 +399,7 @@ def _write_website(c):
_SimpleBulkMapping(
header=_StringTable.BudgetType,
field_to_csv=lambda c: bulk_str(c.campaign.BudgetType),
csv_to_field=lambda c, v: csv_to_field_BudgetType(c.campaign, v, version=13)
csv_to_field=lambda c, v: csv_to_field_BudgetType(c.campaign, v)
),
_SimpleBulkMapping(
header=_StringTable.BudgetName,
Expand Down Expand Up @@ -446,6 +446,11 @@ def _write_website(c):
header=_StringTable.PageFeedIds,
field_to_csv=lambda c: BulkCampaign._write_page_feed_ids(c),
csv_to_field=lambda c, v: BulkCampaign._read_page_feed_ids(c, v)
),
_SimpleBulkMapping(
header=_StringTable.AdScheduleUseSearcherTimeZone,
field_to_csv=lambda c: field_to_csv_UseSearcherTimeZone(c.campaign.AdScheduleUseSearcherTimeZone, c.campaign.Id),
csv_to_field=lambda c, v: setattr(c.campaign, 'AdScheduleUseSearcherTimeZone', parse_bool(v))
),
]

Expand Down

0 comments on commit 322a8ad

Please sign in to comment.