python-sparkpost
python-sparkpost copied to clipboard
Add subaccount support
Master account can pretend be subaccount using extra header. This feature is not implemented or I did not find it.
Thanks
Pavel Cisar
Right you are. I'd like to better understand the way you use the library so we can implement this properly. I see a couple of ways subaccounts could be used:
- During instantiation of the
SparkPost
class - setting subaccount there would make it cascade down through every call:
from sparkpost import SparkPost
sp = SparkPost(subaccount=123)
response = sp.transmissions.send(
...
)
- During each request - for example
sp.transmissions.send
:
from sparkpost import SparkPost
sp = SparkPost()
response = sp.transmissions.send(
subaccount=123,
...
)
Any thoughts on which approach would best suit your use case? Is instantiating multiple instances of SparkPost
, one per subaccount, something that could work, or do we need more granular control?
Hi, for me would be better usage the second one. Specify account for each transmission. In fact, the the first way can be done already. It's not exactly like defining subaccount for master account while init, but I can create two instances with API KEYs related only to subaccounts. That should give me chance to transmit like subaccounts I think, but it seems to me quite ugly way. The second way seems to me more flexible.
Thanks for your help.
Yeah all good points - thanks for the feedback @cisarpavel. I'm going to extract this in the base resource's request
method and then pass through **kwargs
to any calls to the self.request
from the subclasses.
@jgzamora Preeeety sure this can be closed now