reservations_response.py 833 B

12345678910111213141516171819202122232425262728
  1. from .reservation import reservation
  2. from .reservations_collection import reservations_collection
  3. class reservations_response:
  4. def collection(self, targets: list) -> list:
  5. result = list()
  6. for count in targets:
  7. if not isinstance(count, reservation):
  8. raise TypeError("Reservations list not contain reservation.")
  9. result.append(self.single(count))
  10. return result
  11. def single(self, target: reservation) -> dict:
  12. response = {
  13. "target_name": target.target.name,
  14. "target_barcode": target.target.barcode
  15. }
  16. if target.email is not None:
  17. response["email"] = target.email
  18. if target.phone_number is not None:
  19. response["phone_number"] = target.phone_number
  20. return response