100 lines
3.5 KiB
Python
100 lines
3.5 KiB
Python
import time
|
|
|
|
from src.pojo.ReserveResultPojo import ReserveResultPojo, PublishType
|
|
|
|
|
|
class AcceptedAppointmentPojo(ReserveResultPojo):
|
|
accepted_at: float
|
|
day: str
|
|
|
|
def __init__(self, reserve: ReserveResultPojo):
|
|
self.id = reserve.id
|
|
self.accepted = reserve.accepted
|
|
self.passport = reserve.passport
|
|
self.url = reserve.url
|
|
self.store_type = reserve.store_type
|
|
self.lastName = reserve.last_name
|
|
self.firstName = reserve.first_name
|
|
self.ccid = reserve.ccid
|
|
self.email = reserve.mail
|
|
self.phone = reserve.phone
|
|
self.message = reserve.message
|
|
self.source_from = reserve.source_from
|
|
self.created_at = reserve.created_at
|
|
self.validated_at = reserve.validated_at
|
|
|
|
@staticmethod
|
|
def from_reserve(reserve: ReserveResultPojo):
|
|
to_return = AcceptedAppointmentPojo(reserve)
|
|
to_return.accepted_at = time.time()
|
|
return to_return
|
|
|
|
def to_firestore_dict(self):
|
|
dest = {
|
|
u'id': self.id,
|
|
u'phone': self.phone,
|
|
u'firstName': self.firstName,
|
|
u'lastName': self.lastName,
|
|
u'message': self.message,
|
|
u'email': self.email,
|
|
u'passport': self.passport,
|
|
u'url': self.url,
|
|
u'ccid': self.ccid,
|
|
u'source_from': self.source_from,
|
|
u'store_type': self.store_type,
|
|
u'accepted': self.accepted,
|
|
u'day': self.day,
|
|
u'accepted_at': self.accepted_at,
|
|
u'created_at': self.created_at,
|
|
u'validated_at': self.validated_at,
|
|
}
|
|
return dest
|
|
|
|
@staticmethod
|
|
def from_firestore_dict(source):
|
|
if 'type' in source:
|
|
publish_type = source['type']
|
|
if publish_type:
|
|
publish_type = PublishType[publish_type]
|
|
else:
|
|
publish_type = PublishType.SUCCESS
|
|
phone = source['phone']
|
|
url = source['url']
|
|
id = source['id']
|
|
email = source['email']
|
|
lastName = source['lastName']
|
|
firstName = source['firstName']
|
|
result = ReserveResultPojo(type=publish_type, phone=phone,
|
|
url=url, email=email,
|
|
firstName=firstName, lastName=lastName)
|
|
if 'accepted' in source:
|
|
accepted = source['accepted']
|
|
result.accepted = accepted
|
|
if 'message' in source:
|
|
message = source['message']
|
|
result.message = message
|
|
if 'source' in source:
|
|
source_from = source['source']
|
|
result.source_from = source_from
|
|
if 'sim_position' in source:
|
|
sim_position = source['sim_position']
|
|
result.sim_position = sim_position
|
|
if 'slot_position' in source:
|
|
slot_position = source['slot_position']
|
|
result.slot_position = slot_position
|
|
if 'passport' in source:
|
|
passport = source['passport']
|
|
result.passport = passport
|
|
if 'ccid' in source:
|
|
ccid = source['ccid']
|
|
result.ccid = ccid
|
|
if 'store_type' in source:
|
|
store_type = source['store_type']
|
|
result.store_type = store_type
|
|
result.id = id
|
|
accepted_pojo = AcceptedAppointmentPojo.from_reserve(result)
|
|
if 'accepted_at' in source:
|
|
accepted_at = source['accepted_at']
|
|
accepted_pojo.accepted_at = accepted_at
|
|
return accepted_pojo
|