-
Notifications
You must be signed in to change notification settings - Fork 85
Return full Postmark API response from send() and add tests #126
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
Return full Postmark API response from send() and add tests #126
Conversation
|
Thanks! I like it. We'll probably just need to bump the major version on this package, as there's likely people checking that boolean response on send. Will think on it a bit. |
|
Awesome, another option would be to add a check, or allow for an opt-in, i.e.: return_json = False return parsed if return_json else True return results if return_json else True then in mail.send() |
|
I can update to reflect proposed changes that cater for previous usage as well. |
|
I think the new change is good. Looks like tests might be broken upstream. Also I think your tests will need updated with the new changes. I'm gonna peek the test suite in master and we'll go from there. Thanks! |
|
Confirmed tests are fine in master. Looks like they're broken in here. Adding some comments on the diff. |
|
LGTM thanks! I'll bump and do a release |
Summary
This PR updates PMMail.send() and PMBatchMail.send() to return the parsed JSON response from the Postmark API instead of only True/False.
This makes it possible for client code to access useful details such as MessageID, ErrorCode, and Message without re-calling the API.
Changes
Updated PMMail.send() to return the JSON object from Postmark.
Updated PMBatchMail.send() to return a list of JSON objects (one per message).
Updated unit tests to cover both single and batch send scenarios, mocking urlopen to simulate Postmark responses.
Motivation
The previous implementation returned only a boolean, which limited insight into failures or response metadata. Returning the full response allows better error handling and logging.
Example
mail = PMMail( api_key="test-api-key", sender="sender@example.com", to="receiver@example.com", subject="Hello", text_body="Testing single mail return", ) result = mail.send() print(result["MessageID"]) # now accessibleTests
✅ test_mail_returns_result added for PMMail
✅ test_batch_mail_returns_results added for PMBatchMail