Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trading API headers issue #376

Open
slonopot opened this issue Apr 18, 2023 · 1 comment
Open

Trading API headers issue #376

slonopot opened this issue Apr 18, 2023 · 1 comment

Comments

@slonopot
Copy link

There's an issue with Trading API and maybe with the configs themselves. When building headers, some values are being pulled from config and Connection parameters. As we don't need anything other than appid and token, other values (such as devid, keys/certs) are not required. The issue is that these values are None in config, and when config.get(val, default) is being called, it returns None. Later the header check fails. There's probably a better way to deal with this, but as a hotfix one can use:

/ebaysdk/config.py

def get(self, cKey, defaultValue=None):
    val = self.values.get(cKey, defaultValue)
    if val is None:
        return defaultValue
    return val
@slonopot
Copy link
Author

slonopot commented Apr 20, 2023

Another quality of life feature could be some sort of automatic value parsing

/ebaysdk/response.py

def _setattr(self, name, value, datetime_nodes):
if name.lower() in datetime_nodes:
    try:
        ts = "%s %s" % (value.partition(
            'T')[0], value.partition('T')[2].partition('.')[0])
        value = datetime.datetime.strptime(ts, '%Y-%m-%d %H:%M:%S')
    except ValueError:
        pass

if value == 'true':
    value = True
elif value == 'false':
    value = False
else:
    try:
        value = float(value)
        if value % 1 == 0:
            value = int(value)
    except:
        pass


setattr(self, name, value)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant