58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
from dataclasses import dataclass
|
|
|
|
from pojo.captcha_error_contact_pojo import ContactInErrorPojo
|
|
|
|
|
|
@dataclass
|
|
class ContactPojo:
|
|
phone: str
|
|
passport: str
|
|
last_name: str
|
|
first_name: str
|
|
mail: str
|
|
ccid: str
|
|
position: int
|
|
|
|
def __init__(self, phone_number: str, passport_number: str, last_name: str, first_name: str, mail: str,
|
|
ccid: str = "",
|
|
position: int = 0):
|
|
self.phone = phone_number
|
|
self.passport = passport_number
|
|
self.last_name = last_name
|
|
self.first_name = first_name
|
|
self.ccid = ccid
|
|
self.mail = mail
|
|
self.position = position
|
|
|
|
def to_firestore_dict(self):
|
|
dest = {
|
|
u'phone': self.phone,
|
|
u'passport': self.passport,
|
|
u'last_name': self.last_name,
|
|
u'first_name': self.first_name,
|
|
u'mail': self.mail,
|
|
u'ccid': self.ccid,
|
|
u'position': self.position
|
|
}
|
|
|
|
return dest
|
|
|
|
@staticmethod
|
|
def get_contact_from_error_contact(errorContact: ContactInErrorPojo):
|
|
return ContactPojo(phone_number=errorContact.phone, mail=errorContact.mail, ccid=errorContact.ccid,
|
|
last_name=errorContact.last_name, first_name=errorContact.first_name,
|
|
position=errorContact.position, passport_number=errorContact.passport)
|
|
|
|
@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']
|
|
result = ContactPojo(ccid=ccid, phone_number=phone, passport_number=passport, position=position, mail=email,
|
|
last_name=last_name, first_name=first_name)
|
|
return result
|