added easyship api support for indian marketplace#169
added easyship api support for indian marketplace#169GriceTurrble merged 7 commits intopython-amazon-mws:developfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #169 +/- ##
===========================================
- Coverage 77.51% 76.25% -1.27%
===========================================
Files 18 19 +1
Lines 965 998 +33
Branches 92 95 +3
===========================================
+ Hits 748 761 +13
- Misses 212 232 +20
Partials 5 5
Continue to review full report at Codecov.
|
|
Any update on merging this? |
Sorry, I've not had a chance to even think about looking at present. I'll try to give it a quick review this week sometime, as long as nothing else crops up! |
GriceTurrble
left a comment
There was a problem hiding this comment.
Overall, this look solid to me, but there are some minor changes I would like to see before approval:
- Method name consistency (strict matching for method names and the MWS actions they cover).
- Argument name shortening and consistency (using
slot_in place of the more verbosepackage_slot_prefix). - Future-proofing the
update_scheduled_packages(although Amazon only accepts one package per request, they have designed the call to take more than one; if they update their backend capabilities, we would be able to support it proactively with a change here).
Aside from those, good work, and thank you for the contribution. Please address the above and we'll get it merged into dev version shortly. :)
|
@GriceTurrble Hi, did you get a chance to review my code? |
| detail['ScheduledPackageId.AmazonOrderId'] = detail.pop('amazon_order_id') | ||
| detail['ScheduledPackageId.PackageId'] = detail.pop('package_id') | ||
| detail['PackagePickupSlot.SlotId'] = detail.pop('slot_id') | ||
| detail['PackagePickupSlot.PickupTimeStart'] = detail.pop('slot_start_time', None) | ||
| detail['PackagePickupSlot.PickupTimeEnd'] = detail.pop('slot_end_time', None) |
There was a problem hiding this comment.
I have minor doubts about this particular pattern, but not a showstopper. Changes will be accepted, and I encourage you to contribute an additional change with the following.
To be clear, this code does work as intended, even in a case where it doesn't seem like it should. For instance, if package_update_details is an immutable sequence, like a tuple, one might think it can't be updated. In fact, the dicts contained in the sequence can be updated, and the tuple that points to them is not being changed. Though this works, I would like to see it cleaned up so that we aren't changing an object as we iterate through it.
Further, if the detail inside the loop is not a dict, it will throw TypeError: string indices must be integers when trying to access one of its keys. That's not a clear error message for what actually happened, so I would like to see that error handled in a way that contextualizes the problem for the end user. For example:
if not isinstance(detail, dict):
raise ValueError("Package details must be a list of dicts, each with required keys `amazon_order_id`, `package_id`, and `slot_id` (optional keys: `slot_start_time` and `slot_end_time`)")Similarly, detail.pop('amazon_order_id') will throw KeyError: 'amazon_order_id' if that key is missing. Again, in context, this is a bit obscure, and we want the user to see some more details to help them out. Ideally, the dict should be tested for those required keys, with the same ValueError as above thrown if any are missing, so that the developer knows what went wrong more quickly.
These concerns can be handled by a utility function from elsewhere in the module.
There was a problem hiding this comment.
@GriceTurrble thanks for pointing this out. I will fix these points. The package_update_details won't be modified in the function. And the function will throw an error if a non dict or a dict without required keys is passed.
* upstream/develop: Add Feeds utility to convert dict FeedOptions to string (python-amazon-mws#181) Ensure correct decoding of bytes (python-amazon-mws#168) Compatibility fix (python-amazon-mws#124) Implement a couple of function for the OutboundShipments API. (python-amazon-mws#96) Added OutboundShipments.create_fulfillment_order (python-amazon-mws#95) added UpdateReportAcknowledgements (python-amazon-mws#101) Update feeds.py (python-amazon-mws#166) added easyship api support for indian marketplace (python-amazon-mws#169) Moving Slack link up, removing gitter chat link add all current marketplaces and alphabetize by country code (python-amazon-mws#155) Updated slack invite link Slack invite link (python-amazon-mws#152) Slack invite link fix clean_params (python-amazon-mws#106) add in NL marketplace information Fix flake8 warnings Update develop branch CI + package metadata include mws.apis in setup.py Fix bug: Remove trailing comma
#162