Skip to content

Commit

Permalink
update to version 11.12.7
Browse files Browse the repository at this point in the history
  • Loading branch information
qitia committed Oct 15, 2018
1 parent 60d36a5 commit 965070f
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 87 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
-----------
11.12.7(2018-10-10)
+++++++++++++++++++
*Update service proxies to reflect recent interface changes.
*Map TitlePart3 and TextPart2 to BulkExpandedTextAd.
-----------
11.12.6(2018-09-10)
+++++++++++++++++++
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 = '11.12.6'
VERSION = '11.12.7'
BULK_FORMAT_VERSION_5 = '5.0'
BULK_FORMAT_VERSION_6 = '6.0'
WORKING_NAME = 'BingAdsSDKPython'
Expand Down
2 changes: 1 addition & 1 deletion bingads/v11/proxies/campaign_management_service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9959,7 +9959,7 @@
</wsdl:binding>
<wsdl:service name="CampaignManagementService">
<wsdl:port name="BasicHttpBinding_ICampaignManagementService" binding="tns:BasicHttpBinding_ICampaignManagementService">
<soap:address location="https://campaign.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v11/CampaignManagementService.svc" />
<soap:address location="https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v11/CampaignManagementService.svc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
2 changes: 1 addition & 1 deletion bingads/v12/bulk/entities/ad_extensions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def performance_data(self):
_SimpleBulkMapping(
header=_StringTable.ParentId,
field_to_csv=lambda c: bulk_str(c.ad_extension_id_to_entity_id_association.EntityId),
csv_to_field=lambda c, v: setattr(c.ad_extension_id_to_entity_id_association, 'EntityId', int(v))
csv_to_field=lambda c, v: setattr(c.ad_extension_id_to_entity_id_association, 'EntityId', int(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.EditorialStatus,
Expand Down
10 changes: 10 additions & 0 deletions bingads/v12/bulk/entities/bulk_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,11 @@ def expanded_text_ad(self, expanded_text_ad):
field_to_csv=lambda c: c.expanded_text_ad.Text,
csv_to_field=lambda c, v: setattr(c.expanded_text_ad, 'Text', v)
),
_SimpleBulkMapping(
header=_StringTable.TextPart2,
field_to_csv=lambda c: bulk_optional_str(c.expanded_text_ad.TextPart2),
csv_to_field=lambda c, v: setattr(c.expanded_text_ad, 'TextPart2', v if v else '')
),
_SimpleBulkMapping(
header=_StringTable.TitlePart1,
field_to_csv=lambda c: c.expanded_text_ad.TitlePart1,
Expand All @@ -460,6 +465,11 @@ def expanded_text_ad(self, expanded_text_ad):
field_to_csv=lambda c: c.expanded_text_ad.TitlePart2,
csv_to_field=lambda c, v: setattr(c.expanded_text_ad, 'TitlePart2', v)
),
_SimpleBulkMapping(
header=_StringTable.TitlePart3,
field_to_csv=lambda c: bulk_optional_str(c.expanded_text_ad.TitlePart3),
csv_to_field=lambda c, v: setattr(c.expanded_text_ad, 'TitlePart3', v if v else '')
),
_SimpleBulkMapping(
header=_StringTable.Path1,
field_to_csv=lambda c: bulk_optional_str(c.expanded_text_ad.Path1),
Expand Down
111 changes: 98 additions & 13 deletions bingads/v12/bulk/entities/bulk_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from bingads.v12.internal.extensions import *

_ShoppingSetting = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('ShoppingSetting'))
_DsaSetting = type(_CAMPAIGN_OBJECT_FACTORY_V12.create('DynamicSearchAdsSetting'))

class BulkCampaign(_SingleRecordBulkEntity):
""" Represents a campaign that can be read or written in a bulk file.
Expand Down Expand Up @@ -93,13 +94,19 @@ def performance_data(self):
return self._performance_data

def _get_shopping_setting(self):
return self._get_setting(_ShoppingSetting, 'ShoppingSetting')

def _get_dsa_setting(self):
return self._get_setting(_DsaSetting, 'DynamicSearchAdsSetting')

def _get_setting(self, setting_type, setting_name):
if not self.campaign.Settings.Setting:
return None
shopping_settings = [setting for setting in self.campaign.Settings.Setting if
isinstance(setting, _ShoppingSetting)]
if len(shopping_settings) != 1:
raise ValueError('Can only have 1 ShoppingSetting in Campaign Settings.')
return shopping_settings[0]
settings = [setting for setting in self.campaign.Settings.Setting if
isinstance(setting, setting_type)]
if len(settings) != 1:
raise ValueError('Can only have 1 ' + setting_name + ' in Campaign Settings.')
return settings[0]

@staticmethod
def _write_campaign_type(c):
Expand All @@ -116,10 +123,16 @@ def _read_campaign_type(c, v):
campaign_type = v
c.campaign.CampaignType = [campaign_type]
if campaign_type.lower() == 'shopping' or campaign_type.lower() == 'audience':
c.campaign.Settings = _CAMPAIGN_OBJECT_FACTORY_V12.create('ArrayOfSetting')
shopping_setting = _CAMPAIGN_OBJECT_FACTORY_V12.create('ShoppingSetting')
shopping_setting.Type = 'ShoppingSetting'
c.campaign.Settings.Setting = [shopping_setting]
BulkCampaign._create_campaign_setting(c.campaign, 'ShoppingSetting')
elif campaign_type.lower() == 'dynamicsearchads':
BulkCampaign._create_campaign_setting(c.campaign, 'DynamicSearchAdsSetting')

@staticmethod
def _create_campaign_setting(campaign, setting_type):
campaign.Settings = _CAMPAIGN_OBJECT_FACTORY_V12.create('ArrayOfSetting')
setting = _CAMPAIGN_OBJECT_FACTORY_V12.create(setting_type)
setting.Type = setting_type
campaign.Settings.Setting = [setting]

@staticmethod
def _write_store_id(c):
Expand Down Expand Up @@ -208,7 +221,73 @@ def _read_local_inventory_ads_enabled(c, v):
if not shopping_setting:
return None
shopping_setting.LocalInventoryAdsEnabled = v.lower() == 'true' if v else None

@staticmethod
def _read_source(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.Source = v

@staticmethod
def _write_source(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 bulk_str(dsa_setting.Source)

@staticmethod
def _read_domain_language(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.Language = v

@staticmethod
def _write_domain_language(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 bulk_str(dsa_setting.Language)

@staticmethod
def _read_website(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.DomainName = v

@staticmethod
def _write_website(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 bulk_str(dsa_setting.DomainName)

_MAPPINGS = [
_SimpleBulkMapping(
header=_StringTable.CampaignType,
Expand Down Expand Up @@ -311,13 +390,19 @@ def _read_local_inventory_ads_enabled(c, v):
),
_SimpleBulkMapping(
header=_StringTable.Website,
field_to_csv=lambda c: field_to_csv_DSAWebsite(c.campaign),
csv_to_field=lambda c, v: csv_to_field_DSAWebsite(c.campaign, v)
field_to_csv=lambda c: BulkCampaign._write_website(c),
csv_to_field=lambda c, v: BulkCampaign._read_website(c, v)

),
_SimpleBulkMapping(
header=_StringTable.DomainLanguage,
field_to_csv=lambda c: field_to_csv_DSADomainLanguage(c.campaign),
csv_to_field=lambda c, v: csv_to_field_DSADomainLanguage(c.campaign, v)
field_to_csv=lambda c: BulkCampaign._write_domain_language(c),
csv_to_field=lambda c, v: BulkCampaign._read_domain_language(c, v)
),
_SimpleBulkMapping(
header=_StringTable.Source,
field_to_csv=lambda c: BulkCampaign._write_source(c),
csv_to_field=lambda c, v: BulkCampaign._read_source(c, v)
),
_SimpleBulkMapping(
header=_StringTable.SubType,
Expand Down
2 changes: 1 addition & 1 deletion bingads/v12/bulk/entities/bulk_campaign_product_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _add_product_condition_to_row_values(cls, entity, value):
_SimpleBulkMapping(
header=_StringTable.ParentId,
field_to_csv=lambda c: bulk_str(c.biddable_campaign_criterion.CampaignId),
csv_to_field=lambda c, v: setattr(c.biddable_campaign_criterion, 'CampaignId', int(v))
csv_to_field=lambda c, v: setattr(c.biddable_campaign_criterion, 'CampaignId', int(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.Campaign,
Expand Down
2 changes: 2 additions & 0 deletions bingads/v12/internal/bulk/csv_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class _CsvHeaders:
# Ads
_StringTable.Title,
_StringTable.Text,
_StringTable.TextPart2,
_StringTable.DisplayUrl,
_StringTable.DestinationUrl,
_StringTable.BusinessName,
Expand Down Expand Up @@ -281,6 +282,7 @@ class _CsvHeaders:
# Expanded Text Ad
_StringTable.TitlePart1,
_StringTable.TitlePart2,
_StringTable.TitlePart3,
_StringTable.Path1,
_StringTable.Path2,
_StringTable.Domain,
Expand Down
2 changes: 2 additions & 0 deletions bingads/v12/internal/bulk/string_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class _StringTable:
KeywordNegativeKeyword = "Keyword Negative Keyword"
AdGroupNegativeSite = "Ad Group Negative Site"
Text = "Text"
TextPart2="Text Part 2"
Website = "Website"
Target = "Target"
PhysicalIntent = "Physical Intent"
Expand Down Expand Up @@ -350,6 +351,7 @@ class _StringTable:
# Expanded Text Ad
TitlePart1 = "Title Part 1"
TitlePart2 = "Title Part 2"
TitlePart3 = "Title Part 3"
Path1 = "Path 1"
Path2 = "Path 2"
Domain = "Domain"
Expand Down
68 changes: 0 additions & 68 deletions bingads/v12/internal/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,74 +630,6 @@ def csv_to_field_BudgetType(entity, value, version=12):
else:
raise ValueError('Unable to parse BudgetType: {0}'.format(value))


def csv_to_field_DSAWebsite(entity, value):
"""
Set Campaign settings Domain Name from bulk value if the campaign type is Dynamic Search Campaign
:param entity: campaign entity
:param value: bulk str value
"""
if not entity.CampaignType or len(entity.CampaignType) == 0 or entity.CampaignType[0] != "DynamicSearchAds":
return
if len(entity.Settings.Setting) > 0 and entity.Settings.Setting[0].Type == 'DynamicSearchAdsSetting':
entity.Settings.Setting[0].DomainName = value
else:
setting = _CAMPAIGN_OBJECT_FACTORY_V12.create('DynamicSearchAdsSetting')
setting.DomainName = value
setting.Type = 'DynamicSearchAdsSetting'
entity.Settings.Setting.append(setting)


def field_to_csv_DSAWebsite(entity):
"""
convert campaign settings Domain Name to bulk str if the campaign is Dynamic Search Campaign
:param entity: campaign entity
:return: bulk str
"""
if entity.CampaignType is not None and (entity.CampaignType == 'DynamicSearchAds' or (
len(entity.CampaignType) != 0 and entity.CampaignType[0] == 'DynamicSearchAds')):
if entity.Settings is None or entity.Settings.Setting is None or len(entity.Settings.Setting) == 0:
return None
setting = entity.Settings.Setting[0]
if isinstance(setting, type(DynamicSearchAdsSetting)):
return setting.DomainName
return None


def csv_to_field_DSADomainLanguage(entity, value):
"""
Set Campaign settings Language from bulk value if the campaign type is Dynamic Search Campaign
:param entity: campaign entity
:param value: bulk str value
"""
if not entity.CampaignType or len(entity.CampaignType) == 0 or entity.CampaignType[0] != "DynamicSearchAds":
return
if len(entity.Settings.Setting) > 0 and entity.Settings.Setting[0].Type == 'DynamicSearchAdsSetting':
entity.Settings.Setting[0].Language = value
else:
setting = _CAMPAIGN_OBJECT_FACTORY_V12.create('DynamicSearchAdsSetting')
setting.Language = value
setting.Type = 'DynamicSearchAdsSetting'
entity.Settings.Setting.append(setting)


def field_to_csv_DSADomainLanguage(entity):
"""
convert campaign settings Language to bulk str if the campaign is Dynamic Search Campaign
:param entity: campaign entity
:return: bulk str
"""
if entity.CampaignType is not None and (entity.CampaignType == 'DynamicSearchAds' or (
len(entity.CampaignType) != 0 and entity.CampaignType[0] == 'DynamicSearchAds')):
if not entity.Settings or not entity.Settings.Setting or len(entity.Settings.Setting) == 0:
return None
setting = entity.Settings.Setting[0]
if isinstance(setting, type(DynamicSearchAdsSetting)):
return setting.Language

return None


def field_to_csv_WebpageParameter_CriterionName(entity):
if entity.Criterion is None or entity.Criterion.Parameter is None or entity.Criterion.Parameter.CriterionName is None:
return None
Expand Down
12 changes: 11 additions & 1 deletion bingads/v12/proxies/campaign_management_service.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,20 @@
</xs:restriction>
</xs:simpleType>
<xs:element name="CallToAction" nillable="true" type="tns:CallToAction" />
<xs:simpleType name="AssetLinkEditorialStatus">
<xs:restriction base="xs:string">
<xs:enumeration value="Active" />
<xs:enumeration value="Disapproved" />
<xs:enumeration value="Inactive" />
<xs:enumeration value="ActiveLimited" />
</xs:restriction>
</xs:simpleType>
<xs:element name="AddCampaignsRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="AccountId" type="xs:long" />
<xs:element minOccurs="0" name="Campaigns" nillable="true" type="tns:ArrayOfCampaign" />
<xs:element minOccurs="0" name="IncludeDynamicSearchAdsSource" nillable="true" type="xs:boolean" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand Down Expand Up @@ -677,6 +686,7 @@
<xs:sequence>
<xs:element minOccurs="0" name="AccountId" type="xs:long" />
<xs:element minOccurs="0" name="Campaigns" nillable="true" type="tns:ArrayOfCampaign" />
<xs:element minOccurs="0" name="IncludeDynamicSearchAdsSource" nillable="true" type="xs:boolean" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand Down Expand Up @@ -9753,7 +9763,7 @@
</wsdl:binding>
<wsdl:service name="CampaignManagementService">
<wsdl:port name="BasicHttpBinding_ICampaignManagementService" binding="tns:BasicHttpBinding_ICampaignManagementService">
<soap:address location="https://campaign.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V12/CampaignManagementService.svc" />
<soap:address location="https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V12/CampaignManagementService.svc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
15 changes: 15 additions & 0 deletions bingads/v12/reporting/reporting_service_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def submit_download(self, report_request):
:return: The submitted download operation
:rtype: ReportingDownloadOperation
"""
self.normalize_request(report_request)
response = self.service_client.SubmitGenerateReport(report_request)
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.SubmitGenerateReport)
operation = ReportingDownloadOperation(
Expand All @@ -110,6 +111,20 @@ def submit_download(self, report_request):
)
return operation

def normalize_request(self, report_request):

if report_request is None:
return

if hasattr(report_request.Time, 'ReportTimeZone') \
and hasattr(report_request.Time.ReportTimeZone, 'value') \
and report_request.Time.ReportTimeZone.value is None:
report_request.Time.ReportTimeZone=None

if hasattr(report_request.Time, 'PredefinedTime') \
and hasattr(report_request.Time.PredefinedTime, 'value') \
and report_request.Time.PredefinedTime.value is None:
report_request.Time.PredefinedTime=None

@property
def service_client(self):
Expand Down
Loading

0 comments on commit 965070f

Please sign in to comment.