Skip to content

Commit 47f7a11

Browse files
authored
Merge pull request BingAds#180 from BingAds/users/qitia/13.0.9
Version 13.0.9
2 parents 4f1ed7f + 7d72959 commit 47f7a11

27 files changed

+41596
-393
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
.. :changelog:
22
33
Release History
4+
13.0.9(2021-04-29)
5+
+++++++++++++++++++++++++
6+
* Update 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.
7+
* Add bulk mappings for video ad extensions i.e., BulkVideoAdExtension, BulkAccountVideoAdExtension, BulkAdGroupVideoAdExtension, and BulkCampaignVideoAdExtension.
8+
* Add CashbackAdjustment mapping in the BulkAdGroupBiddableCriterion and BulkCampaignBiddableCriterion.
9+
* Cache SDK snapshot of the singleWsdl proxies for all Bing Ads API Version 13 services.
410

511
13.0.8(2021-03-10)
612
+++++++++++++++++++++++++

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 = '13.0.8'
2+
VERSION = '13.0.9'
33
BULK_FORMAT_VERSION_6 = '6.0'
44
WORKING_NAME = 'BingAdsSDKPython'
55
USER_AGENT = '{0} {1} {2}'.format(WORKING_NAME, VERSION, sys.version_info[0:3])

bingads/service_client.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(self, service, version, authorization_data=None, environment='produ
3131
self._authorization_data = authorization_data
3232
self._refresh_oauth_tokens_automatically = True
3333
self._version = ServiceClient._format_version(version)
34+
3435

3536
# TODO This is a temp fix for set default suds temp folder with user info, suds development branch has already fixed it.
3637
if 'cache' not in suds_options:
@@ -94,7 +95,7 @@ def factory(self):
9495
"""
9596

9697
return self.soap_client.factory
97-
98+
9899
@property
99100
def service_url(self):
100101
""" The wsdl url of service based on the specific service and environment.
@@ -105,9 +106,8 @@ def service_url(self):
105106
key = (self._service, self._environment)
106107
service_info_dict = ServiceClient._get_service_info_dict(self._version)
107108
if key not in service_info_dict:
108-
raise ValueError(str.format('Cannot find version: [v{0}] service: [{1}] under environment: [{2}].',
109-
self._version, self._input_service, self._input_environment))
110-
return service_info_dict[(self._service, self._environment)].url
109+
return service_info_dict[(self._service, 'sandbox')]
110+
return service_info_dict[(self._service, self._environment)]
111111

112112

113113
@property
@@ -200,7 +200,6 @@ def _format_version(version):
200200
return 13
201201
raise ValueError(str.format('version error: [{0}] is not supported.', version))
202202

203-
204203
@staticmethod
205204
def _get_service_info_dict(version):
206205
"""
@@ -296,9 +295,9 @@ def name(self):
296295
from suds.sudsobject import Property
297296
from suds.sax.text import Text
298297

299-
298+
# this is used to create entity only. Given the sandbox should have the same contract, we are good to use sandbox wsdl.
300299
_CAMPAIGN_MANAGEMENT_SERVICE_V13 = Client(
301-
'file:///' + pkg_resources.resource_filename('bingads', 'v13/proxies/campaign_management_service.xml'))
300+
'file:///' + pkg_resources.resource_filename('bingads', 'v13/proxies/sandbox/campaignmanagement_service.xml'))
302301
_CAMPAIGN_OBJECT_FACTORY_V13 = _CAMPAIGN_MANAGEMENT_SERVICE_V13.factory
303302
_CAMPAIGN_OBJECT_FACTORY_V13.object_cache = {}
304303
_CAMPAIGN_OBJECT_FACTORY_V13.create_without_cache = _CAMPAIGN_OBJECT_FACTORY_V13.create

bingads/service_info.py

Lines changed: 5 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,11 @@
1-
class _ServiceInfo:
2-
3-
@property
4-
def name(self):
5-
return self._name
6-
7-
@property
8-
def env(self):
9-
return self._env
10-
11-
@property
12-
def url(self):
13-
return self._url
14-
15-
@url.setter
16-
def url(self, url):
17-
self._url = url
18-
19-
20-
def __init__(self, name, env, url):
21-
self._name = name
22-
self._env = env
23-
self._url = url
24-
25-
_SERVICE_INFO_LIST_V13 = [
26-
# ad insight service
27-
_ServiceInfo(
28-
"adinsight",
29-
"production",
30-
"https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/V13/AdInsightService.svc?singleWsdl"
31-
),
32-
_ServiceInfo(
33-
"adinsight",
34-
"sandbox",
35-
"https://adinsight.api.sandbox.bingads.microsoft.com/Api/Advertiser/AdInsight/V13/AdInsightService.svc?singleWsdl"
36-
),
37-
38-
# bulk service
39-
_ServiceInfo(
40-
"bulk",
41-
"production",
42-
"https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/BulkService.svc?singleWsdl"
43-
),
44-
_ServiceInfo(
45-
"bulk",
46-
"sandbox",
47-
"https://bulk.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/BulkService.svc?singleWsdl"
48-
),
49-
50-
# campaign management
51-
_ServiceInfo(
52-
"campaignmanagement",
53-
"production",
54-
"https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc?singleWsdl"
55-
),
56-
_ServiceInfo(
57-
"campaignmanagement",
58-
"sandbox",
59-
"https://campaign.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc?singleWsdl"
60-
),
61-
62-
# customer billing
63-
_ServiceInfo(
64-
"customerbilling",
65-
"production",
66-
"https://clientcenter.api.bingads.microsoft.com/Api/Billing/v13/CustomerBillingService.svc?singleWsdl"
67-
),
68-
_ServiceInfo(
69-
"customerbilling",
70-
"sandbox",
71-
"https://clientcenter.api.sandbox.bingads.microsoft.com/Api/Billing/v13/CustomerBillingService.svc?singleWsdl"
72-
),
73-
74-
# customer management
75-
_ServiceInfo(
76-
"customermanagement",
77-
"production",
78-
"https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl"
79-
),
80-
_ServiceInfo(
81-
"customermanagement",
82-
"sandbox",
83-
"https://clientcenter.api.sandbox.bingads.microsoft.com/Api/CustomerManagement/v13/CustomerManagementService.svc?singleWsdl"
84-
),
85-
86-
# reporting
87-
_ServiceInfo(
88-
"reporting",
89-
"production",
90-
"https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/v13/ReportingService.svc?singleWsdl"
91-
),
92-
_ServiceInfo(
93-
"reporting",
94-
"sandbox",
95-
"https://reporting.api.sandbox.bingads.microsoft.com/Api/Advertiser/Reporting/v13/ReportingService.svc?singleWsdl"
96-
),
97-
]
1+
import pkg_resources
982

3+
_SERVICE_LIST = ['adinsight', 'bulk', 'campaignmanagement', 'customerbilling', 'customermanagement', 'reporting']
994

1005
SERVICE_INFO_DICT_V13 = {}
1016

102-
for service_info in _SERVICE_INFO_LIST_V13:
103-
SERVICE_INFO_DICT_V13[(service_info.name, service_info.env)] = service_info
7+
for service in _SERVICE_LIST:
8+
SERVICE_INFO_DICT_V13[(service, 'production')] = 'file:///' + pkg_resources.resource_filename('bingads', 'v13/proxies/production/%s_service.xml' % (service))
9+
SERVICE_INFO_DICT_V13[(service, 'sandbox')] = 'file:///' + pkg_resources.resource_filename('bingads', 'v13/proxies/sandbox/%s_service.xml' % (service))
10410

10511
SERVICE_INFO_DICT = {13: SERVICE_INFO_DICT_V13}

bingads/v13/bulk/entities/ad_extensions/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
from .bulk_action_ad_extensions import *
1313
from .bulk_promotion_ad_extensions import *
1414
from .bulk_filterlink_ad_extensions import *
15-
from .bulk_flyer_ad_extensions import *
15+
from .bulk_flyer_ad_extensions import *
16+
from .bulk_video_ad_extensions import *
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
from bingads.v13.internal.bulk.mappings import _SimpleBulkMapping
2+
from bingads.v13.internal.bulk.string_table import _StringTable
3+
from bingads.service_client import _CAMPAIGN_OBJECT_FACTORY_V13
4+
5+
from bingads.v13.internal.extensions import *
6+
from .common import _BulkAdExtensionBase
7+
from .common import _BulkCampaignAdExtensionAssociation
8+
from .common import _BulkAdGroupAdExtensionAssociation
9+
from .common import _BulkAccountAdExtensionAssociation
10+
11+
_VideoAdExtension = type(_CAMPAIGN_OBJECT_FACTORY_V13.create('VideoAdExtension'))
12+
13+
14+
class BulkVideoAdExtension(_BulkAdExtensionBase):
15+
""" Represents a video ad extension.
16+
17+
This class exposes the :attr:`video_ad_extension` property that can be read and written
18+
as fields of the Video Ad Extension record in a bulk file.
19+
20+
For more information, see Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
21+
22+
*See also:*
23+
24+
* :class:`.BulkServiceManager`
25+
* :class:`.BulkOperation`
26+
* :class:`.BulkFileReader`
27+
* :class:`.BulkFileWriter`
28+
"""
29+
30+
def __init__(self, account_id=None, ad_extension=None):
31+
if ad_extension and not isinstance(ad_extension, _VideoAdExtension):
32+
raise ValueError('The type of ad_extension is: {0}, should be: {1}'.format(
33+
type(ad_extension),
34+
'VideoAdExtension'
35+
))
36+
super(BulkVideoAdExtension, self).__init__(
37+
account_id=account_id,
38+
ad_extension=ad_extension
39+
)
40+
41+
@property
42+
def video_ad_extension(self):
43+
""" The video ad extension.
44+
45+
see Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
46+
"""
47+
48+
return self._ad_extension
49+
50+
@video_ad_extension.setter
51+
def video_ad_extension(self, value):
52+
self._ad_extension = value
53+
54+
_MAPPINGS = [
55+
_SimpleBulkMapping(
56+
header=_StringTable.Name,
57+
field_to_csv=lambda c: bulk_optional_str(c.video_ad_extension.Name, c.video_ad_extension.Id),
58+
csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'Name', v if v else '')
59+
),
60+
_SimpleBulkMapping(
61+
header=_StringTable.DisplayText,
62+
field_to_csv=lambda c: bulk_optional_str(c.video_ad_extension.DisplayText, c.video_ad_extension.Id),
63+
csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'DisplayText', v if v else '')
64+
),
65+
_SimpleBulkMapping(
66+
header=_StringTable.AltText,
67+
field_to_csv=lambda c: bulk_str(c.video_ad_extension.AlternativeText),
68+
csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'AlternativeText', v)
69+
),
70+
_SimpleBulkMapping(
71+
header=_StringTable.ActionText,
72+
field_to_csv=lambda c: bulk_optional_str(c.video_ad_extension.ActionText, c.video_ad_extension.Id),
73+
csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'ActionText', v if v else '')
74+
),
75+
_SimpleBulkMapping(
76+
header=_StringTable.ThumbnailUrl,
77+
field_to_csv=lambda c: bulk_str(c.video_ad_extension.ThumbnailUrl),
78+
csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'ThumbnailUrl', v)
79+
),
80+
_SimpleBulkMapping(
81+
header=_StringTable.ThumbnailId,
82+
field_to_csv=lambda c: bulk_str(c.video_ad_extension.ThumbnailId),
83+
csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'ThumbnailId', int(v) if v else None)
84+
),
85+
_SimpleBulkMapping(
86+
header=_StringTable.VideoId,
87+
field_to_csv=lambda c: bulk_str(c.video_ad_extension.VideoId),
88+
csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'VideoId', int(v) if v else None)
89+
),
90+
_SimpleBulkMapping(
91+
header=_StringTable.FinalUrlSuffix,
92+
field_to_csv=lambda c: bulk_optional_str(c.video_ad_extension.FinalUrlSuffix, c.video_ad_extension.Id),
93+
csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'FinalUrlSuffix', v)
94+
),
95+
_SimpleBulkMapping(
96+
header=_StringTable.TrackingTemplate,
97+
field_to_csv=lambda c: bulk_str(c.video_ad_extension.TrackingUrlTemplate),
98+
csv_to_field=lambda c, v: setattr(c.video_ad_extension, 'TrackingUrlTemplate', v if v else None)
99+
),
100+
_SimpleBulkMapping(
101+
header=_StringTable.CustomParameter,
102+
field_to_csv=lambda c: field_to_csv_UrlCustomParameters(c.video_ad_extension),
103+
csv_to_field=lambda c, v: csv_to_field_UrlCustomParameters(c.video_ad_extension, v)
104+
),
105+
_SimpleBulkMapping(
106+
header=_StringTable.FinalUrl,
107+
field_to_csv=lambda c: field_to_csv_Urls(c.video_ad_extension.FinalUrls, c.video_ad_extension.Id),
108+
csv_to_field=lambda c, v: csv_to_field_Urls(c.video_ad_extension.FinalUrls, v)
109+
),
110+
_SimpleBulkMapping(
111+
header=_StringTable.FinalMobileUrl,
112+
field_to_csv=lambda c: field_to_csv_Urls(c.video_ad_extension.FinalMobileUrls, c.video_ad_extension.Id),
113+
csv_to_field=lambda c, v: csv_to_field_Urls(c.video_ad_extension.FinalMobileUrls, v)
114+
)
115+
]
116+
117+
def process_mappings_from_row_values(self, row_values):
118+
self.video_ad_extension = _CAMPAIGN_OBJECT_FACTORY_V13.create('VideoAdExtension')
119+
self.video_ad_extension.Type = 'VideoAdExtension'
120+
super(BulkVideoAdExtension, self).process_mappings_from_row_values(row_values)
121+
row_values.convert_to_entity(self, BulkVideoAdExtension._MAPPINGS)
122+
123+
def process_mappings_to_row_values(self, row_values, exclude_readonly_data):
124+
self._validate_property_not_null(self.video_ad_extension, 'video_ad_extension')
125+
super(BulkVideoAdExtension, self).process_mappings_to_row_values(row_values, exclude_readonly_data)
126+
self.convert_to_values(row_values, BulkVideoAdExtension._MAPPINGS)
127+
128+
129+
class BulkAccountVideoAdExtension(_BulkAccountAdExtensionAssociation):
130+
""" Represents an account level video ad extension.
131+
132+
This class exposes properties that can be read and written
133+
as fields of the Account Video Ad Extension record in a bulk file.
134+
135+
For more information, see Account Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
136+
137+
*See also:*
138+
139+
* :class:`.BulkServiceManager`
140+
* :class:`.BulkOperation`
141+
* :class:`.BulkFileReader`
142+
* :class:`.BulkFileWriter`
143+
"""
144+
145+
pass
146+
147+
148+
class BulkCampaignVideoAdExtension(_BulkCampaignAdExtensionAssociation):
149+
""" Represents a campaign level video ad extension.
150+
151+
This class exposes properties that can be read and written
152+
as fields of the Campaign Video Ad Extension record in a bulk file.
153+
154+
For more information, see Campaign Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
155+
156+
*See also:*
157+
158+
* :class:`.BulkServiceManager`
159+
* :class:`.BulkOperation`
160+
* :class:`.BulkFileReader`
161+
* :class:`.BulkFileWriter`
162+
"""
163+
164+
pass
165+
166+
class BulkAdGroupVideoAdExtension(_BulkAdGroupAdExtensionAssociation):
167+
""" Represents an ad group level video ad extension.
168+
169+
This class exposes properties that can be read and written
170+
as fields of the Ad Group Video Ad Extension record in a bulk file.
171+
172+
For more information, see Ad Group Video Ad Extension at https://go.microsoft.com/fwlink/?linkid=846127.
173+
174+
*See also:*
175+
176+
* :class:`.BulkServiceManager`
177+
* :class:`.BulkOperation`
178+
* :class:`.BulkFileReader`
179+
* :class:`.BulkFileWriter`
180+
"""
181+
182+
pass

bingads/v13/bulk/entities/target_criterions/bulk_ad_group_biddable_criterion.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ def __init__(self,
5959
_StringTable.BidAdjustment,
6060
field_to_csv=lambda c: field_to_csv_BidAdjustment(c.biddable_ad_group_criterion),
6161
csv_to_field=lambda c, v: csv_to_field_BidAdjustment(c.biddable_ad_group_criterion, float(v) if v else None)
62+
),
63+
_SimpleBulkMapping(
64+
_StringTable.CashbackAdjustment,
65+
field_to_csv=lambda c: field_to_csv_CashbackAdjustment(c.biddable_ad_group_criterion),
66+
csv_to_field=lambda c, v: csv_to_field_CashbackAdjustment(c.biddable_ad_group_criterion, float(v) if v else None)
6267
)
6368
]
6469

@@ -110,6 +115,8 @@ def process_mappings_from_row_values(self, row_values):
110115
self.create_criterion()
111116
self._biddable_ad_group_criterion.CriterionBid = _CAMPAIGN_OBJECT_FACTORY_V13.create('BidMultiplier')
112117
self._biddable_ad_group_criterion.CriterionBid.Type = 'BidMultiplier'
118+
self._biddable_ad_group_criterion.CriterionCashback = _CAMPAIGN_OBJECT_FACTORY_V13.create('CashbackAdjustment')
119+
self._biddable_ad_group_criterion.CriterionCashback.Type = 'CashbackAdjustment'
113120
row_values.convert_to_entity(self, BulkAdGroupBiddableCriterion._MAPPINGS)
114121

115122
def create_criterion(self):

0 commit comments

Comments
 (0)