o
    k7he
                     @   s   d dl mZmZmZ d dlmZmZmZ d dlmZ d dl	m
Z
 G dd deZG dd deZG d	d
 d
eZG dd deZG dd deZG dd deZG dd deZdS )    )	BaseModelFieldmodel_validator)OptionalListLiteral)datetime)ObjectIdc                   @   s   e Zd ZdZdZdS )GeofenceShapecirclepolygonN)__name__
__module____qualname__CIRCLEPOLYGON r   r   </var/www/html/moveengine/app/v1/models/platform/geofences.pyr
      s    r
   c                   @   s&   e Zd ZU ed ed< ee ed< dS )GeoJSONPointPointtypecoordinatesN)r   r   r   r   __annotations__r   floatr   r   r   r   r      s   
 r   c                   @   s   e Zd ZU eed< dZee ed< eed< dZee ed< ed ed< dZ	ee
 ed< dZee ed	< dZeeee   ed
< edddd ZdS )GeofenceBase
account_idNuser_idnamedescriptionr   r   shapecenterradiusr   aftermodec                 C   s^   | j dkr| jr| jd u rtd| S | j dkr-| jstdtdd | jD s-td| S )Nr   z8Circle geofence must include both 'center' and 'radius'.r   z,Polygon geofence must include 'coordinates'.c                 s   8    | ]}t |tot|d kotdd |D V  qdS )   c                 s       | ]}t |tV  qd S N
isinstancer   .0vr   r   r   	<genexpr>#       z?GeofenceBase.validate_shape_fields.<locals>.<genexpr>.<genexpr>Nr+   listlenallr-   cr   r   r   r/   #      6 z5GeofenceBase.validate_shape_fields.<locals>.<genexpr>0Each coordinate must be a [lng, lat] float pair.r    r!   r"   
ValueErrorr   r4   selfr   r   r   validate_shape_fields   s   

z"GeofenceBase.validate_shape_fields)r   r   r   strr   r   r   r   r   r!   r   r"   r   r   r   r   r=   r   r   r   r   r      s   
 r   c                   @   s   e Zd ZdS )GeofenceCreateN)r   r   r   r   r   r   r   r?   (   s    r?   c                   @   s   e Zd ZU dZee ed< dZee ed< dZee	d  ed< dZ
ee ed< dZee ed< dZeeee   ed< ed	d
dd ZdS )GeofenceUpdateNr   r   r   r    r!   r"   r   r#   r$   c                 C   sZ   | j dkr| jd ur| jd u rtd| S | j dkr+| jr+tdd | jD s+td| S )Nr   z;If 'shape' is 'circle', 'radius' is required with 'center'.r   c                 s   r&   )r'   c                 s   r(   r)   r*   r,   r   r   r   r/   :   r0   zAGeofenceUpdate.validate_shape_fields.<locals>.<genexpr>.<genexpr>Nr1   r5   r   r   r   r/   :   r7   z7GeofenceUpdate.validate_shape_fields.<locals>.<genexpr>r8   r9   r;   r   r   r   r=   4   s   

z$GeofenceUpdate.validate_shape_fields)r   r   r   r   r   r>   r   r   r    r   r!   r   r"   r   r   r   r   r=   r   r   r   r   r@   ,   s   
 r@   c                   @   s@   e Zd ZU dZee ed< eej	dZ
eed< G dd dZdS )GeofenceNid)default_factorycreated_datec                   @   s   e Zd ZdZdZeeiZdS )zGeofence.ConfigTN)r   r   r   populate_by_namefrom_attributesr	   r>   json_encodersr   r   r   r   ConfigC   s    rH   )r   r   r   rB   r   r>   r   r   r   utcnowrD   rH   r   r   r   r   rA   ?   s   
 rA   c                   @   s"   e Zd ZU eed< ee ed< dS )GeofencesListtotal_countusersN)r   r   r   intr   r   rA   r   r   r   r   rJ   I   s   
 rJ   N)pydanticr   r   r   typingr   r   r   r   bsonr	   r>   r
   r   r   r?   r@   rA   rJ   r   r   r   r   <module>   s    
