Response from ping
| 430 | |
| 431 | @dataclass |
| 432 | class PingResponse: |
| 433 | """Response from ping""" |
| 434 | |
| 435 | message: str # Echo message with "pong: " prefix |
| 436 | timestamp: datetime # Timestamp when the ping was processed |
| 437 | protocol_version: int # Protocol version for SDK compatibility |
| 438 | |
| 439 | @staticmethod |
| 440 | def from_dict(obj: Any) -> PingResponse: |
| 441 | assert isinstance(obj, dict) |
| 442 | message = obj.get("message") |
| 443 | timestamp = obj.get("timestamp") |
| 444 | protocol_version = obj.get("protocolVersion") |
| 445 | if message is None or timestamp is None or protocol_version is None: |
| 446 | raise ValueError( |
| 447 | f"Missing required fields in PingResponse: message={message}, " |
| 448 | f"timestamp={timestamp}, protocolVersion={protocol_version}" |
| 449 | ) |
| 450 | timestamp_value = ( |
| 451 | datetime.fromtimestamp(timestamp / 1000, tz=UTC) |
| 452 | if isinstance(timestamp, (int, float)) |
| 453 | else from_datetime(timestamp) |
| 454 | ) |
| 455 | return PingResponse(str(message), timestamp_value, int(protocol_version)) |
| 456 | |
| 457 | def to_dict(self) -> dict: |
| 458 | result: dict = {} |
| 459 | result["message"] = self.message |
| 460 | result["timestamp"] = self.timestamp.isoformat() |
| 461 | result["protocolVersion"] = self.protocol_version |
| 462 | return result |
| 463 | |
| 464 | |
| 465 | @dataclass |
no outgoing calls
no test coverage detected
searching dependent graphs…