File size: 1,245 Bytes
550665c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
from gcsa.attendee import Attendee
from .base_serializer import BaseSerializer
class AttendeeSerializer(BaseSerializer):
type_ = Attendee
def __init__(self, attendee):
super().__init__(attendee)
@staticmethod
def _to_json(attendee: Attendee):
data = {
'email': attendee.email,
'displayName': attendee.display_name,
'comment': attendee.comment,
'optional': attendee.optional,
'resource': attendee.is_resource,
'additionalGuests': attendee.additional_guests,
'responseStatus': attendee.response_status
}
return {k: v for k, v in data.items() if v is not None}
@staticmethod
def _to_object(json_attendee):
return Attendee(
email=json_attendee['email'],
display_name=json_attendee.get('displayName', None),
comment=json_attendee.get('comment', None),
optional=json_attendee.get('optional', None),
is_resource=json_attendee.get('resource', None),
additional_guests=json_attendee.get('additionalGuests', None),
_response_status=json_attendee.get('responseStatus', None)
)
|