Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional filters to get_shop_receipts() #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PeterAttardo
Copy link

No description provided.

@MadDriver
Copy link

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

@PeterAttardo
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants