Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.

Update feeds.py#166

Merged
GriceTurrble merged 2 commits intopython-amazon-mws:developfrom
masavini:develop
Jun 25, 2020
Merged

Update feeds.py#166
GriceTurrble merged 2 commits intopython-amazon-mws:developfrom
masavini:develop

Conversation

@masavini
Copy link
Copy Markdown
Contributor

added FeedOptions to submit_feed

added FeedOptions to submit_feed
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2020

Codecov Report

Merging #166 into develop will decrease coverage by 0.09%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #166      +/-   ##
===========================================
- Coverage    76.25%   76.15%   -0.10%     
===========================================
  Files           19       19              
  Lines          998      994       -4     
  Branches        95       92       -3     
===========================================
- Hits           761      757       -4     
  Misses         232      232              
  Partials         5        5              
Impacted Files Coverage Δ
mws/apis/feeds.py 78.94% <100.00%> (ø)
mws/mws.py 69.18% <0.00%> (-0.53%) ⬇️
mws/decorators.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 721b20c...b53a4af. Read the comment docs.

@GriceTurrble
Copy link
Copy Markdown
Member

GriceTurrble commented Mar 20, 2020

FeedOptions doesn't appear to be part of this request, according to the docs.

Are you seeing something different on your end?

Edit: I see this relates to _UPLOAD_VAT_INVOICE_ feed type, which so far is only mentioned here (PDF). Seems legit, then.

Can we do a bit of verification on the keys in the FeedOptions dict being passed, as well?

@GriceTurrble
Copy link
Copy Markdown
Member

bump

Some changes will be made to the submit_feed function signature by #169 . Going to merge that first, and will handle the merge conflict myself when that's completed.

As for this pull, I dug into the C# client library a bit to confirm how Amazon uses the FeedOptions param. Unlike other params we've used, this one isn't a set of keyed params to add separately, but a single string param expected with a particular format. Per the example in Amazon's developer PDF (linked previously), we would expect a value like this:

feed_options = "metadata:shippingid=283845474;metadata:totalAmount=3.25;metadata:totalvatamount = 1.23;metadata:invoicenumber = INT-3431-XJE3;metadata:documenttype=CreditNote;metadata:transactionid=amzn:crow:429491192ksjfhe39s"

# formatted for readability:

feed_options = (
    "metadata:shippingid=283845474;"
    "metadata:totalAmount=3.25;"
    "metadata:totalvatamount = 1.23;"
    "metadata:invoicenumber = INT-3431-XJE3;"
    "metadata:documenttype=CreditNote;"
    "metadata:transactionid=amzn:crow:429491192ksjfhe39s"
)

The PDF says the following about these key-value pairs:

  • "The key value pairs should be separated by a semicolon ‘;’. The keys should be prefixed with the word ‘metadata’, followed by a colon ‘:’ and the key name. Keys can be upper case or lower case. Amazon will trim any spaces in between. The format should be ‘key1=value1;key2=value2’."
    • "keys can be upper case or lower case", I'm taking that to mean "case-insensitive".
  • "Any spaces between “=” or keys and values will be trimmed by Amazon" (don't need spaces, but they don't hurt).
  • "Do not provide quotation marks around keys or values. Amazon will only accept the following characters in any of the inputs":
    • Commas, slashes, spaces, - (dash), _ (underscore), ; (semi colon), : (colon), /, \, 0-9, A-Z, a-z, #

That all said, I can accept this PR as-is, but I would like for the feed_options argument to accept a dict with keys and string values for this metadata, i.e. {"transactionid": "abc", "documenttype": "CreditNote"}, etc. We can then pass this through a helper method that serializes that input to the format Amazon is expecting.

We can keep what's here and expect the input as a string, then add the ability to accept a dict optionally later (if isinstance(feed_options, dict):, etc.).

@GriceTurrble GriceTurrble mentioned this pull request May 2, 2020
GriceTurrble
GriceTurrble previously approved these changes Jun 25, 2020
Copy link
Copy Markdown
Member

@GriceTurrble GriceTurrble left a comment

Choose a reason for hiding this comment

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

This has been sitting idle for some time, so going to accept as-is. However, I will add an enhancement that accepts a dict argument and then processes that dict into the appropriate string value (per comments made on this PR).

@GriceTurrble GriceTurrble merged commit 44d41ac into python-amazon-mws:develop Jun 25, 2020
Lacrymology added a commit to Shiphero/python-amazon-mws that referenced this pull request Jul 10, 2020
* 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants