I am starting out with python and trying to construct an XML request for an ebay web service:
Now, my question is:
Say, this is my function:
def findBestMatchItemDetailsAcrossStores():
request = """<?xml version="1.0" encoding="utf-8"?>
<findBestMatchItemDetailsAcrossStoresRequest xmlns="http://www.ebay.com/marketplace/search/v1/services">
<siteResultsPerPage>50</siteResultsPerPage>
<entriesPerPage>50</entriesPerPage>
<ignoreFeatured>true</ignoreFeatured>
<keywords>ipod</keywords> <-----REQUIRED
<itemFilter>
<paramName>PriceMin</paramName>
<paramValue>50</paramValue>
<name>Currency</name>
<value>USD</value>
</itemFilter>
<itemFilter>
<paramName>PriceMax</paramName>
<paramValue>100</paramValue>
</itemFilter>
</findBestMatchItemDetailsAcrossStoresRequest>"""
return get_response(findBestMatchItemDetailsAcrossStores.__name__, request)
Where, keyword is the only required field. So, how should I construct the method? The ways can be:
Update:
All the xml tags you see in the request are needed to be passed by the user. But keywords should be passed and others maybe passed if required.
Any suggestions?
A good idea is to put all the parameters with appropriate defaults (or just None
defaults) in the function signature. Yeah, it will require a little more typing in the function itself, but the interface will be clean, self-documented and simple to use, as you won't have to look up possible parameters in ebay docs or function source. It will save you time later on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With