Return full Postmark API response from send() and add tests#126
Merged
nicholasserra merged 3 commits intothemartorana:masterfrom Oct 1, 2025
Merged
Conversation
Collaborator
|
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. |
Author
|
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() |
Author
|
I can update to reflect proposed changes that cater for previous usage as well. |
Collaborator
|
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! |
Collaborator
|
Confirmed tests are fine in master. Looks like they're broken in here. Adding some comments on the diff. |
Collaborator
|
LGTM thanks! I'll bump and do a release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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