Files
appointment_tool/src/pojo/black_contact.py
T
PAN Lei bfcfb191fc merge
2022-07-05 09:44:32 +02:00

39 lines
1.4 KiB
Python

import time
from typing import Union
from src.pojo.contact_pojo import ContactPojo
class BlackContactPojo(ContactPojo):
update_at_in_s: float
def __init__(self, phone_number: str, passport_number: str, last_name: str, first_name: str, mail: str,
update_at_in_s: Union[float, None] = None,
ccid: str = "",
position: int = 0, ):
super().__init__(phone_number, passport_number, last_name, first_name, mail, ccid, position)
if update_at_in_s:
self.update_at_in_s = update_at_in_s
else:
self.update_at_in_s = time.time()
def to_firestore_dict(self):
dest = super().to_firestore_dict()
dest.setdefault(u'update_at_in_s', self.update_at_in_s)
return dest
@staticmethod
def from_firestore_dict(source):
ccid = source['ccid']
phone = source['phone']
position = source['position']
passport = source['passport']
email = source['mail']
last_name = source['last_name']
first_name = source['first_name']
update_at_in_s = source['update_at_in_s']
result = BlackContactPojo(ccid=ccid, phone_number=phone, passport_number=passport, position=position,
mail=email, update_at_in_s=update_at_in_s,
last_name=last_name, first_name=first_name)
return result