Skip to content

Commit

Permalink
update to version 13.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
qitia committed Nov 8, 2019
1 parent 5b6e649 commit 95333bc
Show file tree
Hide file tree
Showing 149 changed files with 150 additions and 29,027 deletions.
7 changes: 7 additions & 0 deletions HISTORY.rst
@@ -1,6 +1,13 @@
.. :changelog:
Release History
13.0.1(2019-11-08)
+++++++++++++++++++++++++
* Updated Bing Ads API Version 13 service proxies to reflect recent interface changes. For details please see the Bing Ads API Release Notes.
* Removed support for Bing Ads API Version 12 i.e., removed the service proxies and bulk entities.
* Added mappings for the "Target Ad Group Id" and "Target Campaign Id" bulk columns in BulkFeedItem.
* Added mappings for the "Include View Through Conversions" and "Profile Expansion Enabled" bulk columns in BulkAccount.

12.13.6(2019-10-12)
+++++++++++++++++++++++++
* Mapped the Experiment Type column to ExperimentType via BulkExperiment.
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
@@ -1,5 +1,4 @@
include *.rst *.py *.txt
include LICENSE

include bingads/v12/proxies/*xml
include bingads/v13/proxies/*xml
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -6,7 +6,7 @@ Bing Ads Python SDK
:target: https://pypi.python.org/pypi/bingads


The Bing Ads Python Software Development Kit (SDK) Version 12.13 enhances the experience of developing Bing Ads applications
The Bing Ads Python Software Development Kit (SDK) Version 13.0 enhances the experience of developing Bing Ads applications
with the Python programming language.
The SDK includes proxy classes for all Bing Ads API web services and abstracts the low level details of authentication with OAuth.
You can also read and write bulk files with the SDK BulkFileReader and BulkFileWriter,
Expand Down
24 changes: 23 additions & 1 deletion bingads/authorization.py
Expand Up @@ -4,7 +4,7 @@
from urlparse import parse_qs, urlparse
from urllib import quote_plus
import json

from datetime import datetime, timedelta
import requests

from .exceptions import OAuthTokenRequestException
Expand Down Expand Up @@ -212,6 +212,15 @@ def __init__(self, access_token=None, access_token_expires_in_seconds=None, refr
self._access_token_expires_in_seconds = access_token_expires_in_seconds
self._refresh_token = refresh_token
self._response_json = response_json
self._access_token_received_datetime=datetime.utcnow()

@property
def access_token_received_datetime(self):
""" The datetime when access token was received
:rtype: datetime
"""
return self._access_token_received_datetime

@property
def access_token(self):
Expand All @@ -231,6 +240,19 @@ def access_token_expires_in_seconds(self):

return self._access_token_expires_in_seconds


@property
def access_token_expired(self):
""" Whether the access token has been expired.
:rtype: bool
"""

return self.access_token_expires_in_seconds is not None and \
self.access_token_expires_in_seconds > 0 and \
datetime.utcnow() > self.access_token_received_datetime + timedelta(seconds = self.access_token_expires_in_seconds)


@property
def refresh_token(self):
""" OAuth refresh token that can be user to refresh an access token.
Expand Down
2 changes: 1 addition & 1 deletion bingads/manifest.py
@@ -1,5 +1,5 @@
import sys
VERSION = '12.13.6'
VERSION = '13.0.1'
BULK_FORMAT_VERSION_5 = '5.0'
BULK_FORMAT_VERSION_6 = '6.0'
WORKING_NAME = 'BingAdsSDKPython'
Expand Down
19 changes: 9 additions & 10 deletions bingads/service_client.py
@@ -1,12 +1,13 @@
from suds.client import Client, Factory, WebFault, ObjectCache # noqa

from suds.client import Client, Factory, WebFault
from suds.cache import ObjectCache
from .headerplugin import HeaderPlugin
from .authorization import *
from .service_info import SERVICE_INFO_DICT
from .manifest import USER_AGENT
from getpass import getuser
from tempfile import gettempdir
from os import path
from datetime import datetime


class ServiceClient:
Expand Down Expand Up @@ -195,8 +196,6 @@ def _format_version(version):
:param version:
:return: int version
"""
if version == 'v12' or version == 12:
return 12
if version == 'v13' or version == 13:
return 13
raise ValueError(str.format('version error: [{0}] is not supported.', version))
Expand Down Expand Up @@ -245,7 +244,12 @@ def __init__(self, service_client, name):
self._name = name

def __call__(self, *args, **kwargs):
need_to_refresh_token = False
need_to_refresh_token = self.service_client.refresh_oauth_tokens_automatically \
and hasattr(self.service_client.authorization_data, 'authentication') \
and isinstance(self.service_client.authorization_data.authentication, OAuthAuthorization) \
and self.service_client.authorization_data.authentication.oauth_tokens is not None \
and self.service_client.authorization_data.authentication.oauth_tokens.access_token_expired

while True:
if need_to_refresh_token:
authentication = self.service_client.authorization_data.authentication
Expand Down Expand Up @@ -293,11 +297,6 @@ def name(self):
from suds.sax.text import Text


_CAMPAIGN_MANAGEMENT_SERVICE_V12 = Client(
'file:///' + pkg_resources.resource_filename('bingads', 'v12/proxies/campaign_management_service.xml'))
_CAMPAIGN_OBJECT_FACTORY_V12 = _CAMPAIGN_MANAGEMENT_SERVICE_V12.factory
_CAMPAIGN_OBJECT_FACTORY_V12.object_cache = {}
_CAMPAIGN_OBJECT_FACTORY_V12.create_without_cache = _CAMPAIGN_OBJECT_FACTORY_V12.create
_CAMPAIGN_MANAGEMENT_SERVICE_V13 = Client(
'file:///' + pkg_resources.resource_filename('bingads', 'v13/proxies/campaign_management_service.xml'))
_CAMPAIGN_OBJECT_FACTORY_V13 = _CAMPAIGN_MANAGEMENT_SERVICE_V13.factory
Expand Down
82 changes: 1 addition & 81 deletions bingads/service_info.py
Expand Up @@ -22,86 +22,6 @@ def __init__(self, name, env, url):
self._env = env
self._url = url

_SERVICE_INFO_LIST_V12 = [
# ad insight service
_ServiceInfo(
"adinsight",
"production",
"https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/V12/AdInsightService.svc?singleWsdl"
),
_ServiceInfo(
"adinsight",
"sandbox",
"https://adinsight.api.sandbox.bingads.microsoft.com/Api/Advertiser/AdInsight/V12/AdInsightService.svc?singleWsdl"
),

# bulk service
_ServiceInfo(
"bulk",
"production",
"https://bulk.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v12/BulkService.svc?singleWsdl"
),
_ServiceInfo(
"bulk",
"sandbox",
"https://bulk.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v12/BulkService.svc?singleWsdl"
),

# campaign management
_ServiceInfo(
"campaignmanagement",
"production",
"https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v12/CampaignManagementService.svc?singleWsdl"
),
_ServiceInfo(
"campaignmanagement",
"sandbox",
"https://campaign.api.sandbox.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v12/CampaignManagementService.svc?singleWsdl"
),

# customer billing
_ServiceInfo(
"customerbilling",
"production",
"https://clientcenter.api.bingads.microsoft.com/Api/Billing/v12/CustomerBillingService.svc?singleWsdl"
),
_ServiceInfo(
"customerbilling",
"sandbox",
"https://clientcenter.api.sandbox.bingads.microsoft.com/Api/Billing/v12/CustomerBillingService.svc?singleWsdl"
),

# customer management
_ServiceInfo(
"customermanagement",
"production",
"https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v12/CustomerManagementService.svc?singleWsdl"
),
_ServiceInfo(
"customermanagement",
"sandbox",
"https://clientcenter.api.sandbox.bingads.microsoft.com/Api/CustomerManagement/v12/CustomerManagementService.svc?singleWsdl"
),

# reporting
_ServiceInfo(
"reporting",
"production",
"https://reporting.api.bingads.microsoft.com/Api/Advertiser/Reporting/v12/ReportingService.svc?singleWsdl"
),
_ServiceInfo(
"reporting",
"sandbox",
"https://reporting.api.sandbox.bingads.microsoft.com/Api/Advertiser/Reporting/v12/ReportingService.svc?singleWsdl"
),
]


SERVICE_INFO_DICT_V12 = {}

for service_info in _SERVICE_INFO_LIST_V12:
SERVICE_INFO_DICT_V12[(service_info.name, service_info.env)] = service_info

_SERVICE_INFO_LIST_V13 = [
# ad insight service
_ServiceInfo(
Expand Down Expand Up @@ -182,4 +102,4 @@ def __init__(self, name, env, url):
for service_info in _SERVICE_INFO_LIST_V13:
SERVICE_INFO_DICT_V13[(service_info.name, service_info.env)] = service_info

SERVICE_INFO_DICT = {12: SERVICE_INFO_DICT_V12, 13: SERVICE_INFO_DICT_V13}
SERVICE_INFO_DICT = {13: SERVICE_INFO_DICT_V13}
3 changes: 0 additions & 3 deletions bingads/v12/__init__.py

This file was deleted.

14 changes: 0 additions & 14 deletions bingads/v12/bulk/__init__.py

This file was deleted.

0 comments on commit 95333bc

Please sign in to comment.