Skip to content

Commit

Permalink
update to version 12.13.3
Browse files Browse the repository at this point in the history
  • Loading branch information
qitia committed Jun 24, 2019
1 parent d7e6cc6 commit 1db560e
Show file tree
Hide file tree
Showing 15 changed files with 631 additions and 6 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.. :changelog:
Release History
12.13.3(2019-06-15)
+++++++++++++++++++++++++
* Updated Bing Ads API version 12 and 13 service proxies to reflect recent interface changes. For more information please see the Bing Ads API Release Notes: https://docs.microsoft.com/en-us/advertising/guides/release-notes.
* For Bing Ads API version 13, added BulkFeed and BulkFeedItem for ad customizer feeds and page feeds. For more information please see the Feed: https://docs.microsoft.com/en-us/advertising/bulk-service/feed?view=bingads-13 and Feed Item: https://docs.microsoft.com/en-us/advertising/bulk-service/feed-item?view=bingads-13 reference documentation.
* For Bing Ads API version 13, added the mapping for PageFeedIds in BulkCampaign. For more information please see the Campaign: https://docs.microsoft.com/en-us/advertising/bulk-service/dynamic-search-ad?view=bingads-13#pagefeedids reference documentation.
* For Bing Ads API version 13, added the mapping for TextPart2 in BulkDynamicSearchAd. For more information please see the Dynamic Search Ad: https://docs.microsoft.com/en-us/advertising/bulk-service/dynamic-search-ad?view=bingads-13#textpart2 reference documentation.

12.13.2(2019-05-15)
+++++++++++++++++++++++++
Expand Down
2 changes: 1 addition & 1 deletion bingads/manifest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
VERSION = '12.13.2'
VERSION = '12.13.3'
BULK_FORMAT_VERSION_5 = '5.0'
BULK_FORMAT_VERSION_6 = '6.0'
WORKING_NAME = 'BingAdsSDKPython'
Expand Down
5 changes: 5 additions & 0 deletions bingads/v12/bulk/entities/bulk_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@ def dynamic_search_ad(self, dynamic_search_ad):
field_to_csv=lambda c: c.dynamic_search_ad.Path2,
csv_to_field=lambda c, v: setattr(c.dynamic_search_ad, 'Path2', v)
),
_SimpleBulkMapping(
header=_StringTable.TextPart2,
field_to_csv=lambda c: c.dynamic_search_ad.TextPart2,
csv_to_field=lambda c, v: setattr(c.dynamic_search_ad, 'TextPart2', v)
),
]

def process_mappings_from_row_values(self, row_values):
Expand Down
2 changes: 1 addition & 1 deletion bingads/v12/internal/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ def csv_to_field_AdSchedule(entity, value):
if value is None or value.strip() == '':
return
daytime_strs = value.split(';')
ad_schedule_pattern = '\((Monday|Tuesday|Wednesday|ThursDay|Friday|Saturday|Sunday)\[(\d\d?):(\d\d)-(\d\d?):(\d\d)\]\)'
ad_schedule_pattern = '\((Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)\[(\d\d?):(\d\d)-(\d\d?):(\d\d)\]\)'
pattern = re.compile(ad_schedule_pattern, re.IGNORECASE)
daytimes = []
for daytime_str in daytime_strs:
Expand Down
1 change: 1 addition & 0 deletions bingads/v13/bulk/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
from .labels import *
from .bulk_offline_conversion import *
from .bulk_experiment import *
from .feeds import *
5 changes: 5 additions & 0 deletions bingads/v13/bulk/entities/bulk_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ def dynamic_search_ad(self, dynamic_search_ad):
field_to_csv=lambda c: c.dynamic_search_ad.Path2,
csv_to_field=lambda c, v: setattr(c.dynamic_search_ad, 'Path2', v)
),
_SimpleBulkMapping(
header=_StringTable.TextPart2,
field_to_csv=lambda c: c.dynamic_search_ad.TextPart2,
csv_to_field=lambda c, v: setattr(c.dynamic_search_ad, 'TextPart2', v)
),
]

def process_mappings_from_row_values(self, row_values):
Expand Down
27 changes: 27 additions & 0 deletions bingads/v13/bulk/entities/bulk_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,28 @@ def _write_domain_language(c):
return None
return bulk_str(dsa_setting.Language)

@staticmethod
def _read_page_feed_ids(c, v):
if not c.campaign.CampaignType:
return None
campgaign_types = [campaign_type.lower() for campaign_type in c.campaign.CampaignType]
if 'dynamicsearchads' in campgaign_types:
dsa_setting = c._get_dsa_setting()
if not dsa_setting:
return None
dsa_setting.PageFeedIds.long = csv_to_field_PageFeedIds(v)

@staticmethod
def _write_page_feed_ids(c):
if not c.campaign.CampaignType:
return None
campgaign_types = [campaign_type.lower() for campaign_type in c.campaign.CampaignType]
if 'dynamicsearchads' in campgaign_types:
dsa_setting = c._get_dsa_setting()
if not dsa_setting:
return None
return field_to_csv_Ids(dsa_setting.PageFeedIds, c.campaign.Id)

@staticmethod
def _read_website(c, v):
if not c.campaign.CampaignType:
Expand Down Expand Up @@ -420,6 +442,11 @@ def _write_website(c):
field_to_csv=lambda c: bulk_optional_str(c.campaign.FinalUrlSuffix, c.campaign.Id),
csv_to_field=lambda c, v: setattr(c.campaign, 'FinalUrlSuffix', v)
),
_SimpleBulkMapping(
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)
),
]

def read_additional_data(self, stream_reader):
Expand Down
2 changes: 2 additions & 0 deletions bingads/v13/bulk/entities/feeds/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .bulk_feed import *
from .bulk_feed_item import *
150 changes: 150 additions & 0 deletions bingads/v13/bulk/entities/feeds/bulk_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
from bingads.service_client import _CAMPAIGN_OBJECT_FACTORY_V13
from bingads.v13.internal.bulk.string_table import _StringTable
from bingads.v13.internal.bulk.entities.single_record_bulk_entity import _SingleRecordBulkEntity
from bingads.v13.internal.bulk.mappings import _SimpleBulkMapping
from bingads.v13.internal.extensions import *


class BulkFeed(_SingleRecordBulkEntity):
""" Represents a feed.
Properties of this class and of classes that it is derived from, correspond to fields of the Feed record in a bulk file.
For more information, see Feed at https://go.microsoft.com/fwlink/?linkid=846127
*See also:*
* :class:`.BulkServiceManager`
* :class:`.BulkOperation`
* :class:`.BulkFileReader`
* :class:`.BulkFileWriter`
"""

def __init__(self, id = None, status=None, account_id=None, sub_type=None, feed_name = None, custom_attr=None):
super(BulkFeed, self).__init__()
self._status = status
self._account_id = account_id
self._id = id
self._sub_type = sub_type
self._name = feed_name
self._custom_attributes = custom_attr


@property
def id(self):
""" the status of bulk record
Corresponds to the 'Id' field in the bulk file.
:rtype: str
"""
return self._id

@id.setter
def id(self, value):
self._id = value

@property
def status(self):
""" the status of bulk record
Corresponds to the 'Status' field in the bulk file.
:rtype: str
"""
return self._status

@status.setter
def status(self, value):
self._status = value

@property
def account_id(self):
""" the id of the account which contains the feed
Corresponds to the 'Parent Id' field in the bulk file.
:rtype: long
"""
return self._account_id

@account_id.setter
def account_id(self, value):
self._account_id = value

@property
def name(self):
""" the id of the account which contains the feed
Corresponds to the 'Feed Name' field in the bulk file.
:rtype: long
"""
return self._name

@name.setter
def name(self, value):
self._name = value

@property
def sub_type(self):
""" the id of the account which contains the feed
Corresponds to the 'Sub Type' field in the bulk file.
:rtype: long
"""
return self._sub_type

@sub_type.setter
def sub_type(self, value):
self._sub_type = value

@property
def custom_attributes(self):
""" the id of the account which contains the feed
Corresponds to the 'Custom Attributes' field in the bulk file.
:rtype: long
"""
return self._custom_attributes

@custom_attributes.setter
def custom_attributes(self, value):
self._custom_attributes = value

_MAPPINGS = [
_SimpleBulkMapping(
header=_StringTable.Id,
field_to_csv=lambda c: bulk_str(c.id),
csv_to_field=lambda c, v: setattr(c, 'id', int(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.ParentId,
field_to_csv=lambda c: bulk_str(c.account_id),
csv_to_field=lambda c, v: setattr(c, 'account_id', int(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.Status,
field_to_csv=lambda c: c.status,
csv_to_field=lambda c, v: setattr(c, 'status', v)
),
_SimpleBulkMapping(
header=_StringTable.FeedName,
field_to_csv=lambda c: bulk_str(c.name),
csv_to_field=lambda c, v: setattr(c, 'name', v)
),
_SimpleBulkMapping(
header=_StringTable.SubType,
field_to_csv=lambda c: bulk_str(c.sub_type),
csv_to_field=lambda c, v: setattr(c, 'sub_type', v)
),
_SimpleBulkMapping(
header=_StringTable.CustomAttributes,
field_to_csv=lambda c: field_to_csv_CustomAttributes(c.custom_attributes),
csv_to_field=lambda c, v: csv_to_field_CustomAttributes(c, v)
),
]

def process_mappings_from_row_values(self, row_values):
row_values.convert_to_entity(self, BulkFeed._MAPPINGS)

def process_mappings_to_row_values(self, row_values, exclude_readonly_data):
self.convert_to_values(row_values, BulkFeed._MAPPINGS)

def read_additional_data(self, stream_reader):
super(BulkFeed, self).read_additional_data(stream_reader)
Loading

0 comments on commit 1db560e

Please sign in to comment.