skoudoro / mailerlite-api-python

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

Performance suggestion #57

Open gwillem opened 1 year ago

gwillem commented 1 year ago

Thanks for making this library!

FWIW, I think it's good Python practice to not execute remote calls upon instantiating a new object. In this case, creating an API object will run 7 identical calls to /api/v2/stats via client.check_headers().

skoudoro commented 1 year ago

Hi @gwillem,

Thank you for your suggestion, that's a good point!

I need to find a work around, because I still want to keep the possibility to just use Campaign object without using api object.

Feel free to contribute if you have a good strategy. Busy week coming, so I will look into it this coming weekend

gwillem commented 1 year ago

I still want to keep the possibility to just use Campaign object without using api object.

What is your use case? Perhaps its better to split into models and verbs? It's a common design, see for example https://github.com/chargebee/chargebee-python

Also, why are you pre-validating headers and why not just proxy the error from ML if the headers are faulty? What kind of OSError are you expecting?

The requests module already supports put and delete functions, why duplicate them in client.py?