Merchant Fulfillment API MWS#50
Conversation
* Added Finances API Feature * .setup.py: bump version to 0.7.5-dev0 * Split out request_description building from make_request() So that it can be tested more easily, and refactored * Split out building the initial params dict from make_request() So that it can be tested more easily * Add fake MWS credentials pytest fixture * test_service_status() should use the pytest fake credentials fixture * Add more pytest fixtures (access_key, secret_key, account_id, timestamp) * Add test for calc_request_description() * Split out calc_request_description() into more statements So that it is easier to debug * Fix calc_request_description - don't include leading ampersand * Don't do automated deployments via Travis (for the moment) * Update README.md badges * InboundShipments, next_token_action decorator, and some style cleanups. (python-amazon-mws#33) * Testing out git commits from VS Code * Reverting the test commit * Adding VS Code settings to gitignore. * Style fixes * MWS.enumerate_param deprecated: now using utils.enumerate_param and utils.enumerate_params * InboundShipments fleshed out; added `utils.next_token_action` decorator; deprecated separate methods for `...by_next_token()` * Bugfix, rename `_enumerate_param` to `enumerate_param` (no need for private) * Fix for next_token issues. * TravisCI flake8 complaining, fixes. * Minor flake8 complaint. * Hack to get flake8 to stop complaining. * Strip pylint disables to clear line length issue. * Correction to keyed params, now tests every item in values sequence to ensure all are dicts. * Add tests for param methods in utils. * Add test for next token decorator. * Adding 'InboundShipments' to `__all__` * Assigning response a default in __init__ for DictWrapper and DataWrapper * Unneeded line breaks removed + docstring formatting * Comment corrected. They're tuples, not sets. * Finances methods updated to use next_token_action decorator * Create .travis.yaml * Update .gitignore * Removing deploy code from local travis * Delete .travis.yaml * Pushed to 0.8.0-dev0 Recently added functionality to InboundShipments, as well as Finances API. These constitute feature additions with backwards compatibility, which calls for a minor version update. * Adding Python 3.6 category We are testing in 3.6 in Travis anyway. May as well include the note. * Specified master and develop branches for badges Ensured the badges for Travis and Codecov are pointing to the appropriate branches (used to be pointing to default, which was master in both cases). * Updated comments throughout module No substantial code changes, comment changes only. Also ensured all docstrings follow same format. * Fixed docstring formatting Also made slight update to docstring for ObjectDict to more clearly note what it does, vs what the original code did. * Fix for flake8 (trailing whitespace) * Fix for flake8 (trailing whitespace) * Bump to 0.8.0 (drop dev tag) for release * Bug: Incorrect use of `super` for back-compat Using the old-style `super` syntax to comply with Python 2.7 compatibility. Not revealed in tests, because current tests don't touch the APIs. Whoops! * Added back old object names in case needed Old names `object_dict` and `xml2dict` added back in case the old objects are being used directly by some users. To be removed in 1.0.0 release down the road.
Remove old-style string formatting for sake of clarity.
Codecov Report
@@ Coverage Diff @@
## develop #50 +/- ##
===========================================
- Coverage 46.67% 45.71% -0.97%
===========================================
Files 4 4
Lines 632 665 +33
Branches 64 65 +1
===========================================
+ Hits 295 304 +9
- Misses 324 346 +22
- Partials 13 15 +2
Continue to review full report at Codecov.
|
|
Code coverage issue is something I'm working on separately, so no need to worry about the coverage decrease in this PR. Post-0.9 we will have a better standard for coverage of new features. |
|
@Bobspadger, can you independently verify this code working in your production? As before, I have no seller account, so I cannot test it against MWS. |
|
@GriceTurrble I'll try, I need to read the docs and work out if my account is activated for this and that I won't cause our order process / customers any issues. |
|
Testing - got stuck: import mws
from credentials import creds
# Make some easier to read globals
SECRET_KEY = creds['amazon']['secret_key']
AWS_ACCESS_KEY = creds['amazon']['AWS_access_id']
SELLER_ID = creds['amazon']['sellerid']
MARKETPLACE_ID = creds['amazon']['marketplaceids']['UK']
shipping = mws.MerchantFulfillment(access_key=AWS_ACCESS_KEY, secret_key=SECRET_KEY, account_id=SELLER_ID, region='UK')
###
# Get service status
###
service_status = shipping.get_service_status()
print(service_status.parsed)
"""
Passes, status green good to carry on
"""
###
# Get eligible shipping services
###
"""
I'm using real order items and id's here
Note: Quantity : 1 fails, Quantity: '1' works and allows params to be encoded. Not sure if this is expected?
"""
item_list = [{'OrderItemId': 'REDACTED', 'Quantity': '1'}]
ship_fron = {
'Name': 'Absolute Music',
'AddressLine1': 'REDACTED',
'AddressLine2': 'REDACTED',
'City': 'REDACTED',
'Email': 'REDACTED',
'PostalCode': 'REDACTED',
'Phone': 'REDACTED'
}
package = {'Length': '10',
'Width': '10',
'Height': '10',
'Unit': 'Centimetres'
}
weight = {'Value': '1',
'Unit': 'g'}
ship_service = {'DeliveryExperience': 'DeliveryConfirmationWithSignature',
'CarrierWillPickUp': 'true'}
services = shipping.get_eligible_shipping_services("XXX-XXXXXXX-XXXXXXX", item_list=item_list, ship_from_address=ship_fron,
package_dimensions=package, weight=weight, shipping_service_options=ship_service)
print(services.parsed)and I get Can't see anything immediately incorrect - do you have any info with regards to my inputs?? @cmchecha |
|
Just noticed this PR was targeting |
| node_tree[key] = val | ||
| # Save childrens | ||
| for child in node.getchildren(): | ||
| for child in node: |
There was a problem hiding this comment.
This is a fairly basic upstream process that seems to have been working so far. Changing this now could have some nasty aftereffects without extensive testing.
@cmchecha , can you provide some detail here, please?
There was a problem hiding this comment.
Output in my production:
DeprecationWarning: This method will be removed in future versions. Use 'list(elem)' or iteration over elem instead.
for child in node.getchildren():
But we can return to the previous version.
|
@Bobspadger I found the error, it was the list of items. |
|
Those last updates are providing me with better error codes, working through a test now |
<ErrorResponse xmlns="https://mws.amazonservices.com/MerchantFulfillment/2015-06-01">
<Error>
<Type>Sender</Type>
<Code>TermsAndConditionsNotAccepted</Code>
</Error>
<RequestId>7d3d2cf5-6686-4a7e-8713-8791d824fc8b</RequestId>
</ErrorResponse>Not sure if this is because I need to accept terms and conditions, documentation @amazon is lacking on this |
|
Docs cover this somewhat: http://docs.developer.amazonservices.com/en_UK/merch_fulfill/MerchFulfill_ErrorCodes.html
That is something the seller needs to take care of. I would assume at this stage that getting that error means the rest of the request is solid. |
|
@cmchecha I found you updates provided me with those error messages to fix, so thanks, it was that list items. Its returning proper responses now @GriceTurrble Yep, I just found that too - being a bit slow today :( I now have responses from Amazon, but not quite as they are giving me with their seller central. I'm just trying to work out why this is at present but the communications aspect of it is looking good :) |
|
I have a support request open with Amazon on this. To me, it looks like we are ok for the communications part of it (only tested on Once I've got confirmation from Amazon that its actually them needing to activate the services on my account and doing so, I can test and confirm the rest of the label creation etc. Looks good so far though. |
|
Just an update on this. I now have the full merchant fulfilment API working and returning labels. I'm happy this is fully working now. |
No description provided.