This repository has been archived by the owner on May 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 170
InboundShipments: additions and base function changes #32
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Initial methods to add functionality for the InboundShipments class in mws. Tested on live account Feb 2-6, 2015.
- Adds generic "ByNextToken" method to base class. - Adjustments to comments on InboundShipments methods. - New methods: estimate_transport_request, list_inbound_shipments, list_inbound_shipment_items
Inboundshipments branch merge to BFS master
- ready to start cracking on this one
- (sorry, UNIX style)
- (sorry, UNIX style)
- Soon to be broken down into component API files, as well
- Update requirements code and docs later
Requiring python-dateutil for date parsing of response timestamps
Set method="POST" on make_request calls that weren't using it right.
(from czpython/python-amazon-mws, Pull czpython#31)
Addition of MX marketplace
* testing needed
* Further testing required
* Tested and working.
* Testing this functionality: may be better to have user handle these exceptions and parse their own messages.
Check for error code using .get, avoids potential exception here.
Error parsing correction.
* Function unique_list_order_preserved is now available. * This function is being used in get_prep_instructions_for_sku and get_prep_instructions_for_asin to ensure unique lists of items.
Bugfix: ensure unique lists for certain operations
bumped release number to reflect recent changes
Correction to ListInventorySupply operation
Change reference of 'datetime' to 'start_time'
Update to invalid items pattern
Corrected pattern (again)
Corrections to missing Message key in certain error messages
Yep, broke the whole thing. F*&^
Forgot to return error dict
Doing this instead of assigning the code['value'], which runs risk of having a later process check for the Message's 'value' key. Since it would be a string at that point, that raises TypeError for wrong type of index (string instead of integer). Other processes already check `if message` before getting the value of that message, so this should fix the issue downstream.
Assign Code dict to Message directly.
Added `box_contents_source` param to CreateInboundShipment and UpdateInboundShipment
* Required argument in create_inbound_shipment_plan and create_inbound_shipment * Optional in update_inbound_shipment
Changed 'args' to 'items'
Update to invalid_items patterns
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been developing on this fork for some time now and want to push my changes in for others to see, make corrections on, potentially benefit from. In addition to the initial methods for InboundShipments, there are some changes to the base class methods that should be noted.
General Changes
time.strftime
, using the built-indatetime.isoformat()
to create timestamps in iso8601remove_empty()
function, simplifying it to a dict comprehensionremove_namespace()
caused a TypeError in Py3 in some cases. Added atry...except
to handle it.parsed
behavior. If either no root key is given or an error response occurs (with a root key given, but that key doesn't exist), the root will point toself._response_dict
. Was not previously possible.action_by_next_token()
method: pass the name of the original action and the NextToken, and the proper request will be sent out.NEXT_TOKEN_OPERATIONS
constant has been added to each API class, containing a list of actions for that API which have eligible "by_next_token" operations. If an incorrect name is passed, MWSError is raised to warn the user.I realize for backwards compability, it would make sense to deprecate these instead of straight up remove them. I can re-make those methods and commit again.MWS.enumerate_params()
Overhauled
enumerate_param
, changing it to a non-public method and preferring the new methodenumerate_params
. The latter takes a dictionary, where each key is the param to enumerate and each value is an iterable to be enumerated; and returns a single dict with all params enumerated by the original method.Example: the following three statements...
...have been replaced by one:
Most operations only need to create an initial dict and then update it once with
enumerate_params
. All methods that would otherwise useenumerate_param
now useenumerate_params
, instead.MWS.enumerate_keyed_param()
New method
enumerate_keyed_param
. Created for CreateInboundShipmentPlan (docs), specifically the InboundShipmentPlanRequestItems param. There are similar params that will need this in the future, such as in Create/UpdateInboundShipment.Comments on this one give a good example already.
Inbound Shipments
Several of the basic operations are available here now. These include:
I'm currently working through that last one, and soon will be writing CreateInboundShipment, UpdateInboundShipment, and PutTransportContent.
(We're not due to use ConfirmTransportRequest for a while, so I have no way to test this properly.)
Generic error handling removed
As part of this, I've removed the call to
raise_for_status
withinmake_request
. This is because the error responses we get back from Amazon are, themselves, XML responses, and it's better that we be able to parse them instead of lose them to a generic HTTPError.This might mean that some methods written specifically to catch the MWSError raised there won't work: you'll get a "good" response now, but that will be an XML with "ErrorResponse" at the root, not the original rootkey (that's why I changed the behavior for
parsed
property, as well). This impacts any user-defined methods that might look for throttled requests.This is likely not complete and could be refined further. Let me know what you guys think.
Thanks.
P.S. I am using ListInboundShipments and ListInboundShipmentItems in production already, in a method that periodically grabs our shipment data. I've had success with threading these requests, and would be glad to show that code.