Created
May 29, 2024 04:33
-
-
Save marteinn/36c95aa7b24edfc9d8406cbd4d5dcde7 to your computer and use it in GitHub Desktop.
Convert firebase BatchResponse to a JSON serializable struct
This file contains 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
from typing import Dict, List | |
from firebase_admin.messaging import BatchResponse, SendResponse | |
def batch_response_to_dict(batch_response: BatchResponse) -> Dict: | |
responses: List[SendResponse] = batch_response.responses | |
return { | |
"responses": [ | |
{ | |
"message_id": x.message_id, | |
"success": x.success, | |
"exception": str(x.exception) if x.exception else None, | |
} | |
for x in responses | |
], | |
"success_count": batch_response.success_count, | |
"failure_count": batch_response.failure_count, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment