Skip to content

Commit

Permalink
Merge pull request #246 from BingAds/v13.0.16
Browse files Browse the repository at this point in the history
v13.0.16
  • Loading branch information
xinyuwen2 authored Jun 7, 2023
2 parents df1f35d + 4162f4e commit 7d9e3fa
Show file tree
Hide file tree
Showing 42 changed files with 5,788 additions and 2,350 deletions.
9 changes: 8 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
.. :changelog:
Release History
13.0.16(2023-06-02)
+++++++++++++++++++++++++
* 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.
* Add bulk mappings for performance max campaign i.e., BulkAssetGroup, BulkAssetGroupListingGroup, BulkAudienceGroup, BulkAudienceGroupAssetGroupAssociation, BulkCampaignNegativeWebPage.
* Add mappings for new fields in BulkCampaign: UrlExpansionOptOut.
* Support new bidding scheme: ManualCpaScheme and CostPerSaleBiddingScheme.
* get rid of six/future as we support python3 only. Refer to https://github.com/BingAds/BingAds-Python-SDK/issues/233.

13.0.15(2022-12-23)
+++++++++++++++++++++++++
* 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.
Expand All @@ -9,7 +17,6 @@ Release History
* Add bulk mappings for AdGroupHotelListingGroup.
* Add mappings for new fields in BulkAdgroup: UseOptimizedTargeting, HotelSetting, CommissionRate and PercentCpcBid.
* Support new bidding scheme: percentCpcBiddingScheme and commissionBiddingScheme.
* get rid of six/future as we support python3 only. Refer to https://github.com/BingAds/BingAds-Python-SDK/issues/233.

13.0.14(2022-06-30)
+++++++++++++++++++++++++
Expand Down
5 changes: 0 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ External Dependencies

- `suds-community`_
- `requests`_
- `future`_
- `six`_
- `enum34`_

.. _Bing Ads Client Libraries: https://docs.microsoft.com/en-us/bingads/guides/client-libraries
Expand All @@ -35,7 +33,4 @@ External Dependencies

.. _suds-community: https://pypi.org/pypi/suds-community/
.. _requests: http://pypi.python.org/pypi/requests
.. _chardet: http://pypi.python.org/pypi/chardet
.. _future: http://pypi.python.org/pypi/future
.. _six: http://pypi.python.org/pypi/six
.. _enum34: http://pypi.python.org/pypi/enum34
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 = '13.0.15'
VERSION = '13.0.16'
BULK_FORMAT_VERSION_6 = '6.0'
WORKING_NAME = 'BingAdsSDKPython'
USER_AGENT = '{0} {1} {2}'.format(WORKING_NAME, VERSION, sys.version_info[0:3])
7 changes: 2 additions & 5 deletions bingads/v13/bulk/bulk_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import requests
import zipfile
import os
import six
import sys
import shutil

Expand Down Expand Up @@ -94,10 +93,8 @@ def download_result_file(self, result_file_directory, result_file_name, decompre
zip_file_path = result_file_path

if os.path.exists(result_file_path) and overwrite is False:
if six.PY3:
raise FileExistsError('Result file: {0} exists'.format(result_file_path))
else:
raise OSError('Result file: {0} exists'.format(result_file_path))
raise FileExistsError('Result file: {0} exists'.format(result_file_path))

headers = {
'User-Agent': USER_AGENT,
}
Expand Down
7 changes: 1 addition & 6 deletions bingads/v13/bulk/bulk_service_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from bingads.authorization import *
from bingads.util import _TimeHelper
from bingads.exceptions import TimeoutException
from six import PY2, PY3


class BulkServiceManager:
SYNC_THRESHOLD = 1000
Expand Down Expand Up @@ -186,10 +184,7 @@ def bulkupload_entitie_records(self, entity_upload_parameters, tmp_file, progres
records = self.service_client.factory.create("ns2:ArrayOfstring")
tmp_csv_file = io.open(tmp_file, encoding='utf-8-sig')

if PY3:
records.string = [x.strip() for x in tmp_csv_file.readlines()]
elif PY2:
records.string = [line.encode('utf-8').strip() for line in tmp_csv_file]
records.string = [x.strip() for x in tmp_csv_file.readlines()]

try:
#print(self.service_client)
Expand Down
6 changes: 6 additions & 0 deletions bingads/v13/bulk/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@
from .bulk_ad_customizer_attribute_campaign import *
from .bulk_ad_customizer_attribute_ad_group import *
from .bulk_ad_customizer_attribute_keyword import *

from .bulk_asset_group import *
from .bulk_audience_group import *
from .bulk_asset_group_listing_group import *
from .bulk_audience_group_asset_group_association import *
from .bulk_campaign_negative_webpage import *
179 changes: 179 additions & 0 deletions bingads/v13/bulk/entities/bulk_asset_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
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, _ComplexBulkMapping
from bingads.v13.internal.extensions import *

class BulkAssetGroup(_SingleRecordBulkEntity):
""" Represents an asset group.
This class exposes the property :attr:`asset_group` that can be read and written as fields of the Asset Group record
in a bulk file.
For more information, see Asset Group at https://go.microsoft.com/fwlink/?linkid=846127.
*See also:*
* :class:`.BulkServiceManager`
* :class:`.BulkOperation`
* :class:`.BulkFileReader`
* :class:`.BulkFileWriter`
"""

def __init__(self, campaign_id=None, campaign_name=None, asset_group=None):
super(BulkAssetGroup, self).__init__()

self._campaign_id = campaign_id
self._campaign_name = campaign_name
self._asset_group = asset_group


@property
def campaign_id(self):
""" The identifier of the campaign that contains the asset group.
Corresponds to the 'Parent Id' field in the bulk file.
:rtype: int
"""

return self._campaign_id

@campaign_id.setter
def campaign_id(self, campaign_id):
self._campaign_id = campaign_id

@property
def campaign_name(self):
""" The name of the campaign that contains the asset group.
Corresponds to the 'Campaign' field in the bulk file.
:rtype: str
"""

return self._campaign_name

@campaign_name.setter
def campaign_name(self, campaign_name):
self._campaign_name = campaign_name

@property
def asset_group(self):
""" The AssetGroup Data Object of the Campaign Management Service.
A subset of AssetGroup properties are available in the Ad Group record.
For more information, see Ad Group at https://go.microsoft.com/fwlink/?linkid=846127.
"""
return self._asset_group

@asset_group.setter
def asset_group(self, asset_group):
self._asset_group = asset_group

_MAPPINGS = [
_SimpleBulkMapping(
header=_StringTable.Id,
field_to_csv=lambda c: bulk_str(c.asset_group.Id),
csv_to_field=lambda c, v: setattr(c.asset_group, 'Id', int(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.Status,
field_to_csv=lambda c: bulk_str(c.asset_group.Status),
csv_to_field=lambda c, v: setattr(c.asset_group, 'Status', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.ParentId,
field_to_csv=lambda c: bulk_str(c.campaign_id),
csv_to_field=lambda c, v: setattr(c, 'campaign_id', int(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.Campaign,
field_to_csv=lambda c: c.campaign_name,
csv_to_field=lambda c, v: setattr(c, 'campaign_name', v)
),
_SimpleBulkMapping(
header=_StringTable.AssetGroup,
field_to_csv=lambda c: bulk_str(c.asset_group.Name),
csv_to_field=lambda c, v: setattr(c.asset_group, 'Name', v)
),
_SimpleBulkMapping(
header=_StringTable.StartDate,
field_to_csv=lambda c: bulk_date_str(c.asset_group.StartDate),
csv_to_field=lambda c, v: setattr(c.asset_group, 'StartDate', parse_date(v))
),
_SimpleBulkMapping(
header=_StringTable.EndDate,
field_to_csv=lambda c: bulk_date_str(c.asset_group.EndDate),
csv_to_field=lambda c, v: setattr(c.asset_group, 'EndDate', parse_date(v))
),
_SimpleBulkMapping(
header=_StringTable.BusinessName,
field_to_csv=lambda c: c.asset_group.BusinessName,
csv_to_field=lambda c, v: setattr(c.asset_group, 'BusinessName', v)
),
_SimpleBulkMapping(
header=_StringTable.CallToAction,
field_to_csv=lambda c: c.asset_group.CallToAction,
csv_to_field=lambda c, v: setattr(c.asset_group, 'CallToAction', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.Descriptions,
field_to_csv=lambda c: field_to_csv_TextAssetLinks(c.asset_group.Descriptions),
csv_to_field=lambda c, v: csv_to_field_TextAssetLinks(c.asset_group.Descriptions ,v)
),
_SimpleBulkMapping(
header=_StringTable.EditorialStatus,
field_to_csv=lambda c: c.asset_group.EditorialStatus,
csv_to_field=lambda c, v: setattr(c.asset_group, 'EditorialStatus', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.FinalMobileUrl,
field_to_csv=lambda c: field_to_csv_Urls(c.asset_group.FinalMobileUrls, c.asset_group.Id),
csv_to_field=lambda c, v: csv_to_field_Urls(c.asset_group.FinalMobileUrls, v)
),
_SimpleBulkMapping(
header=_StringTable.FinalUrl,
field_to_csv=lambda c: field_to_csv_Urls(c.asset_group.FinalUrls, c.asset_group.Id),
csv_to_field=lambda c, v: csv_to_field_Urls(c.asset_group.FinalUrls, v)
),
_SimpleBulkMapping(
header=_StringTable.Headlines,
field_to_csv=lambda c: field_to_csv_TextAssetLinks(c.asset_group.Headlines),
csv_to_field=lambda c, v: csv_to_field_TextAssetLinks(c.asset_group.Headlines, v)
),
_SimpleBulkMapping(
header=_StringTable.Images,
field_to_csv=lambda c: field_to_csv_ImageAssetLinks(c.asset_group.Images),
csv_to_field=lambda c, v: csv_to_field_ImageAssetLinks(c.asset_group.Images, v)
),
_SimpleBulkMapping(
header=_StringTable.LongHeadlines,
field_to_csv=lambda c: field_to_csv_TextAssetLinks(c.asset_group.LongHeadlines),
csv_to_field=lambda c, v: csv_to_field_TextAssetLinks(c.asset_group.LongHeadlines ,v)
),
_SimpleBulkMapping(
header=_StringTable.Path1,
field_to_csv=lambda c: bulk_optional_str(c.asset_group.Path1, c.asset_group.Id),
csv_to_field=lambda c, v: setattr(c.asset_group, 'Path1', v)
),
_SimpleBulkMapping(
header=_StringTable.Path2,
field_to_csv=lambda c: bulk_optional_str(c.asset_group.Path2, c.asset_group.Id),
csv_to_field=lambda c, v: setattr(c.asset_group, 'Path2', v)
),
]


def process_mappings_from_row_values(self, row_values):
self.asset_group = _CAMPAIGN_OBJECT_FACTORY_V13.create('AssetGroup')

row_values.convert_to_entity(self, BulkAssetGroup._MAPPINGS)

def process_mappings_to_row_values(self, row_values, exclude_readonly_data):
self._validate_property_not_null(self._asset_group, 'AssetGroup')
self.convert_to_values(row_values, BulkAssetGroup._MAPPINGS)

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

0 comments on commit 7d9e3fa

Please sign in to comment.