saleweaver / python-amazon-sp-api

Python wrapper to access the amazon selling partner API
https://python-amazon-sp-api.readthedocs.io/en/latest/
MIT License
520 stars 234 forks source link

Add product_pricing client #1390

Closed alixleger closed 2 months ago

alixleger commented 4 months ago

Hi,

I saw that the product pricing v2022-05-01 isn't implemented yet so here is the related PR, generated with the make_endpoint command.

I also saw that the v0 is implemented in a Client named "Products" so I don't really know if it's better to merge these 2 clients in a single one...

I remain available if any changes are required.

Thanks a lot for that project !

saleweaver commented 4 months ago

Hi,

thanks for this. The clients usually use versioning (for example visible in CatalogItems).


class CatalogItemsVersion(str, enum.Enum):
    V_2020_12_01 = "2020-12-01"
    V_2022_04_01 = "2022-04-01"
    LATEST = "2022-04-01"

class CatalogItems(Client):

...
    @sp_endpoint('/catalog/<version>/items', method='GET')
    def search_catalog_items(self, **kwargs) -> ApiResponse:

I think we should keep it that way - do you mind to amend the PR to the existing structure?

alixleger commented 4 months ago

Hi @saleweaver , the problem with that ProductPricing endpoint is that operations implemented in the v0 aren't implemented in the next version (2022-05-01) and operations implemented in that last version aren't in the v0.

Do you still want me to set up versioning on the Products client?

saleweaver commented 4 months ago

The endpoint is one of the first I've implemented in the library, so the naming is wrong either way. I'll go ahead and merge your PR, then it's named correctly as well... 😄

alixleger commented 4 months ago

I've just merge it on the current Products client, but I've just don't used the versioning, I can do it if needed as well 😉

xEverth commented 4 months ago

Hello @saleweaver , Do you have style guides or indications on method versioning? In the 1.5.0 you merged changes for FulfillmentInbound but there are some operations that have been deprecated and do not exist in the 2024-03-20 version

The deprecated decorator doesn't take the client version into account and the version is added to the endpoint by _check_version in the Client call to _request, so it's too late to specify that one operation is not supported for the selected client version and Amazon will respond with an error.

@sp_endpoint('/inbound/fba/<version>/inboundPlans/{}', method='GET') def get_shipment(self, inboundPlanId, **kwargs) -> ApiResponse:

If this is intended, and you should keep different client versions around for different operations, then no change is required.

If on the other hand you envision a way to specify when a method is only available to certain versions of the client and prevent from calling altogether, I may give it a shot at implementing it for the FulfillmentInbound.

Let me know and thank you!

saleweaver commented 4 months ago

@xEverth thanks a lot for this!!! I had the idea to modify the deprecated decorator (or create another one) as well - if you want to take a shot at it, I'll be more than happy to merge it. IMO decorating the methods with deprecated since version or something would be ideal.