Skip to content

Commit d23e804

Browse files
committed
update to version 12.13.4.1
1 parent 16bca8a commit d23e804

File tree

5 files changed

+64
-52
lines changed

5 files changed

+64
-52
lines changed

HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
.. :changelog:
22
33
Release History
4+
12.13.4.1(2019-08-23)
5+
+++++++++++++++++++++++++
6+
* Write TextAsset and ImageAsset to the Bulk upload file without the Type explicitly set.
7+
48
12.13.4(2019-08-09)
59
+++++++++++++++++++++++++
610
* 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.

bingads/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
VERSION = '12.13.4'
2+
VERSION = '12.13.4.1'
33
BULK_FORMAT_VERSION_5 = '5.0'
44
BULK_FORMAT_VERSION_6 = '6.0'
55
WORKING_NAME = 'BingAdsSDKPython'

bingads/v12/internal/extensions.py

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
RadiusCriterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('RadiusCriterion')
4343
TargetSetting_Type = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('TargetSetting'))
4444
CoOpSetting_Type = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('CoOpSetting'))
45+
TextAsset_Type = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('TextAsset'))
46+
ImageAsset_Type = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('ImageAsset'))
4547

4648
def bulk_str(value):
4749
if value is None or (hasattr(value, 'value') and value.value is None):
@@ -402,31 +404,32 @@ def csv_to_field_Rsa_TextAssetLinks(assetLinks, value):
402404

403405
for assetLinkContract in assetLinkContracts:
404406
asset_link = _CAMPAIGN_OBJECT_FACTORY_V12.create('AssetLink')
407+
asset_link.Asset = _CAMPAIGN_OBJECT_FACTORY_V12.create('TextAsset')
405408
asset_link.Asset.Type = 'TextAsset'
406-
asset_link.Asset.Id = assetLinkContract['id']
407-
asset_link.Asset.Text = assetLinkContract['text']
408-
asset_link.Asset.Name = assetLinkContract['name']
409-
asset_link.AssetPerformanceLabel = assetLinkContract['assetPerformanceLabel']
410-
asset_link.PinnedField = assetLinkContract['pinnedField']
411-
asset_link.EditorialStatus = assetLinkContract['editorialStatus']
409+
asset_link.Asset.Id = assetLinkContract['id'] if 'id' in assetLinkContract else None
410+
asset_link.Asset.Text = assetLinkContract['text'] if 'text' in assetLinkContract else None
411+
asset_link.Asset.Name = assetLinkContract['name'] if 'name' in assetLinkContract else None
412+
asset_link.AssetPerformanceLabel = assetLinkContract['assetPerformanceLabel'] if 'assetPerformanceLabel' in assetLinkContract else None
413+
asset_link.PinnedField = assetLinkContract['pinnedField'] if 'pinnedField' in assetLinkContract else None
414+
asset_link.EditorialStatus = assetLinkContract['editorialStatus'] if 'editorialStatus' in assetLinkContract else None
412415
assetLinks.AssetLink.append(asset_link)
413416

414417
def field_to_csv_ImageAssetLinks(entity):
415418
if entity is None or entity.AssetLink is None:
416419
return None
417420
assetLinkContracts = []
418421
for assetLink in entity.AssetLink:
419-
if assetLink.Asset is not None and assetLink.Asset.Type == 'ImageAsset':
422+
if assetLink.Asset is not None and isinstance(assetLink.Asset, ImageAsset_Type):
420423
contract = {}
421-
contract['cropHeight'] = assetLink.Asset.CropHeight
422-
contract['cropWidth'] = assetLink.Asset.CropWidth
423-
contract['cropX'] = assetLink.Asset.CropX
424-
contract['cropY'] = assetLink.Asset.CropY
425-
contract['id'] = assetLink.Asset.Id
426-
contract['name'] = assetLink.Asset.Name
427-
contract['assetPerformanceLabel'] = assetLink.AssetPerformanceLabel
428-
contract['editorialStatus'] = assetLink.EditorialStatus
429-
contract['pinnedField'] = assetLink.PinnedField
424+
contract['cropHeight'] = assetLink.Asset.CropHeight if hasattr(assetLink.Asset, 'CropHeight') else None
425+
contract['cropWidth'] = assetLink.Asset.CropWidth if hasattr(assetLink.Asset, 'CropWidth') else None
426+
contract['cropX'] = assetLink.Asset.CropX if hasattr(assetLink.Asset, 'CropX') else None
427+
contract['cropY'] = assetLink.Asset.CropY if hasattr(assetLink.Asset, 'CropY') else None
428+
contract['id'] = assetLink.Asset.Id if hasattr(assetLink.Asset, 'Id') else None
429+
contract['name'] = assetLink.Asset.Name if hasattr(assetLink.Asset, 'Name') else None
430+
contract['assetPerformanceLabel'] = assetLink.AssetPerformanceLabel if hasattr(assetLink, 'AssetPerformanceLabel') else None
431+
contract['editorialStatus'] = assetLink.EditorialStatus if hasattr(assetLink, 'EditorialStatus') else None
432+
contract['pinnedField'] = assetLink.PinnedField if hasattr(assetLink, 'PinnedField') else None
430433
assetLinkContracts.append(contract)
431434
if len(assetLinkContracts) > 0:
432435
return json.dumps(assetLinkContracts)
@@ -439,31 +442,32 @@ def csv_to_field_ImageAssetLinks(assetLinks, value):
439442

440443
for assetLinkContract in assetLinkContracts:
441444
asset_link = _CAMPAIGN_OBJECT_FACTORY_V12.create('AssetLink')
445+
asset_link.Asset = _CAMPAIGN_OBJECT_FACTORY_V12.create('ImageAsset')
442446
asset_link.Asset.Type = 'ImageAsset'
443-
asset_link.Asset.CropHeight = assetLinkContract['cropHeight']
444-
asset_link.Asset.CropWidth = assetLinkContract['cropWidth']
445-
asset_link.Asset.CropX = assetLinkContract['cropX']
446-
asset_link.Asset.CropY = assetLinkContract['cropY']
447-
asset_link.Asset.Id = assetLinkContract['id']
448-
asset_link.Asset.Name = assetLinkContract['name']
449-
asset_link.AssetPerformanceLabel = assetLinkContract['assetPerformanceLabel']
450-
asset_link.PinnedField = assetLinkContract['pinnedField']
451-
asset_link.EditorialStatus = assetLinkContract['editorialStatus']
447+
asset_link.Asset.CropHeight = assetLinkContract['cropHeight'] if 'cropHeight' in assetLinkContract else None
448+
asset_link.Asset.CropWidth = assetLinkContract['cropWidth'] if 'cropWidth' in assetLinkContract else None
449+
asset_link.Asset.CropX = assetLinkContract['cropX'] if 'cropX' in assetLinkContract else None
450+
asset_link.Asset.CropY = assetLinkContract['cropY'] if 'cropY' in assetLinkContract else None
451+
asset_link.Asset.Id = assetLinkContract['id'] if 'id' in assetLinkContract else None
452+
asset_link.Asset.Name = assetLinkContract['name'] if 'name' in assetLinkContract else None
453+
asset_link.AssetPerformanceLabel = assetLinkContract['assetPerformanceLabel'] if 'assetPerformanceLabel' in assetLinkContract else None
454+
asset_link.PinnedField = assetLinkContract['pinnedField'] if 'pinnedField' in assetLinkContract else None
455+
asset_link.EditorialStatus = assetLinkContract['editorialStatus'] if 'editorialStatus' in assetLinkContract else None
452456
assetLinks.AssetLink.append(asset_link)
453457

454458
def field_to_csv_Rsa_TextAssetLinks(entity):
455459
if entity is None or entity.AssetLink is None:
456460
return None
457461
assetLinkContracts = []
458462
for assetLink in entity.AssetLink:
459-
if assetLink.Asset is not None and assetLink.Asset.Type == 'TextAsset':
463+
if assetLink.Asset is not None and isinstance(assetLink.Asset, TextAsset_Type):
460464
contract = {}
461-
contract['id'] = assetLink.Asset.Id
462-
contract['name'] = assetLink.Asset.Name
463-
contract['text'] = assetLink.Asset.Text
464-
contract['assetPerformanceLabel'] = assetLink.AssetPerformanceLabel
465-
contract['editorialStatus'] = assetLink.EditorialStatus
466-
contract['pinnedField'] = assetLink.PinnedField
465+
contract['id'] = assetLink.Asset.Id if hasattr(assetLink.Asset, 'Id') else None
466+
contract['name'] = assetLink.Asset.Name if hasattr(assetLink.Asset, 'Name') else None
467+
contract['text'] = assetLink.Asset.Text if hasattr(assetLink.Asset, 'Text') else None
468+
contract['assetPerformanceLabel'] = assetLink.AssetPerformanceLabel if hasattr(assetLink, 'AssetPerformanceLabel') else None
469+
contract['editorialStatus'] = assetLink.EditorialStatus if hasattr(assetLink, 'EditorialStatus') else None
470+
contract['pinnedField'] = assetLink.PinnedField if hasattr(assetLink, 'PinnedField') else None
467471
assetLinkContracts.append(contract)
468472
if len(assetLinkContracts) > 0:
469473
return json.dumps(assetLinkContracts)

bingads/v13/internal/extensions.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
RadiusCriterion = _CAMPAIGN_OBJECT_FACTORY_V13.create('RadiusCriterion')
4343
TargetSetting_Type = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('TargetSetting'))
4444
CoOpSetting_Type = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('CoOpSetting'))
45+
TextAsset_Type = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('TextAsset'))
46+
ImageAsset_Type = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('ImageAsset'))
4547

4648
def bulk_str(value):
4749
if value is None or (hasattr(value, 'value') and value.value is None):
@@ -402,6 +404,7 @@ def csv_to_field_Rsa_TextAssetLinks(assetLinks, value):
402404

403405
for assetLinkContract in assetLinkContracts:
404406
asset_link = _CAMPAIGN_OBJECT_FACTORY_V13.create('AssetLink')
407+
asset_link.Asset = _CAMPAIGN_OBJECT_FACTORY_V13.create('TextAsset')
405408
asset_link.Asset.Type = 'TextAsset'
406409
asset_link.Asset.Id = assetLinkContract['id']
407410
asset_link.Asset.Text = assetLinkContract['text']
@@ -416,17 +419,17 @@ def field_to_csv_ImageAssetLinks(entity):
416419
return None
417420
assetLinkContracts = []
418421
for assetLink in entity.AssetLink:
419-
if assetLink.Asset is not None and assetLink.Asset.Type == 'ImageAsset':
420-
contract = {}
421-
contract['cropHeight'] = assetLink.Asset.CropHeight
422-
contract['cropWidth'] = assetLink.Asset.CropWidth
423-
contract['cropX'] = assetLink.Asset.CropX
424-
contract['cropY'] = assetLink.Asset.CropY
425-
contract['id'] = assetLink.Asset.Id
426-
contract['name'] = assetLink.Asset.Name
427-
contract['assetPerformanceLabel'] = assetLink.AssetPerformanceLabel
428-
contract['editorialStatus'] = assetLink.EditorialStatus
429-
contract['pinnedField'] = assetLink.PinnedField
422+
if assetLink.Asset is not None and isinstance(assetLink.Asset, ImageAsset_Type):
423+
contract = {}
424+
contract['cropHeight'] = assetLink.Asset.CropHeight if hasattr(assetLink.Asset, 'CropHeight') else None
425+
contract['cropWidth'] = assetLink.Asset.CropWidth if hasattr(assetLink.Asset, 'CropWidth') else None
426+
contract['cropX'] = assetLink.Asset.CropX if hasattr(assetLink.Asset, 'CropX') else None
427+
contract['cropY'] = assetLink.Asset.CropY if hasattr(assetLink.Asset, 'CropY') else None
428+
contract['id'] = assetLink.Asset.Id if hasattr(assetLink.Asset, 'Id') else None
429+
contract['name'] = assetLink.Asset.Name if hasattr(assetLink.Asset, 'Name') else None
430+
contract['assetPerformanceLabel'] = assetLink.AssetPerformanceLabel if hasattr(assetLink, 'AssetPerformanceLabel') else None
431+
contract['editorialStatus'] = assetLink.EditorialStatus if hasattr(assetLink, 'EditorialStatus') else None
432+
contract['pinnedField'] = assetLink.PinnedField if hasattr(assetLink, 'PinnedField') else None
430433
assetLinkContracts.append(contract)
431434
if len(assetLinkContracts) > 0:
432435
return json.dumps(assetLinkContracts)
@@ -439,6 +442,7 @@ def csv_to_field_ImageAssetLinks(assetLinks, value):
439442

440443
for assetLinkContract in assetLinkContracts:
441444
asset_link = _CAMPAIGN_OBJECT_FACTORY_V13.create('AssetLink')
445+
asset_link.Asset = _CAMPAIGN_OBJECT_FACTORY_V13.create('ImageAsset')
442446
asset_link.Asset.Type = 'ImageAsset'
443447
asset_link.Asset.CropHeight = assetLinkContract['cropHeight']
444448
asset_link.Asset.CropWidth = assetLinkContract['cropWidth']
@@ -456,14 +460,14 @@ def field_to_csv_Rsa_TextAssetLinks(entity):
456460
return None
457461
assetLinkContracts = []
458462
for assetLink in entity.AssetLink:
459-
if assetLink.Asset is not None and assetLink.Asset.Type == 'TextAsset':
463+
if assetLink.Asset is not None and isinstance(assetLink.Asset, TextAsset_Type):
460464
contract = {}
461-
contract['id'] = assetLink.Asset.Id
462-
contract['name'] = assetLink.Asset.Name
463-
contract['text'] = assetLink.Asset.Text
464-
contract['assetPerformanceLabel'] = assetLink.AssetPerformanceLabel
465-
contract['editorialStatus'] = assetLink.EditorialStatus
466-
contract['pinnedField'] = assetLink.PinnedField
465+
contract['id'] = assetLink.Asset.Id if hasattr(assetLink.Asset, 'Id') else None
466+
contract['name'] = assetLink.Asset.Name if hasattr(assetLink.Asset, 'Name') else None
467+
contract['text'] = assetLink.Asset.Text if hasattr(assetLink.Asset, 'Text') else None
468+
contract['assetPerformanceLabel'] = assetLink.AssetPerformanceLabel if hasattr(assetLink, 'AssetPerformanceLabel') else None
469+
contract['editorialStatus'] = assetLink.EditorialStatus if hasattr(assetLink, 'EditorialStatus') else None
470+
contract['pinnedField'] = assetLink.PinnedField if hasattr(assetLink, 'PinnedField') else None
467471
assetLinkContracts.append(contract)
468472
if len(assetLinkContracts) > 0:
469473
return json.dumps(assetLinkContracts)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
except ImportError:
44
from distutils.core import setup
55

6-
VERSION = '12.13.4'
6+
VERSION = '12.13.4.1'
77

88
with open('README.rst', 'r') as f:
99
readme = f.read()

0 commit comments

Comments
 (0)