# Path: mapmyfitness/exceptions.py
# class InvalidSearchArgumentsException(Exception):
#     """Invalid arguments were passed when searching."""
# 
# class InvalidObjectException(Exception):
#     """The object you attempted to create or update was invalid."""
# 
# Path: mapmyfitness/paginator.py
# class Paginator(object):
#     def __init__(self, initial_object_list, per_page, total_count,
#                  searchable, original_kwargs, orphans=0):
#         self.initial_object_list = initial_object_list
#         self.per_page = per_page
#         self.total_count = total_count
#         self.searchable = searchable
#         self.original_kwargs = original_kwargs
#         self.orphans = int(orphans)
#         self._num_pages = None
# 
#     def validate_number(self, number):
#         try:
#             number = int(number)
#         except (TypeError, ValueError):
#             raise PageNotAnInteger('That page number is not an integer')
#         if number < 1:
#             raise EmptyPage('That page number is less than 1')
#         if number > self.num_pages:
#             raise EmptyPage('That page contains no results')
#         return number
# 
#     def page(self, number):
#         number = self.validate_number(number)
#         bottom = (number - 1) * self.per_page
#         top = bottom + self.per_page
#         if top + self.orphans >= self.count:
#             top = self.count
#         if number == 1:
#             objects = self.initial_object_list
#         else:
#             params = copy.deepcopy(self.original_kwargs)
#             params.update({'offset': bottom, 'limit': self.per_page})
#             objects = self.searchable._search(params)
#         return self._get_page(objects, number, self)
# 
#     def _get_page(self, *args, **kwargs):
#             return Page(*args, **kwargs)
# 
#     def _get_count(self):
#         return self.total_count
#     count = property(_get_count)
# 
#     def _get_num_pages(self):
#         if self._num_pages is None:
#             hits = max(1, self.count - self.orphans)
#             self._num_pages = int(ceil(hits / float(self.per_page)))
#         return self._num_pages
#     num_pages = property(_get_num_pages)
# 
#     def _get_page_range(self):
#         return list(range(1, self.num_pages + 1))
#     page_range = property(_get_page_range)


import copy
from mapmyfitness.exceptions import InvalidSearchArgumentsException, InvalidObjectException
from mapmyfitness.paginator import Paginator
        # to the API to get the total count needed to process pages
        #
        initial_object_list = self._search(kwargs)
        return Paginator(initial_object_list, self.per_page, self.total_count, self, original_kwargs)


class Createable(object):
    def create(self, obj):
        self.validator = self.validator_class(create_obj=obj)
        if not self.validator.valid:
            raise InvalidObjectException(self.validator)

        inflator = self.inflator_class(obj)
        data = inflator.inflated

        params = None
        if self.__class__.__name__ == 'Route':
            # Routes are special, and need to be created with additional params
            params = {'field_set': 'detailed'}

        api_resp = self.call('post', '{0}/'.format(self.path), data=data, extra_headers={'Content-Type': 'application/json'}, params=params)

        serializer = self.serializer_class(api_resp)
        return serializer.serialized


class Updateable(object):
    def update(self, id, obj):
        self.validator = self.validator_class(obj)
        if not self.validator.valid:

# Path: mapmyfitness/exceptions.py
# class InvalidSearchArgumentsException(Exception):
#     """Invalid arguments were passed when searching."""
# 
# class InvalidObjectException(Exception):
#     """The object you attempted to create or update was invalid."""
# 
# Path: mapmyfitness/paginator.py
# class Paginator(object):
#     def __init__(self, initial_object_list, per_page, total_count,
#                  searchable, original_kwargs, orphans=0):
#         self.initial_object_list = initial_object_list
#         self.per_page = per_page
#         self.total_count = total_count
#         self.searchable = searchable
#         self.original_kwargs = original_kwargs
#         self.orphans = int(orphans)
#         self._num_pages = None
# 
#     def validate_number(self, number):
#         try:
#             number = int(number)
#         except (TypeError, ValueError):
#             raise PageNotAnInteger('That page number is not an integer')
#         if number < 1:
#             raise EmptyPage('That page number is less than 1')
#         if number > self.num_pages:
#             raise EmptyPage('That page contains no results')
#         return number
# 
#     def page(self, number):
#         number = self.validate_number(number)
#         bottom = (number - 1) * self.per_page
#         top = bottom + self.per_page
#         if top + self.orphans >= self.count:
#             top = self.count
#         if number == 1:
#             objects = self.initial_object_list
#         else:
#             params = copy.deepcopy(self.original_kwargs)
#             params.update({'offset': bottom, 'limit': self.per_page})
#             objects = self.searchable._search(params)
#         return self._get_page(objects, number, self)
# 
#     def _get_page(self, *args, **kwargs):
#             return Page(*args, **kwargs)
# 
#     def _get_count(self):
#         return self.total_count
#     count = property(_get_count)
# 
#     def _get_num_pages(self):
#         if self._num_pages is None:
#             hits = max(1, self.count - self.orphans)
#             self._num_pages = int(ceil(hits / float(self.per_page)))
#         return self._num_pages
#     num_pages = property(_get_num_pages)
# 
#     def _get_page_range(self):
#         return list(range(1, self.num_pages + 1))
#     page_range = property(_get_page_range)


# Path: mapmyfitness/api/mixins.py
import copy
from mapmyfitness.exceptions import InvalidSearchArgumentsException, InvalidObjectException
from mapmyfitness.paginator import Paginator

        # to the API to get the total count needed to process pages
        #
        initial_object_list = self._search(kwargs)
        return Paginator(initial_object_list, self.per_page, self.total_count, self, original_kwargs)


class Createable(object):
    def create(self, obj):
        self.validator = self.validator_class(create_obj=obj)
        if not self.validator.valid:
            raise InvalidObjectException(self.validator)

        inflator = self.inflator_class(obj)
        data = inflator.inflated

        params = None
        if self.__class__.__name__ == 'Route':
            # Routes are special, and need to be created with additional params
            params = {'field_set': 'detailed'}

        api_resp = self.call('post', '{0}/'.format(self.path), data=data, extra_headers={'Content-Type': 'application/json'}, params=params)

        serializer = self.serializer_class(api_resp)
        return serializer.serialized


class Updateable(object):
    def update(self, id, obj):
        self.validator = self.validator_class(obj)
        if not self.validator.valid:

            raise InvalidObjectException(self.validator)