message.py 882 B

12345678910111213141516171819202122232425262728293031323334
  1. # TODO: Message design
  2. class ShowroomMessage(object):
  3. def __init__(self, ident, query, *, content: dict=None):
  4. self._query = query
  5. self._ident = ident
  6. self._content = content
  7. @property
  8. def query(self):
  9. return self._query
  10. # TODO: settle on a name for this before using it anywhere
  11. @property
  12. def ident(self):
  13. return self._ident
  14. @property
  15. def content(self):
  16. return self._content
  17. def set_content(self, new_content):
  18. # TODO: content validation?
  19. self._content = new_content
  20. def json(self):
  21. # content is already a dict
  22. # although some items might not be, e.g. datetime
  23. # this exists basically to mimic requests Response
  24. # TODO: handle datetime and other objects json can't
  25. # though that wouldn't happen here
  26. return self._content