Skip to content

Conversation

@bloodywing
Copy link
Contributor

Plentymarkets uses CamelCase for token responses

See here: https://developers.plentymarkets.com/rest-doc/introduction

The Token Responses are from their docs, they are not mine.

Copy link
Member

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this is reasonable, but I have some concerns about the approach. Thanks for the PR!

token['refresh_token'] = refresh_token

token['token_type'] = 'Bearer'
del token['tokenType']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason not to just build a new dictionary doing this mapping? I'm nervous about this fix being a bit brittle in the face of changing dictionaries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no problem I rewrite it.
I copied the facebook fix and rewrite it for plenty, I just wanted to make it work.

token dict in plentymarkets.py remains untouched
fixed tests for the plentymarkets compliance_fixes
@coveralls
Copy link

coveralls commented Feb 16, 2017

Coverage Status

Coverage increased (+0.4%) to 87.131% when pulling b0a98d7 on bloodywing:plentymarkets_fix into e6286c6 on requests:master.

if refresh_token is not None:
fixed_token['refresh_token'] = refresh_token

fixed_token['token_type'] = 'Bearer'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I should have been clearer.

What I was going for here was more like:

fixed_token = {}
for k, v in token.items():
    fixed_token[to_snake_case(k)] = v

This should resolve the problem in its entirety, and also defends against this changing in the future. Does that make more sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha.

More generic approch to convert the Token to snake case.
@coveralls
Copy link

coveralls commented Feb 16, 2017

Coverage Status

Coverage increased (+0.3%) to 86.994% when pulling 32e43d7 on bloodywing:plentymarkets_fix into e6286c6 on requests:master.

Copy link
Member

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tiny note and then we're good to go I think!


def _compliance_fix(r):

# Plenty returns the Token in CamelCase instead with _
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/instead with/instead of with

from .slack import slack_compliance_fix
from .mailchimp import mailchimp_compliance_fix
from .weibo import weibo_compliance_fix
from .plentymarkets import plentymarkets_compliance_fix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry I missed this: can we get a newline at the end here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are also 2 spaces. Cleaning this up.

@coveralls
Copy link

coveralls commented Feb 16, 2017

Coverage Status

Coverage increased (+0.3%) to 86.994% when pulling bb18ec0 on bloodywing:plentymarkets_fix into e6286c6 on requests:master.

Removed double-space and added newline
Copy link
Member

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'm happy with this. Thanks for the work!

@coveralls
Copy link

coveralls commented Feb 16, 2017

Coverage Status

Coverage increased (+0.3%) to 86.994% when pulling 1849884 on bloodywing:plentymarkets_fix into e6286c6 on requests:master.

@Lukasa Lukasa merged commit a618145 into requests:master Feb 16, 2017
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

Successfully merging this pull request may close these issues.

3 participants