Convert ControlResponse into a JSONResponse.
(self)
| 675 | ) |
| 676 | |
| 677 | def to_api_json_response(self) -> JSONResponse: |
| 678 | """Convert ControlResponse into a JSONResponse.""" |
| 679 | status = "success" if self.error_code == 200 else "error" |
| 680 | content = { |
| 681 | "request_id": self.request_id, |
| 682 | "status": status, |
| 683 | "error_message": self.error_message, |
| 684 | "result": self.result, |
| 685 | } |
| 686 | return JSONResponse(status_code=self.error_code, content=content) |
| 687 | |
| 688 | def __repr__(self) -> str: |
| 689 | """Provide a clean representation of the control response.""" |
no outgoing calls