etsyv3 icon indicating copy to clipboard operation
etsyv3 copied to clipboard

Add optional filters to get_shop_receipts()

Open PeterAttardo opened this issue 1 year ago • 2 comments

PeterAttardo avatar Jan 07 '24 00:01 PeterAttardo

Do you have a fork with this PR integrated? I would like to use it.

MadDriver avatar Apr 27 '24 05:04 MadDriver

I do not, but you can manually hack this change into your code by either monkeypatching the existing EtsyAPI class, or by defining a new class that inherits from EtsyAPI and overwriting the get_shop_receipts method, like so:

class EtsyAPIPatched(EtsyAPI):
    def get_shop_receipts(
            self,
            shop_id: int,
            limit: Optional[int] = None,
            offset: Optional[int] = None,
            was_paid: bool = True,
            was_shipped: bool = False,
            was_canceled: Optional[bool] = None,
            min_created: Optional[int] = None,
            max_created: Optional[int] = None,
            min_last_modified: Optional[int] = None,
            max_last_modified: Optional[int] = None,
            sort_on: Optional[str] = None,
            sort_order: Optional[str] = None,
            was_delivered: Optional[bool] = None,
    ) -> Any:
        uri = f"{ETSY_API_BASEURL}/shops/{shop_id}/receipts"
        kwargs: Dict[str, Any] = {
            "limit": limit,
            "offset": offset,
            "was_paid": was_paid,
            "was_shipped": was_shipped,
            "was_canceled": was_canceled,
            "min_created": min_created,
            "max_created": max_created,
            "min_last_modified": min_last_modified,
            "max_last_modified": max_last_modified,
            "sort_on": sort_on,
            "sort_order": sort_order,
            "was_delivered": was_delivered,
        }
        return self._issue_request(uri, **kwargs)

PeterAttardo avatar Apr 27 '24 05:04 PeterAttardo

Sorry for the delay - been a bit recently. But thanks for your help!

anitabyte avatar Aug 10 '24 11:08 anitabyte