websideproject / paddle-billing-client

Python wrapper around the new Paddle Billing API
MIT License
14 stars 6 forks source link

The client.list_events() method doesn't support pagination #188

Closed archatas closed 10 months ago

archatas commented 10 months ago

🐛 Bug Report

The client.list_events() method doesn't support pagination although it should according to documentation (and in general it makes sense to have events paginations, because there will be a lot of them in an active project.

https://developer.paddle.com/api-reference/events/list-events

Error raised:

TypeError: PaddleApiClient.list_events() got an unexpected keyword argument 'paginate'

🔬 How To Reproduce

Steps to reproduce the behavior:

  1. Create a notification setting pointing to some webhook.
  2. Trigger notifications at Paddle sandbox like editing address or business information of a person (or anything else)
  3. Call paginate(client.list_events)

Code sample

from paddle_billing_client.pagination import paginate

for events_response in paginate(self.client.list_events):
    for api_event in events_response.data:
        print(api_event)

Environment

bgervan commented 10 months ago

I have changed that function. Although, I think the event api is kind of ignorable in favor of notification, where you see the processed events too (and failed), which is not true for the events api.

What is your use case? Maybe I am missing something

bgervan commented 10 months ago

Fixed in https://github.com/websideproject/paddle-billing-client/releases/tag/v0.1.16

archatas commented 10 months ago

In my Django app, I am syncing all info from Paddle Billing with analogous models on Django for the ability to have a dashboard or statistics later depending on further ideas and future requirements.

In general, Event objects are retrieved by webhooks, and it might be useful to sync past events before getting the new ones for any possible statistics.

archatas commented 10 months ago

If I understand correctly, when a change happens at Paddle Billing, and event is created. If there are Notification settings (maybe more than one, e.g. your website + affiliate website, or multiple of your websites that share the same Paddle account, then notifications are created for each of those notification settings.

archatas commented 10 months ago

By the way, thank you again for such a quick reaction!

bgervan commented 10 months ago

Yes, you need notification settings to get events via webhook.

I am working on a Django package which utilize this client package. My flow is that you store many different models and every write comes from paddle notification, so works as a reading "cache". If there is unprocessed you can replay those notifications, you can filter to those by query.

Before activating the notification, you can fetch all models to get the current state, if you have past events.

I will think about how useful to get the events to get some kind of analytics, but there is a new endpoint to get reports, so maybe that can be used to show some cool charts in your admin.

archatas commented 10 months ago

What's the name of your Django package? I don't want to have a name clash. As I am also planning to release it.

bgervan commented 10 months ago

django-paddle-billing or dj-paddle-billing, it's not published yet

archatas commented 10 months ago

Mine is django-paddle-billing and will be a paid one. Also unpublished yet. If you are alright with dj-paddle-billing, then there is no need to renaming anything. Otherwise, I need to think of something different.

bgervan commented 10 months ago

That still mean the same, in the readme the title still Django Paddle Billing, so "seo" wise, there should be some better names which differenciate the two package

archatas commented 10 months ago

OK. Then I take the name dj-paddle-subscriptions. :)

bgervan commented 10 months ago

Good name. Thanks for the flexibility :)

archatas commented 10 months ago

Thanks for the great package! Without it my API calls would probably be without type checking, so less robust.