79 lines
2.5 KiB
Python
79 lines
2.5 KiB
Python
from dataclasses import dataclass
|
|
|
|
from src.pojo.captcha_error_contact_pojo import ContactInErrorPojo
|
|
|
|
|
|
@dataclass
|
|
class ContactPojo:
|
|
phone: str
|
|
passport: str
|
|
last_name: str
|
|
first_name: str
|
|
mail: str
|
|
store: str
|
|
ip_country: str
|
|
ip_address: str
|
|
isp: str = None
|
|
ua: str = ""
|
|
|
|
def __repr__(self):
|
|
return "phone:{}, passport:{}, last_name:{}, first_name:{}, mail:{}, store:{}, ip_country:{},isp:{}".format(
|
|
self.phone, self.passport, self.last_name, self.first_name, self.mail, self.store, self.ip_country,
|
|
self.isp)
|
|
|
|
def __init__(self, phone_number: str, passport_number: str, last_name: str, first_name: str, mail: str, store: str,
|
|
ip_country="FR"):
|
|
self.phone = str(phone_number).replace(".0", "")
|
|
self.passport = passport_number
|
|
self.last_name = last_name
|
|
self.first_name = first_name
|
|
self.mail = mail
|
|
self.store = store
|
|
self.ip_country = ip_country
|
|
self.ip_address = ""
|
|
self.ua = ""
|
|
|
|
def __hash__(self):
|
|
return hash(self.mail)
|
|
|
|
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'store': self.store,
|
|
u'ip_country': self.ip_country,
|
|
u'ua': self.ua
|
|
}
|
|
return dest
|
|
|
|
@staticmethod
|
|
def get_contact_from_error_contact(errorContact: ContactInErrorPojo):
|
|
return ContactPojo(phone_number=errorContact.phone, mail=errorContact.mail,
|
|
last_name=errorContact.last_name, first_name=errorContact.first_name,
|
|
passport_number=errorContact.passport)
|
|
|
|
@staticmethod
|
|
def from_firestore_dict(source):
|
|
phone = source['phone']
|
|
passport = source['passport']
|
|
email = source['mail']
|
|
last_name = source['last_name']
|
|
first_name = source['first_name']
|
|
store = "random"
|
|
if 'store' in source:
|
|
store = source['store']
|
|
ip_country = "FR"
|
|
if source.get('ip_country'):
|
|
ip_country = source['ip_country']
|
|
ua = ""
|
|
if source.get('ua'):
|
|
ua = source['ua']
|
|
result = ContactPojo(phone_number=phone, passport_number=passport, mail=email,
|
|
last_name=last_name, first_name=first_name, store=store)
|
|
result.ip_country = ip_country
|
|
result.ua = ua
|
|
return result
|