python-amazon-sp-api icon indicating copy to clipboard operation
python-amazon-sp-api copied to clipboard

Added GetItemOffersBatchRequest

Open kkpalczewski opened this issue 3 years ago • 4 comments

The initial idea for addressing Batch operations, on /batches/products/pricing/v0/itemOffers endpoint.

So the main idea is to:

  1. Create request definitions, since batch requests (in our case GetItemOffersBatchRequest) are not explicitly stated in sp_api.api.products.products.Products.get_item_offers_batch function.
  2. Allow as input request definition class or Python base types requests_: Optional[Union[List[Dict], GetItemOffersBatchRequest]] = None.

The main problem is that one has to state directly "MarketplaceId" in list of requests, but addressing that will require changing self._request.

Exemplary use:

products_api.get_item_offers_batch([
        {
            "uri": "/products/pricing/v0/items/AAABBBCCCD/offers",
            "method": "GET",
            "MarketplaceId": "A1PA6795UKMFR9"
        }
    ])

kkpalczewski avatar Jul 26 '22 10:07 kkpalczewski

Thanks for working on this, +1 from me on merging the batch endpoints soon since the deadline is coming up fast.

all-iver avatar Jul 28 '22 18:07 all-iver

Thanks! Can you please make the tests working

saleweaver avatar Jul 28 '22 22:07 saleweaver

Thanks! Can you please make the tests working

Unfortunately there's no sandbox implementation for the batch calls, so the test won't work. I see there are some other tests that just do basic assertions, so maybe something like this would work?

def test_get_item_offers_batch():
    res = Products().get_item_offers_batch([])
    assert res.errors is None
    assert isinstance(res, ApiResponse)

all-iver avatar Aug 01 '22 22:08 all-iver

Yeah, that would be perfect, are the other tests working? Seems like they don't.

saleweaver avatar Aug 06 '22 21:08 saleweaver

Yeah, that would be perfect, are the other tests working? Seems like they don't.

@saleweaver It seems like @kp-sellectra may not come back to this, so I forked his and I created #693 with the test fix as suggested by @all-iver above. That change works fine, and the other tests are currently passing. If that works for you, you could close this one and approve #693. If there's a better way, I'm all ears!

dtilchin avatar Aug 16 '22 18:08 dtilchin