File size: 738 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 |
from gcsa.person import Person
from .base_serializer import BaseSerializer
class PersonSerializer(BaseSerializer):
type_ = Person
def __init__(self, person):
super().__init__(person)
@staticmethod
def _to_json(person: Person):
data = {
'email': person.email,
'displayName': person.display_name
}
return {k: v for k, v in data.items() if v is not None}
@staticmethod
def _to_object(json_person):
return Person(
email=json_person['email'],
display_name=json_person.get('displayName', None),
_id=json_person.get('id', None),
_is_self=json_person.get('self', None)
)
|