Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 205
Added get_my_fees_estimate() to products.py #216
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,9 +163,89 @@ def get_lowest_priced_offers_for_asin( | |
| } | ||
| return self.make_request(data) | ||
|
|
||
| # # # TODO add this | ||
| # def get_my_fees_estimate(self): | ||
| # pass | ||
| def get_my_fees_estimate( | ||
| self, marketplace_id, id_type, id_value, is_amazon_fulfilled, identifier, listing_price, listing_price_currency_code | ||
| ): | ||
|
|
||
| """ | ||
| Each argument must be a list, up to a length of 20, with id_value (number of ASINs or SellerSKUs) determining how many requests are made. | ||
| Options: | ||
| A single element list which repeats, or | ||
| A list of equal length as id_value for a one to one relationship | ||
|
|
||
| Example: | ||
| marketplace_id = ['A1F83G8C2ARO7P'] | ||
| id_value = ['B082YTKC47', 'B07WGJ9JGP', 'B01LXP5TXI'] | ||
| id_type = ['ASIN'] | ||
| is_amazon_fulfilled = [True, False, True] | ||
| identifier = ['request1', 'request2', 'request3'] | ||
| listing_price = [9, 16.42, 2.99] | ||
| listing_price_currency_code = ['GBP'] | ||
|
|
||
| Example 2: | ||
| marketplace_id = ['A1F83G8C2ARO7P', 'ATVPDKIKX0DER', 'A13V1IB3VIYZZH'] | ||
| id_value = ['B082YTKC47', 'B07WGJ9JGP', 'B01-LXP-TXI6'] | ||
| id_type = ['ASIN', 'ASIN', 'SellerSKU'] | ||
| is_amazon_fulfilled = [True] | ||
| identifier = ['Fee requests'] | ||
| listing_price = [19] | ||
| listing_price_currency_code = ['GBP', 'USD', 'EUR'] | ||
|
|
||
|
|
||
| Returns Amazon Fees for ASINs and SellerSKUs specified. | ||
|
|
||
| Docs: | ||
| https://docs.developer.amazonservices.com/en_UK/products/Products_GetMyFeesEstimate.html | ||
|
Comment on lines
+172
to
+198
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Despite the points made about the overall design, this is great documentation to explain the method's usage and options. Really appreciate having the docstring be this detailed to help me see the intended design. 👍 |
||
|
|
||
| """ | ||
|
|
||
| data = { | ||
| "Action": "GetMyFeesEstimate", | ||
| } | ||
|
Comment on lines
+202
to
+204
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor point, an upcoming change (#207) will move the return self.make_request("GetMyFeesEstimate", data) |
||
|
|
||
| values = [] | ||
| for i in range(len(id_value)): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a general point, iterating using for idx, val in enumerate(id_value):
print(marketplace_id[idx])
print(val) |
||
| values_dict = dict() | ||
|
|
||
| try: | ||
| values_dict['MarketplaceId'] = marketplace_id[i] | ||
| except IndexError: | ||
| values_dict['MarketplaceId'] = marketplace_id[0] | ||
|
Comment on lines
+210
to
+213
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see how this is attempting to use a list of values that contains either 1 or n items, where n is intended to be the same as the number of id_value = [0, 1, 2, 3]
marketplace_id = ['a', 'b']The above would create sets like That point is moot, however, as the design becomes too cumbersome to manage with these tightly-coupled list arguments (see other comments on review). |
||
|
|
||
| try: | ||
| values_dict['IdType'] = id_type[i] | ||
| except IndexError: | ||
| values_dict['IdType'] = id_type[0] | ||
|
|
||
| try: | ||
| values_dict['IdValue'] = id_value[i] | ||
| except IndexError: | ||
| values_dict['IdValue'] = id_value[0] | ||
|
|
||
| try: | ||
| values_dict['IsAmazonFulfilled'] = is_amazon_fulfilled[i] | ||
| except IndexError: | ||
| values_dict['IsAmazonFulfilled'] = is_amazon_fulfilled[0] | ||
|
|
||
| try: | ||
| values_dict['Identifier'] = identifier[i] | ||
| except IndexError: | ||
| values_dict['Identifier'] = identifier[0] | ||
|
|
||
| try: | ||
| values_dict['PriceToEstimateFees.ListingPrice.Amount'] = listing_price[i] | ||
| except IndexError: | ||
| values_dict['PriceToEstimateFees.ListingPrice.Amount'] = listing_price[0] | ||
|
|
||
| try: | ||
| values_dict['PriceToEstimateFees.ListingPrice.CurrencyCode'] = listing_price_currency_code[i] | ||
| except IndexError: | ||
| values_dict['PriceToEstimateFees.ListingPrice.CurrencyCode'] = listing_price_currency_code[0] | ||
|
|
||
| values.append(values_dict) | ||
|
|
||
| data.update(utils.enumerate_keyed_param("FeesEstimateRequestList.FeesEstimateRequest.", values)) | ||
| return self.make_request(data) | ||
|
|
||
| def get_my_price_for_sku(self, marketplace_id, skus, condition=None): | ||
| """ | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This design gets cumbersome to manage, as it requires every argument to be a list of exactly 1 or exactly
nelements, wherenis supposed to match the length of one of those list arguments (id_value). This cannot easily account for situations where any given list containsxnumber of elements wherex != 1 and x != n.Further, we can certainly account for the 20 request limit specified in Amazon's documentation, but current code is not performing that check.
I think we'd be better served if each item is defined by a dictionary, like so:
The request method should then be able to accept one of the following signatures:
I'm a little partial the second one myself, but either will do. 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the example also includes
shippingandpoints, which can also be requested according to documentation (see PriceToEstimateFees in the Products Datatypes doc). Full coverage of the request's potential parameters will be necessary before the method can be accepted.