# coding: utf-8

"""
    Yanport API

    ## À propos Voici quelques ressources qui vous aideront à explorer notre API, si vous avez des problèmes ou des demandes, veuillez contacter le [support](mailto:support@yanport.com). ## REST API Nos services webs utilisent le protocle **HTTPS** sur le port 443, tout accès en HTTP sur le port 80 est bloqué par notre pare-feu. Les échanges de données sont réalisés en **JSON**. ## Authentification Avant de commencer à explorer notre API, vous devez nous [contacter](https://www.yanport.com/contact) afin d'obtenir un [JSON Web Token](https://jwt.io) (**JWT**) qui vous permettra de vous identifier à chaque requêtes. ### JWT (header) La méthode privilégiée pour s'authentifier est de passer à chaque requêtes le token dans le header `Authorization: Bearer {{ JWT }}` en remplaçant `{{ JWT }}` par votre token. ### JWT (query param) Il est aussi possible de passer le token directement en query param de la requête `https://api.yanport.com/?token={{ JWT }}`. (_privilégié le passage par header en production._) ## Pour démarrer Lorsque vous disposez de votre token d'authentification, vous pouvez commencer à explorer notre API grâce au boutton  `Try it out` sur chacun de nos webs services. Mais au préalable, vous devez vous authentifier en cliquant sur le boutton `Authorize `, en remplissant l'input `api_key` avec `Bearer {{ JWT }}`.  **Exemple** `Bearer eyUEkiLCJh...CHCUiBfD63oxoo=` ## Limitation Toutes les requêtes à notre API sont loggées, c'est pourquoi vous devez respecter nos [CGU](https://dev.yanport.com/cgu) afin d'éviter tout usage abusif de notre API. 

    OpenAPI spec version: 1.0
    Contact: dev@yanport.com
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..configuration import Configuration
from ..api_client import ApiClient


class EvenementsadboxApi(object):
    """
    NOTE: This class is auto generated by the swagger code generator program.
    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        config = Configuration()
        if api_client:
            self.api_client = api_client
        else:
            if not config.api_client:
                config.api_client = ApiClient()
            self.api_client = config.api_client

    def adbox_events_count_group_by_group_by_and_sub_group_by_get(self, group_by, terms_size, sub_group_by, **kwargs):
        """
        Nombre de biens
        Retourne le nombre de biens regroupés selon 1 critère et 1 sous-critère.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.adbox_events_count_group_by_group_by_and_sub_group_by_get(group_by, terms_size, sub_group_by, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str group_by: Grouper par (required)
        :param int terms_size: Précision des résultats (required)
        :param str sub_group_by: Grouper par (required)
        :param int _from: Début de la pagination
        :param int size: Nombre de résultats
        :param str sort: Trier par
        :param list[str] includes: Inclure un ou plusieurs élements par identifiant
        :param list[str] excludes: Exclure un ou plusieurs élements par identifiant
        :param list[int] user_ids: Liste d'identifiants d'utilisateurs
        :param str status: Liste de statuts d'évènements
        :param str event_types: Liste de types d'évènements
        :param list[str] tags: Identifiants (UUID) de tags
        :param list[str] property_ids: Identifiants de biens
        :param datetime event_time_min: Date minimal de la création de l'évènement (YYYY-mm-ddTHH:mm:ss)
        :param datetime event_time_max: Date maximal de la création de l'évènement (YYYY-mm-ddTHH:mm:ss)
        :return: CountResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.adbox_events_count_group_by_group_by_and_sub_group_by_get_with_http_info(group_by, terms_size, sub_group_by, **kwargs)
        else:
            (data) = self.adbox_events_count_group_by_group_by_and_sub_group_by_get_with_http_info(group_by, terms_size, sub_group_by, **kwargs)
            return data

    def adbox_events_count_group_by_group_by_and_sub_group_by_get_with_http_info(self, group_by, terms_size, sub_group_by, **kwargs):
        """
        Nombre de biens
        Retourne le nombre de biens regroupés selon 1 critère et 1 sous-critère.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.adbox_events_count_group_by_group_by_and_sub_group_by_get_with_http_info(group_by, terms_size, sub_group_by, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str group_by: Grouper par (required)
        :param int terms_size: Précision des résultats (required)
        :param str sub_group_by: Grouper par (required)
        :param int _from: Début de la pagination
        :param int size: Nombre de résultats
        :param str sort: Trier par
        :param list[str] includes: Inclure un ou plusieurs élements par identifiant
        :param list[str] excludes: Exclure un ou plusieurs élements par identifiant
        :param list[int] user_ids: Liste d'identifiants d'utilisateurs
        :param str status: Liste de statuts d'évènements
        :param str event_types: Liste de types d'évènements
        :param list[str] tags: Identifiants (UUID) de tags
        :param list[str] property_ids: Identifiants de biens
        :param datetime event_time_min: Date minimal de la création de l'évènement (YYYY-mm-ddTHH:mm:ss)
        :param datetime event_time_max: Date maximal de la création de l'évènement (YYYY-mm-ddTHH:mm:ss)
        :return: CountResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['group_by', 'terms_size', 'sub_group_by', '_from', 'size', 'sort', 'includes', 'excludes', 'user_ids', 'status', 'event_types', 'tags', 'property_ids', 'event_time_min', 'event_time_max']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method adbox_events_count_group_by_group_by_and_sub_group_by_get" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'group_by' is set
        if ('group_by' not in params) or (params['group_by'] is None):
            raise ValueError("Missing the required parameter `group_by` when calling `adbox_events_count_group_by_group_by_and_sub_group_by_get`")
        # verify the required parameter 'terms_size' is set
        if ('terms_size' not in params) or (params['terms_size'] is None):
            raise ValueError("Missing the required parameter `terms_size` when calling `adbox_events_count_group_by_group_by_and_sub_group_by_get`")
        # verify the required parameter 'sub_group_by' is set
        if ('sub_group_by' not in params) or (params['sub_group_by'] is None):
            raise ValueError("Missing the required parameter `sub_group_by` when calling `adbox_events_count_group_by_group_by_and_sub_group_by_get`")

        if 'terms_size' in params and params['terms_size'] > 100:
            raise ValueError("Invalid value for parameter `terms_size` when calling `adbox_events_count_group_by_group_by_and_sub_group_by_get`, must be a value less than or equal to `100`")
        if 'terms_size' in params and params['terms_size'] < 10:
            raise ValueError("Invalid value for parameter `terms_size` when calling `adbox_events_count_group_by_group_by_and_sub_group_by_get`, must be a value greater than or equal to `10`")
        if '_from' in params and params['_from'] < 0:
            raise ValueError("Invalid value for parameter `_from` when calling `adbox_events_count_group_by_group_by_and_sub_group_by_get`, must be a value greater than or equal to `0`")
        if 'size' in params and params['size'] > 1000:
            raise ValueError("Invalid value for parameter `size` when calling `adbox_events_count_group_by_group_by_and_sub_group_by_get`, must be a value less than or equal to `1000`")
        if 'size' in params and params['size'] < 0:
            raise ValueError("Invalid value for parameter `size` when calling `adbox_events_count_group_by_group_by_and_sub_group_by_get`, must be a value greater than or equal to `0`")

        collection_formats = {}

        path_params = {}
        if 'group_by' in params:
            path_params['groupBy'] = params['group_by']
        if 'sub_group_by' in params:
            path_params['subGroupBy'] = params['sub_group_by']

        query_params = []
        if '_from' in params:
            query_params.append(('from', params['_from']))
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'sort' in params:
            query_params.append(('sort', params['sort']))
        if 'includes' in params:
            query_params.append(('includes', params['includes']))
            collection_formats['includes'] = 'multi'
        if 'excludes' in params:
            query_params.append(('excludes', params['excludes']))
            collection_formats['excludes'] = 'multi'
        if 'user_ids' in params:
            query_params.append(('userIds', params['user_ids']))
            collection_formats['userIds'] = 'multi'
        if 'status' in params:
            query_params.append(('status', params['status']))
        if 'event_types' in params:
            query_params.append(('eventTypes', params['event_types']))
        if 'tags' in params:
            query_params.append(('tags', params['tags']))
            collection_formats['tags'] = 'multi'
        if 'property_ids' in params:
            query_params.append(('propertyIds', params['property_ids']))
            collection_formats['propertyIds'] = 'multi'
        if 'event_time_min' in params:
            query_params.append(('eventTimeMin', params['event_time_min']))
        if 'event_time_max' in params:
            query_params.append(('eventTimeMax', params['event_time_max']))
        if 'terms_size' in params:
            query_params.append(('termsSize', params['terms_size']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['jwt']

        return self.api_client.call_api('/adbox-events/count/group-by-{groupBy}-and-{subGroupBy}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='CountResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)

    def adbox_events_count_group_by_group_by_get(self, group_by, terms_size, **kwargs):
        """
        Nombre de biens
        Retourne le nombre de biens regroupés selon 1 critère
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.adbox_events_count_group_by_group_by_get(group_by, terms_size, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str group_by: Grouper par (required)
        :param int terms_size: Précision des résultats (required)
        :param int _from: Début de la pagination
        :param int size: Nombre de résultats
        :param str sort: Trier par
        :param list[str] includes: Inclure un ou plusieurs élements par identifiant
        :param list[str] excludes: Exclure un ou plusieurs élements par identifiant
        :param list[int] user_ids: Liste d'identifiants d'utilisateurs
        :param str status: Liste de statuts d'évènements
        :param str event_types: Liste de types d'évènements
        :param list[str] tags: Identifiants (UUID) de tags
        :param list[str] property_ids: Identifiants de biens
        :param datetime event_time_min: Date minimal de la création de l'évènement (YYYY-mm-ddTHH:mm:ss)
        :param datetime event_time_max: Date maximal de la création de l'évènement (YYYY-mm-ddTHH:mm:ss)
        :return: CountResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.adbox_events_count_group_by_group_by_get_with_http_info(group_by, terms_size, **kwargs)
        else:
            (data) = self.adbox_events_count_group_by_group_by_get_with_http_info(group_by, terms_size, **kwargs)
            return data

    def adbox_events_count_group_by_group_by_get_with_http_info(self, group_by, terms_size, **kwargs):
        """
        Nombre de biens
        Retourne le nombre de biens regroupés selon 1 critère
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.adbox_events_count_group_by_group_by_get_with_http_info(group_by, terms_size, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str group_by: Grouper par (required)
        :param int terms_size: Précision des résultats (required)
        :param int _from: Début de la pagination
        :param int size: Nombre de résultats
        :param str sort: Trier par
        :param list[str] includes: Inclure un ou plusieurs élements par identifiant
        :param list[str] excludes: Exclure un ou plusieurs élements par identifiant
        :param list[int] user_ids: Liste d'identifiants d'utilisateurs
        :param str status: Liste de statuts d'évènements
        :param str event_types: Liste de types d'évènements
        :param list[str] tags: Identifiants (UUID) de tags
        :param list[str] property_ids: Identifiants de biens
        :param datetime event_time_min: Date minimal de la création de l'évènement (YYYY-mm-ddTHH:mm:ss)
        :param datetime event_time_max: Date maximal de la création de l'évènement (YYYY-mm-ddTHH:mm:ss)
        :return: CountResponse
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['group_by', 'terms_size', '_from', 'size', 'sort', 'includes', 'excludes', 'user_ids', 'status', 'event_types', 'tags', 'property_ids', 'event_time_min', 'event_time_max']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method adbox_events_count_group_by_group_by_get" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'group_by' is set
        if ('group_by' not in params) or (params['group_by'] is None):
            raise ValueError("Missing the required parameter `group_by` when calling `adbox_events_count_group_by_group_by_get`")
        # verify the required parameter 'terms_size' is set
        if ('terms_size' not in params) or (params['terms_size'] is None):
            raise ValueError("Missing the required parameter `terms_size` when calling `adbox_events_count_group_by_group_by_get`")

        if 'terms_size' in params and params['terms_size'] > 100:
            raise ValueError("Invalid value for parameter `terms_size` when calling `adbox_events_count_group_by_group_by_get`, must be a value less than or equal to `100`")
        if 'terms_size' in params and params['terms_size'] < 10:
            raise ValueError("Invalid value for parameter `terms_size` when calling `adbox_events_count_group_by_group_by_get`, must be a value greater than or equal to `10`")
        if '_from' in params and params['_from'] < 0:
            raise ValueError("Invalid value for parameter `_from` when calling `adbox_events_count_group_by_group_by_get`, must be a value greater than or equal to `0`")
        if 'size' in params and params['size'] > 1000:
            raise ValueError("Invalid value for parameter `size` when calling `adbox_events_count_group_by_group_by_get`, must be a value less than or equal to `1000`")
        if 'size' in params and params['size'] < 0:
            raise ValueError("Invalid value for parameter `size` when calling `adbox_events_count_group_by_group_by_get`, must be a value greater than or equal to `0`")

        collection_formats = {}

        path_params = {}
        if 'group_by' in params:
            path_params['groupBy'] = params['group_by']

        query_params = []
        if '_from' in params:
            query_params.append(('from', params['_from']))
        if 'size' in params:
            query_params.append(('size', params['size']))
        if 'sort' in params:
            query_params.append(('sort', params['sort']))
        if 'includes' in params:
            query_params.append(('includes', params['includes']))
            collection_formats['includes'] = 'multi'
        if 'excludes' in params:
            query_params.append(('excludes', params['excludes']))
            collection_formats['excludes'] = 'multi'
        if 'user_ids' in params:
            query_params.append(('userIds', params['user_ids']))
            collection_formats['userIds'] = 'multi'
        if 'status' in params:
            query_params.append(('status', params['status']))
        if 'event_types' in params:
            query_params.append(('eventTypes', params['event_types']))
        if 'tags' in params:
            query_params.append(('tags', params['tags']))
            collection_formats['tags'] = 'multi'
        if 'property_ids' in params:
            query_params.append(('propertyIds', params['property_ids']))
            collection_formats['propertyIds'] = 'multi'
        if 'event_time_min' in params:
            query_params.append(('eventTimeMin', params['event_time_min']))
        if 'event_time_max' in params:
            query_params.append(('eventTimeMax', params['event_time_max']))
        if 'terms_size' in params:
            query_params.append(('termsSize', params['terms_size']))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.\
            select_header_accept(['application/json'])

        # Authentication setting
        auth_settings = ['jwt']

        return self.api_client.call_api('/adbox-events/count/group-by-{groupBy}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='CountResponse',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _return_http_data_only=params.get('_return_http_data_only'),
                                        _preload_content=params.get('_preload_content', True),
                                        _request_timeout=params.get('_request_timeout'),
                                        collection_formats=collection_formats)
