Skip to content

Commit c5069aa

Browse files
committed
update to version 12.0.3
1 parent 25fa4f4 commit c5069aa

File tree

42 files changed

+834
-1379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+834
-1379
lines changed

HISTORY.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
33
Release History
44
-----------
5+
12.0.3(2019-01-10)
6+
+++++++++++++++++++
7+
* BREAKING CHANGE for BulkAdGroupCustomAudienceAssociation, BulkAdGroupInMarketAudienceAssociation, BulkAdGroupNegativeCustomAudienceAssociation, BulkAdGroupNegativeInMarketAudienceAssociation, BulkAdGroupNegativeProductAudienceAssociation, BulkAdGroupNegativeRemarketingListAssociation, BulkAdGroupNegativeSimilarRemarketingListAssociation, BulkAdGroupProductAudienceAssociation, BulkAdGroupRemarketingListAssociation, and BulkAdGroupSimilarRemarketingListAssociation: Replaced custom_audience_name, in_market_audience_name, product_audience_name, remarketing_list_name, and similar_remarketing_list_name with audience_name. The audience_name property is now used to map from the 'Audience Name' field of a Bulk file via all audience association SDK objects.
8+
* Updated service proxies to reflect recent interface changes. For details please see the release notes: https://docs.microsoft.com/en-us/bingads/guides/release-notes.
9+
* Added Bulk mapping for responsive ad images i.e., added Images to the existing BulkResponsiveAd.
10+
* Added Bulk mapping for campaign target setting i.e., added TargetSetting to the existing BulkCampaign.
11+
* Added Bulk mapping for campaign level audience associations i.e.,BulkCampaignCustomAudienceAssociation, BulkCampaignInMarketAudienceAssociation, BulkCampaignNegativeCustomAudienceAssociation, BulkCampaignNegativeInMarketAudienceAssociation, BulkCampaignNegativeProductAudienceAssociation, BulkCampaignNegativeRemarketingListAssociation, BulkCampaignNegativeSimilarRemarketingListAssociation, BulkCampaignProductAudienceAssociation, BulkCampaignRemarketingListAssociation, and BulkCampaignSimilarRemarketingListAssociation.
12+
* Added the get_response_header method in class ServiceClient, to access the service TrackingId, etc per GitHub issue https://github.com/BingAds/BingAds-Python-SDK/issues/106.
13+
514
12.0.2(2018-12-10)
615
+++++++++++++++++++
716
*Updated 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.

bingads/headerplugin.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,13 @@ def __init__(self):
77
def parsed(self, context):
88
self.document = context.reply
99

10-
def get_headers(self, method):
11-
Result = {}
12-
method = method.method
13-
binding = method.binding.output
14-
SHeaderElem = binding.headpart_types(method, False)
15-
10+
def get_response_header(self):
11+
result = {}
1612
envns = ('SOAP-ENV', 'http://schemas.xmlsoap.org/soap/envelope/')
1713
soapenv = self.document.getChild('Envelope', envns)
1814
soapheaders = soapenv.getChild('Header', envns)
1915
SHeaderNodes = soapheaders.children
2016

21-
for Elem in SHeaderElem:
22-
for Node in SHeaderNodes:
23-
if(Node.name == Elem.name):
24-
ElemRes = Elem.resolve(nobuiltin=True)
25-
NodeRes = binding.unmarshaller().process(Node, ElemRes)
26-
Result[Elem.name] = NodeRes
27-
return Result
28-
#
17+
for Node in SHeaderNodes:
18+
result[Node.name] = Node.text
19+
return result

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.0.2'
2+
VERSION = '12.0.3'
33
BULK_FORMAT_VERSION_5 = '5.0'
44
BULK_FORMAT_VERSION_6 = '6.0'
55
WORKING_NAME = 'BingAdsSDKPython'

bingads/service_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def __getattr__(self, name):
5252

5353
self.set_options(**self._options)
5454
return _ServiceCall(self, name)
55+
56+
def get_response_header(self):
57+
return self.hp.get_response_header()
5558

5659
def set_options(self, **kwargs):
5760
""" Set suds options, these options will be passed to suds.

bingads/v12/bulk/bulk_operation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def get_status(self):
240240
if self.final_status is not None:
241241
return self.final_status
242242
response = self._get_status_with_retry(4)
243-
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.GetBulkDownloadStatus)
243+
headers = self.service_client.get_response_header()
244244
self.tracking_id = headers['TrackingId'] if 'TrackingId' in headers else None
245245
status = BulkOperationStatus(
246246
status=response.RequestStatus,
@@ -339,7 +339,7 @@ def get_status(self):
339339
if self.final_status is not None:
340340
return self.final_status
341341
response = self._get_status_with_retry(4)
342-
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.GetBulkUploadStatus)
342+
headers = self.service_client.get_response_header()
343343
self.tracking_id = headers['TrackingId'] if 'TrackingId' in headers else None
344344
status = BulkOperationStatus(
345345
status=response.RequestStatus,

bingads/v12/bulk/bulk_service_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def submit_download(self, submit_download_parameters):
202202
LastSyncTimeInUTC=last_sync_time_in_utc,
203203
PerformanceStatsDateRange=performance_stats_date_range,
204204
)
205-
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.DownloadCampaignsByAccountIds)
205+
headers = self.service_client.get_response_header()
206206
else:
207207
response = self.service_client.DownloadCampaignsByCampaignIds(
208208
Campaigns={
@@ -218,7 +218,7 @@ def submit_download(self, submit_download_parameters):
218218
LastSyncTimeInUTC=last_sync_time_in_utc,
219219
PerformanceStatsDateRange=performance_stats_date_range,
220220
)
221-
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.DownloadCampaignsByCampaignIds)
221+
headers = self.service_client.get_response_header()
222222
operation = BulkDownloadOperation(
223223
request_id=response,
224224
authorization_data=self._authorization_data,
@@ -242,7 +242,7 @@ def submit_upload(self, submit_upload_parameters):
242242
AccountId=self._authorization_data.account_id,
243243
ResponseMode=submit_upload_parameters.response_mode,
244244
)
245-
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.GetBulkUploadUrl)
245+
headers = self.service_client.get_response_header()
246246
request_id = response.RequestId
247247
upload_url = response.UploadUrl
248248

bingads/v12/bulk/entities/audiences/__init__.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@
22
__email__ = '[email protected]'
33

44
from .bulk_remarketing_list import *
5-
from .bulk_ad_group_remarketing_list_association import *
6-
from .bulk_ad_group_negative_remarketing_list_association import *
75
from .bulk_custom_audience import *
86
from .bulk_ad_group_custom_audience_association import *
9-
from .bulk_ad_group_negative_custom_audience_association import *
107
from .bulk_in_market_audience import *
118
from .bulk_ad_group_in_market_audience_association import *
12-
from .bulk_ad_group_negative_in_market_audience_association import *
139
from .bulk_ad_group_product_audience_association import *
1410
from .bulk_ad_group_negative_product_audience_association import *
11+
from .bulk_ad_group_negative_in_market_audience_association import *
12+
from .bulk_ad_group_negative_custom_audience_association import *
13+
from .bulk_ad_group_negative_remarketing_list_association import *
14+
from .bulk_ad_group_negative_similar_remarketing_list_association import *
15+
from .bulk_ad_group_remarketing_list_association import *
1516
from .bulk_product_audience import *
1617
from .bulk_similar_remarketing_list import *
1718
from .bulk_ad_group_similar_remarketing_list_association import *
18-
from .bulk_ad_group_negative_similar_remarketing_list_association import *
19+
from .bulk_ad_group_audience_association import *
20+
from .bulk_ad_group_negative_audience_association import *
21+
from .bulk_campaign_audience_association import *
22+
from .bulk_campaign_custom_audience_association import *
23+
from .bulk_campaign_in_market_audience_association import *
24+
from .bulk_campaign_product_audience_association import *
25+
from .bulk_campaign_remarketing_list_association import *
26+
from .bulk_campaign_similar_remarketing_list_association import *
27+
from .bulk_campaign_negative_audience_association import *
28+
from .bulk_campaign_negative_remarketing_list_association import *
29+
from .bulk_campaign_negative_custom_audience_association import *
30+
from .bulk_campaign_negative_in_market_audience_association import *
31+
from .bulk_campaign_negative_product_audience_association import *
32+
from .bulk_campaign_negative_similar_remarketing_list_association import *
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
from bingads.v12.bulk.entities import *
2+
from bingads.service_client import _CAMPAIGN_OBJECT_FACTORY_V12
3+
from bingads.v12.internal.bulk.entities.single_record_bulk_entity import _SingleRecordBulkEntity
4+
from bingads.v12.internal.bulk.mappings import _SimpleBulkMapping
5+
from bingads.v12.internal.bulk.string_table import _StringTable
6+
from bingads.v12.internal.extensions import *
7+
8+
9+
class BulkAdGroupAudienceAssociation(_SingleRecordBulkEntity):
10+
""" Base class for all Ad Group Audience Association subclasses that can be read or written in a bulk file.
11+
12+
*See also:*
13+
14+
* :class:`.BulkAdGroupCustomAudienceAssociation`
15+
* :class:`.BulkAdGroupInMarketAudienceAssociation`
16+
* :class:`.BulkAdGroupProductAudienceAssociation`
17+
* :class:`.BulkAdGroupRemarketingListAssociation`
18+
* :class:`.BulkAdGroupSimilarRemarketingListAssociation`
19+
"""
20+
21+
def __init__(self,
22+
biddable_ad_group_criterion=None,
23+
campaign_name=None,
24+
ad_group_name=None,
25+
audience_name=None):
26+
super(BulkAdGroupAudienceAssociation, self).__init__()
27+
28+
self._biddable_ad_group_criterion = biddable_ad_group_criterion
29+
self._campaign_name = campaign_name
30+
self._ad_group_name = ad_group_name
31+
self._audience_name = audience_name
32+
self._performance_data = None
33+
34+
_MAPPINGS = [
35+
_SimpleBulkMapping(
36+
_StringTable.Status,
37+
field_to_csv=lambda c: bulk_str(c.biddable_ad_group_criterion.Status),
38+
csv_to_field=lambda c, v: setattr(c.biddable_ad_group_criterion, 'Status', v if v else None)
39+
),
40+
_SimpleBulkMapping(
41+
_StringTable.Id,
42+
field_to_csv=lambda c: bulk_str(c.biddable_ad_group_criterion.Id),
43+
csv_to_field=lambda c, v: setattr(c.biddable_ad_group_criterion, 'Id', int(v) if v else None)
44+
),
45+
_SimpleBulkMapping(
46+
_StringTable.ParentId,
47+
field_to_csv=lambda c: bulk_str(c.biddable_ad_group_criterion.AdGroupId),
48+
csv_to_field=lambda c, v: setattr(c.biddable_ad_group_criterion, 'AdGroupId', int(v) if v else None)
49+
),
50+
_SimpleBulkMapping(
51+
_StringTable.Campaign,
52+
field_to_csv=lambda c: c.campaign_name,
53+
csv_to_field=lambda c, v: setattr(c, 'campaign_name', v)
54+
),
55+
_SimpleBulkMapping(
56+
_StringTable.AdGroup,
57+
field_to_csv=lambda c: c.ad_group_name,
58+
csv_to_field=lambda c, v: setattr(c, 'ad_group_name', v)
59+
),
60+
_SimpleBulkMapping(
61+
_StringTable.Audience,
62+
field_to_csv=lambda c: c.audience_name,
63+
csv_to_field=lambda c, v: setattr(c, 'audience_name', v)
64+
),
65+
_SimpleBulkMapping(
66+
_StringTable.BidAdjustment,
67+
field_to_csv=lambda c: field_to_csv_BidAdjustment(c.biddable_ad_group_criterion),
68+
csv_to_field=lambda c, v: csv_to_field_BidAdjustment(c.biddable_ad_group_criterion, float(v) if v else None)
69+
),
70+
_SimpleBulkMapping(
71+
_StringTable.AudienceId,
72+
field_to_csv=lambda c: field_to_csv_CriterionAudienceId(c.biddable_ad_group_criterion),
73+
csv_to_field=lambda c, v: csv_to_field_CriterionAudienceId(c.biddable_ad_group_criterion, int(v) if v else None)
74+
),
75+
]
76+
77+
@property
78+
def biddable_ad_group_criterion(self):
79+
""" Defines a Biddable Ad Group Criterion """
80+
81+
return self._biddable_ad_group_criterion
82+
83+
@biddable_ad_group_criterion.setter
84+
def biddable_ad_group_criterion(self, biddable_ad_group_criterion):
85+
self._biddable_ad_group_criterion = biddable_ad_group_criterion
86+
87+
@property
88+
def campaign_name(self):
89+
""" Defines the name of the Campaign.
90+
91+
:rtype: str
92+
"""
93+
94+
return self._campaign_name
95+
96+
@campaign_name.setter
97+
def campaign_name(self, campaign_name):
98+
self._campaign_name = campaign_name
99+
100+
@property
101+
def ad_group_name(self):
102+
""" Defines the name of the Ad Group
103+
104+
:rtype: str
105+
"""
106+
107+
return self._ad_group_name
108+
109+
@ad_group_name.setter
110+
def ad_group_name(self, ad_group_name):
111+
self._ad_group_name = ad_group_name
112+
113+
@property
114+
def audience_name(self):
115+
""" Defines the name of the Audience
116+
117+
:rtype: str
118+
"""
119+
120+
return self._audience_name
121+
122+
@audience_name.setter
123+
def audience_name(self, audience_name):
124+
self._audience_name = audience_name
125+
126+
@property
127+
def performance_data(self):
128+
return self._performance_data
129+
130+
def process_mappings_from_row_values(self, row_values):
131+
self._biddable_ad_group_criterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('BiddableAdGroupCriterion')
132+
self._biddable_ad_group_criterion.Type = 'BiddableAdGroupCriterion'
133+
self._biddable_ad_group_criterion.Criterion = _CAMPAIGN_OBJECT_FACTORY_V12.create('AudienceCriterion')
134+
self._biddable_ad_group_criterion.Criterion.Type = 'AudienceCriterion'
135+
self._biddable_ad_group_criterion.CriterionBid = _CAMPAIGN_OBJECT_FACTORY_V12.create('BidMultiplier')
136+
self._biddable_ad_group_criterion.CriterionBid.Type = 'BidMultiplier'
137+
row_values.convert_to_entity(self, BulkAdGroupAudienceAssociation._MAPPINGS)
138+
139+
self._performance_data = PerformanceData.read_from_row_values_or_null(row_values)
140+
141+
def process_mappings_to_row_values(self, row_values, exclude_readonly_data):
142+
self._validate_property_not_null(self.biddable_ad_group_criterion, 'biddable_ad_group_criterion')
143+
self.convert_to_values(row_values, BulkAdGroupAudienceAssociation._MAPPINGS)
144+
145+
PerformanceData.write_to_row_values_if_not_null(self._performance_data, row_values)
146+
147+
def read_additional_data(self, stream_reader):
148+
super(BulkAdGroupAudienceAssociation, self).read_additional_data(stream_reader)

0 commit comments

Comments
 (0)