skoudoro / mailerlite-api-python

Python wrapper for Mailerlite API v2
Other
30 stars 8 forks source link

implement limit and offset for subscribers activity #39

Closed YvesMlk closed 2 years ago

YvesMlk commented 2 years ago

I found out that the activity endpoint of the subscribers API from mailerlite has as well a limit and offset parameter. This is not specified in the mailerlite API documentation. https://developers.mailerlite.com/reference/activity-of-single-subscriber

Just calling the activity of the subscriber endpoint (with this library) doesn't return the full activity history of the subscriber.

When I call the API directly without this mailerlite-api-python wrapper library, and add limit and offset, I'm able to get the full history.

import requests

url = "https://api.mailerlite.com/api/v2/subscribers/987654321/activity?offset=0&limit=1000"

headers = {
    "Accept": "application/json",
    "X-MailerLite-ApiDocs": "true",
    "X-MailerLite-ApiKey": "....mykey..."
}

response = requests.request("GET", url, headers=headers)

print(response.text)
skoudoro commented 2 years ago

Hi @YvesMlk,

Good catch and Thank you for this feedback!

Feel free to create a Pull Request. If you can't, just let me know and I will add this parameter this week and use the opportunity to cut a release.

Thanks!

YvesMlk commented 2 years ago

Hi @skoudoro, Thanks for the quick response. I'm not quite sure how to best implement it in your code. It would be great of you could add the parameter. Thanks.

skoudoro commented 2 years ago

Hi @YvesMlk,

I just added these parameters. It will be on version v0.9.0 of mailerlite-python-api.

The version is tagged so it should be on Pipy tomorrow. pip install -U mailerlite-api-python. if it is not the case, I will have to add it manually. So maybe, tomorrow night or Thursday.

Feel free to add a star to the project, it helps 😄

Thanks again

YvesMlk commented 2 years ago

That all went pretty smooth. upgraded to version 0.9.0 Thanks for the instructions. Seems like Mailerlite has boosted the performance of the API after addressing this issue and low performance on getting the user's activity through the API.