python-amazon-sp-api
python-amazon-sp-api copied to clipboard
Added GetItemOffersBatchRequest
The initial idea for addressing Batch operations, on /batches/products/pricing/v0/itemOffers endpoint.
So the main idea is to:
- 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.
- 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"
}
])
Thanks for working on this, +1 from me on merging the batch endpoints soon since the deadline is coming up fast.
Thanks! Can you please make the tests working
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)
Yeah, that would be perfect, are the other tests working? Seems like they don't.
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!