# Path: zenpy/lib/exception.py
# class ZenpyException(Exception):
#     """
#     A ``ZenpyException`` is raised for internal errors.
#     """
# 
# Path: zenpy/lib/util.py
# def is_iterable_but_not_string(obj):
#     """
#     Determine whether or not obj is iterable but not a string (eg, a list, set, tuple etc).
#     """
#     return hasattr(obj, '__iter__') and not isinstance(
#         obj, str) and not isinstance(obj, bytes)
# 
# def to_unix_ts(start_time):
#     """Given a datetime object, returns its value as a unix timestamp"""
#     if isinstance(start_time, datetime):
#         if is_timezone_aware(start_time):
#             start_time = start_time.astimezone(pytz.utc)
#         else:
#             log.warning(
#                 "Non timezone-aware datetime object passed to IncrementalEndpoint. "
#                 "The Zendesk API expects UTC time, if this is not the case results will be incorrect!"
#             )
#         unix_time = calendar.timegm(start_time.timetuple())
#     else:
#         unix_time = start_time
# 
#     return int(unix_time)


import logging
from datetime import date
from datetime import datetime
from requests.utils import quote
from zenpy.lib.exception import ZenpyException
from zenpy.lib.util import is_iterable_but_not_string, to_unix_ts
    from urllib import urlencode
    from urlparse import urlunsplit, SplitResult
    from urllib.parse import urlencode
    from urllib.parse import urlunsplit, SplitResult
    +-----------------+------------------+
    | \*_before       | < (time|date)    |
    +-----------------+------------------+
    | minus           | \- (negation)    |
    +-----------------+------------------+
    | \*_between      | > < (dates only) |
    +-----------------+------------------+

    For example the call:

    .. code:: python

      zenpy.search("zenpy", created_between=[yesterday, today], type='ticket', minus='negated')

    Would generate the following API call:
    ::
        /api/v2/search.json?query=zenpy+created>2015-08-29 created<2015-08-30+type:ticket+-negated


    """
    def __call__(self, query=None, **kwargs):

        renamed_kwargs = dict()
        modifiers = list()
        params = dict()
        for key, value in kwargs.items():
            if isinstance(value, datetime):
                kwargs[key] = value.strftime(self.ISO_8601_FORMAT)
            elif isinstance(value, date):
                kwargs[key] = value.strftime(self.ZENDESK_DATE_FORMAT)

# Path: zenpy/lib/exception.py
# class ZenpyException(Exception):
#     """
#     A ``ZenpyException`` is raised for internal errors.
#     """
# 
# Path: zenpy/lib/util.py
# def is_iterable_but_not_string(obj):
#     """
#     Determine whether or not obj is iterable but not a string (eg, a list, set, tuple etc).
#     """
#     return hasattr(obj, '__iter__') and not isinstance(
#         obj, str) and not isinstance(obj, bytes)
# 
# def to_unix_ts(start_time):
#     """Given a datetime object, returns its value as a unix timestamp"""
#     if isinstance(start_time, datetime):
#         if is_timezone_aware(start_time):
#             start_time = start_time.astimezone(pytz.utc)
#         else:
#             log.warning(
#                 "Non timezone-aware datetime object passed to IncrementalEndpoint. "
#                 "The Zendesk API expects UTC time, if this is not the case results will be incorrect!"
#             )
#         unix_time = calendar.timegm(start_time.timetuple())
#     else:
#         unix_time = start_time
# 
#     return int(unix_time)


# Path: zenpy/lib/endpoint.py
import logging
from datetime import date
from datetime import datetime
from requests.utils import quote
from zenpy.lib.exception import ZenpyException
from zenpy.lib.util import is_iterable_but_not_string, to_unix_ts
    from urllib import urlencode
    from urlparse import urlunsplit, SplitResult
    from urllib.parse import urlencode
    from urllib.parse import urlunsplit, SplitResult

    +-----------------+------------------+
    | \*_before       | < (time|date)    |
    +-----------------+------------------+
    | minus           | \- (negation)    |
    +-----------------+------------------+
    | \*_between      | > < (dates only) |
    +-----------------+------------------+

    For example the call:

    .. code:: python

      zenpy.search("zenpy", created_between=[yesterday, today], type='ticket', minus='negated')

    Would generate the following API call:
    ::
        /api/v2/search.json?query=zenpy+created>2015-08-29 created<2015-08-30+type:ticket+-negated


    """
    def __call__(self, query=None, **kwargs):

        renamed_kwargs = dict()
        modifiers = list()
        params = dict()
        for key, value in kwargs.items():
            if isinstance(value, datetime):
                kwargs[key] = value.strftime(self.ISO_8601_FORMAT)
            elif isinstance(value, date):
                kwargs[key] = value.strftime(self.ZENDESK_DATE_FORMAT)

            elif is_iterable_but_not_string(value) and key == 'ids':