o
    w+f+                     @   sT   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 )c                   @   s   e Zd ZdZ	dddZdd Zdd Zed	d
 Zej	dd
 Zedd Z
e
j	dd Z
edd Zej	dd Zedd Zej	dd Zedd Zej	dd Zedd Zej	dd Zedd Zej	dd ZdS )StatszP
    Object for building query params for a global email statistics request
    Nc                 C   s<   d| _ d| _d| _d| _d| _d| _d| _|r|| _dS dS )zCreate a Stats object

        :param start_date: Date of when stats should begin in YYYY-MM-DD format, defaults to None
        :type start_date: string, optional
        N)_start_date	_end_date_aggregated_by_sort_by_metric_sort_by_direction_limit_offset
start_date)selfr	    r   O/var/www/html/venv/lib/python3.10/site-packages/sendgrid/helpers/stats/stats.py__init__   s   
zStats.__init__c                 C   s   t |  S )zJGet a JSON representation of this object.

        :rtype: string
        )strgetr
   r   r   r   __str__   s   zStats.__str__c                 C   s   i }| j dur| j |d< | jdur| j|d< | jdur | j|d< | jdur*| j|d< | jdur4| j|d< | jdur>| j|d< | jdurH| j|d< |S )	z
        Get a JSON-ready representation of Stats

        :returns: This GlobalStats, ready for use in a request body.
        :rtype: response stats dict
        Nr	   end_dateaggregated_bysort_by_metricsort_by_directionlimitoffset)r	   r   r   r   r   r   r   r
   statsr   r   r   r      s    













z	Stats.getc                 C      | j S )zUDate of when stats should begin in YYYY-MM-DD format

        :rtype: string
        r   r   r   r   r   r	   7      zStats.start_datec                 C   
   || _ dS )zDate of when stats should begin in YYYY-MM-DD format

        :param value: Date representing when stats should begin
        :type value: string
        Nr   r
   valuer   r   r   r	   ?      
c                 C   r   )zSDate of when stats should end in YYYY-MM-DD format

        :rtype: string
        r   r   r   r   r   r   H   r   zStats.end_datec                 C   r   )zDate of when stats should end in YYYY-MM-DD format

        :param value: Date representing when stats should end
        :type value: string
        Nr!   r   r   r   r   r   P   r    c                 C   r   )zfChosen period (e.g. 'day', 'week', 'month') for how stats get grouped

        :rtype: string
        r   r   r   r   r   r   Y   r   zStats.aggregated_byc                 C   r   )zChosen period (e.g. 'day', 'week', 'month') for how stats get grouped

        :param value: Period for how keys will get formatted
        :type value: string
        Nr"   r   r   r   r   r   a   r    c                 C   r   )z8Metric to sort stats by

        :rtype: string
        r   r   r   r   r   r   j   r   zStats.sort_by_metricc                 C   r   )zyMetric to sort stats by

        :param value: Chosen metric stats will by sorted by
        :type value: string
        Nr#   r   r   r   r   r   r   r    c                 C   r   )zVDirection data will be sorted, either 'asc' or 'desc'

        :rtype: string
        r   r   r   r   r   r   {   r   zStats.sort_by_directionc                 C   r   )zDirection data will be sorted, either 'asc' or 'desc'

        :param value: Direction of data, either 'asc' or 'desc'
        :type value: string
        Nr$   r   r   r   r   r      r    c                 C   r   )zBMax amount of results to be returned

        :rtype: int
        r   r   r   r   r   r      r   zStats.limitc                 C   r   )zsMax amount of results to be returned

        :param value: Max amount of results
        :type value: int
        Nr%   r   r   r   r   r      r    c                 C   r   )zWNumber of places a starting point of a data set will move

        :rtype: int
        r   r   r   r   r   r      r   zStats.offsetc                 C   r   )zNumber of places a starting point of a data set will move

        :param value: Number of positions to move from starting point
        :type value: int
        Nr&   r   r   r   r   r      r    N)__name__
__module____qualname____doc__r   r   r   propertyr	   setterr   r   r   r   r   r   r   r   r   r   r      sD    













r   c                       >   e Zd ZdZd fdd	Zdd Zedd Zd	d
 Z  Z	S )CategoryStatszL
    object for building query params for a category statistics request
    Nc                    F   d| _ tt|   |r|r|| _|D ]}| t| qdS dS dS )a7  Create a CategoryStats object

        :param start_date: Date of when stats should begin in YYYY-MM-DD format, defaults to None
        :type start_date: string, optional
        :param categories: list of categories to get results of, defaults to None
        :type categories: list(string), optional
        N)_categoriessuperr/   r   r	   add_categoryCategory)r
   r	   
categoriescat_name	__class__r   r   r         zCategoryStats.__init__c                 C      i }| j dur| j |d< | jdur| j|d< | jdur | j|d< | jdur*| j|d< | jdur4| j|d< | jdur>| j|d< | jdurH| j|d< | jdurWd	d
 | jD |d< |S )zw
        Get a JSON-ready representation of this CategoryStats.

        :return: response category stats dict
        Nr	   r   r   r   r   r   r   c                 S      g | ]}|  qS r   r   ).0categoryr   r   r   
<listcomp>       z%CategoryStats.get.<locals>.<listcomp>r5   )r	   r   r   r   r   r   r   r5   r   r   r   r   r      (   















zCategoryStats.getc                 C   r   )z;List of categories

        :rtype: list(Category)
        )r1   r   r   r   r   r5      r   zCategoryStats.categoriesc                 C       | j du rg | _ | j | dS )zAppends a category to this object's category list

        :param category: Category to append to CategoryStats
        :type category: Category
        N)r1   append)r
   r>   r   r   r   r3         
zCategoryStats.add_categoryNN)
r(   r)   r*   r+   r   r   r,   r5   r3   __classcell__r   r   r7   r   r/          
r/   c                       r.   )SubuserStatszJ
    object of building query params for a subuser statistics request
    Nc                    r0   )a0  Create a SubuserStats object

        :param start_date: Date of when stats should begin in YYYY-MM-DD format, defaults to None
        :type start_date: string, optional
        :param subusers: list of subusers to get results of, defaults to None
        :type subusers: list(string), optional
        N)	_subusersr2   rH   r   r	   add_subuserSubuser)r
   r	   subuserssubuser_namer7   r   r   r      r9   zSubuserStats.__init__c                 C   r:   )zu
        Get a JSON-ready representation of this SubuserStats.

        :return: response subuser stats dict
        Nr	   r   r   r   r   r   r   c                 S   r;   r   r<   )r=   subuserr   r   r   r?     r@   z$SubuserStats.get.<locals>.<listcomp>rL   )r	   r   r   r   r   r   r   rL   r   r   r   r   r     rA   zSubuserStats.getc                 C   r   )z8List of subusers

        :rtype: list(Subuser)
        )rI   r   r   r   r   rL      r   zSubuserStats.subusersc                 C   rB   )zAppends a subuser to this object's subuser list

        :param subuser: Subuser to append to SubuserStats
        :type subuser: Subuser
        N)rI   rC   )r
   rN   r   r   r   rJ   (  rD   zSubuserStats.add_subuserrE   )
r(   r)   r*   r+   r   r   r,   rL   rJ   rF   r   r   r7   r   rH      rG   rH   c                   @   <   e Zd ZdZd
ddZedd Zejdd Zdd	 ZdS )r4   zZ
    Represents a searchable statistics category to be used in a CategoryStats object
    Nc                 C      d| _ |dur|| _ dS dS )zCreate a Category object

        :param name: name of category, defaults to None
        :type name: string, optional
        N_namer
   namer   r   r   r   7     
zCategory.__init__c                 C   r   )z5Get name of category

        :rtype: string
        rQ   r   r   r   r   rT   A  r   zCategory.namec                 C   r   )zqSet name of category

        :param value: name of the statistical category
        :type value: string
        NrQ   r   r   r   r   rT   I  r    c                 C   r   )zj
        Get a string representation of Category.

        :return: string of the category's name
        rT   r   r   r   r   r   R  r   zCategory.getr'   	r(   r)   r*   r+   r   r,   rT   r-   r   r   r   r   r   r4   3      



r4   c                   @   rO   )rK   zM
    Represents a searchable subuser to be used in a SubuserStats object
    Nc                 C   rP   )z}Create a Subuser object

        :param name: name of subuser, defaults to None
        :type name: string, optional
        NrQ   rS   r   r   r   r   _  rU   zSubuser.__init__c                 C   r   )z8Get name of the subuser

        :rtype: string
        rQ   r   r   r   r   rT   i  r   zSubuser.namec                 C   r   )zgSet name of the subuser

        :param value: name of the subuser
        :type value: string
        NrQ   r   r   r   r   rT   q  r    c                 C   r   )zh
        Get a string representation of Subuser.

        :return: string of the subuser's name
        rV   r   r   r   r   r   z  r   zSubuser.getr'   rW   r   r   r   r   rK   [  rX   rK   N)objectr   r/   rH   r4   rK   r   r   r   r   <module>   s     /BB(