Skip to content

Commit 988704c

Browse files
committed
Bulk commit to force https and for fixes to the code samples. see Changes file more details
1 parent a713f28 commit 988704c

File tree

11 files changed

+53
-77
lines changed

11 files changed

+53
-77
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Changes for ebaysdk
22

3+
2.2.0 Mon Apr 20 15:23:53 PDT 2020
4+
- Forced HTTPS for finding, shopping, and trading calls
5+
- fixed sample code so that it uses the appropriate domain
6+
- added py38 to tox testing
7+
38
2.1.6
49
- Update Copyright
510

ebay.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ api.ebay.com:
1919
# Finding API - https://www.x.com/developers/ebay/products/finding-api
2020
svcs.ebay.com:
2121
appid: ENTER_YOUR_APPID_HERE
22-
version: 1.0.0
2322

2423
# Shopping API - https://www.x.com/developers/ebay/products/shopping-api
2524
open.api.ebay.com:
2625
appid: ENTER_YOUR_APPID_HERE
27-
version: 671

ebaysdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import platform
1010
import logging
1111

12-
__version__ = '2.1.5'
12+
__version__ = '2.2.0'
1313
Version = __version__ # for backward compatibility
1414

1515
try:

ebaysdk/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def build_request_data(self, verb, data, verb_attrs):
169169

170170
def build_request_url(self, verb):
171171
url = "%s://%s%s" % (
172-
HTTP_SSL[self.config.get('https', False)],
172+
HTTP_SSL[self.config.get('https', True)],
173173
self.config.get('domain'),
174174
self.config.get('uri')
175175
)

ebaysdk/response.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ def __init__(self, obj, verb=None, list_nodes=[], datetime_nodes=[], parse_respo
161161
datetime_nodes=copy.copy(datetime_nodes))
162162
except XMLSyntaxError as e:
163163
log.debug('response parse failed: %s' % e)
164+
self._dom = self._parse_xml("<%sResponse>parse error <![CDATA[%s]]></%sResponse>" % (verb, e, verb))
165+
self._dict = self._etree_to_dict(self._dom)
164166
self.reply = ResponseDataObject({}, [])
167+
165168
else:
166169
self.reply = ResponseDataObject({}, [])
167170

ebaysdk/shopping/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(self, **kwargs):
7272
self.config.set('uri', '/shopping')
7373
self.config.set('warnings', True)
7474
self.config.set('errors', True)
75-
self.config.set('https', False)
75+
self.config.set('https', True, force=True)
7676
self.config.set('siteid', '0')
7777
self.config.set('response_encoding', 'XML')
7878
self.config.set('request_encoding', 'XML')
@@ -85,15 +85,13 @@ def __init__(self, **kwargs):
8585
self.config.set(
8686
'doc_url', 'http://developer.ebay.com/DevZone/Shopping/docs/CallRef/index.html')
8787

88-
if self.config.get('https') and self.debug:
89-
print("HTTPS is not supported on the Shopping API.")
90-
9188
self.datetime_nodes = ['timestamp', 'registrationdate', 'creationtime',
9289
'commenttime', 'updatetime', 'estimateddeliverymintime',
9390
'estimateddeliverymaxtime', 'creationtime', 'estimateddeliverymintime',
9491
'estimateddeliverymaxtime', 'endtime', 'starttime']
9592

9693
self.base_list_nodes = [
94+
'getcategoryinforesponse.categoryarray.category',
9795
'findhalfproductsresponse.halfcatalogproduct.productid',
9896
'findhalfproductsresponse.halfproducts.product',
9997
'getshippingcostsresponse.internationalshippingserviceoption.shipsto',

ebaysdk/trading/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def __init__(self, **kwargs):
8787
self.config.set('uri', '/ws/api.dll')
8888
self.config.set('warnings', True)
8989
self.config.set('errors', True)
90-
self.config.set('https', True)
90+
self.config.set('https', True, force=True)
9191
self.config.set('siteid', '0')
9292
self.config.set('response_encoding', 'XML')
9393
self.config.set('request_encoding', 'XML')

samples/common.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
Licensed under CDDL 1.0
66
'''
77

8+
from ebaysdk.finding import Connection as finding
9+
10+
def get_one_item(opts):
11+
api = finding(debug=opts.debug, appid=opts.appid,
12+
config_file=opts.yaml, warnings=True)
13+
14+
api_request = {
15+
'keywords': u'GRAMMY Foundation®',
16+
}
17+
18+
response = api.execute('findItemsAdvanced', api_request)
19+
return response.reply.searchResult.item[0].itemId
20+
821

922
def dump(api, full=False):
1023

@@ -17,7 +30,7 @@ def dump(api, full=False):
1730
print("Call Success: %s in length" % len(api.response.content))
1831

1932
print("Response code: %s" % api.response_code())
20-
print("Response DOM1: %s" % api.response_dom()) # deprecated
33+
print("Response DOM1: %s" % api.response.dom()) # deprecated
2134
print("Response ETREE: %s" % api.response.dom())
2235

2336
if full:

samples/shopping.py

Lines changed: 23 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
sys.path.insert(0, '%s/../' % os.path.dirname(__file__))
1818

19-
from common import dump
19+
from common import dump, get_one_item
2020

2121
import ebaysdk
2222
from ebaysdk.exception import ConnectionError
@@ -37,8 +37,8 @@ def init_options():
3737
dest="appid", default=None,
3838
help="Specifies the eBay application id to use.")
3939
parser.add_option("-n", "--domain",
40-
dest="domain", default='svcs.ebay.com',
41-
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
40+
dest="domain", default='open.api.ebay.com',
41+
help="Specifies the eBay domain to use (e.g. open.api.ebay.com).")
4242

4343
(opts, args) = parser.parse_args()
4444
return opts, args
@@ -51,13 +51,12 @@ def run(opts):
5151
print("Shopping samples for SDK version %s" % ebaysdk.get_version())
5252

5353
try:
54-
response = api.execute('FindPopularItems', {'QueryKeywords': 'Python'})
54+
ItemID = get_one_item(opts)
5555

56-
dump(api)
56+
response = api.execute('GetSingleItem', {'ItemID': ItemID})
57+
print("EndTime: %s" % response.reply.Item.EndTime)
5758

58-
print("Matching Titles:")
59-
for item in response.reply.ItemArray.Item:
60-
print(item.Title)
59+
dump(api)
6160

6261
except ConnectionError as e:
6362
print(e)
@@ -69,45 +68,22 @@ def popularSearches(opts):
6968
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, domain=opts.domain,
7069
warnings=True)
7170

72-
choice = True
73-
74-
while choice:
75-
76-
choice = input('Search: ')
77-
78-
if choice == 'quit':
79-
break
80-
81-
mySearch = {
82-
"MaxKeywords": 10,
83-
"QueryKeywords": choice,
84-
}
85-
86-
try:
87-
response = api.execute('FindPopularSearches', mySearch)
71+
mySearch = {
72+
"MaxKeywords": 10,
73+
"QueryKeywords": 'shirt',
74+
}
8875

89-
dump(api, full=False)
90-
91-
print("Related: %s" %
92-
response.reply.PopularSearchResult.RelatedSearches)
93-
94-
for term in response.reply.PopularSearchResult.AlternativeSearches.split(';')[:3]:
95-
api.execute('FindPopularItems', {
96-
'QueryKeywords': term, 'MaxEntries': 3})
76+
try:
77+
response = api.execute('FindPopularSearches', mySearch)
9778

98-
print("Term: %s" % term)
99-
try:
100-
for item in response.reply.ItemArray.Item:
101-
print(item.Title)
102-
except AttributeError:
103-
pass
79+
dump(api, full=False)
10480

105-
dump(api)
106-
print("\n")
81+
print("Related: %s" %
82+
response.reply.PopularSearchResult.RelatedSearches)
10783

108-
except ConnectionError as e:
109-
print(e)
110-
print(e.response.dict())
84+
except ConnectionError as e:
85+
print(e)
86+
print(e.response.dict())
11187

11288

11389
def categoryInfo(opts):
@@ -116,28 +92,12 @@ def categoryInfo(opts):
11692
api = Shopping(debug=opts.debug, appid=opts.appid, config_file=opts.yaml, domain=opts.domain,
11793
warnings=True)
11894

119-
response = api.execute('GetCategoryInfo', {"CategoryID": 3410})
120-
121-
dump(api, full=False)
122-
123-
except ConnectionError as e:
124-
print(e)
125-
print(e.response.dict())
126-
127-
128-
def with_affiliate_info(opts):
129-
try:
130-
api = Shopping(debug=opts.debug, appid=opts.appid,
131-
config_file=opts.yaml, warnings=True,
132-
trackingid=1234, trackingpartnercode=9)
95+
response = api.execute('GetCategoryInfo', {"CategoryID": 11450})
13396

134-
mySearch = {
135-
"MaxKeywords": 10,
136-
"QueryKeywords": 'shirt',
137-
}
97+
print("Category Name: %s" %
98+
response.reply.CategoryArray.Category[0].CategoryName)
13899

139-
response = api.execute('FindPopularSearches', mySearch)
140-
dump(api, full=False)
100+
dump(api)
141101

142102
except ConnectionError as e:
143103
print(e)
@@ -165,5 +125,4 @@ def using_attributes(opts):
165125
run(opts)
166126
popularSearches(opts)
167127
categoryInfo(opts)
168-
with_affiliate_info(opts)
169128
using_attributes(opts)

samples/trading.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def init_options():
4040
dest="certid", default=None,
4141
help="Specifies the eBay cert id to use.")
4242
parser.add_option("-n", "--domain",
43-
dest="domain", default='svcs.ebay.com',
44-
help="Specifies the eBay domain to use (e.g. svcs.sandbox.ebay.com).")
43+
dest="domain", default='api.ebay.com',
44+
help="Specifies the eBay domain to use (e.g. api.sandbox.ebay.com).")
4545

4646
(opts, args) = parser.parse_args()
4747
return opts, args

0 commit comments

Comments
 (0)