# Path: cartographer/exceptions/request_exceptions.py
# class DataMissing(ParameterMissing):
#     parameter_name = 'data'
# 
# class BadPageCountParameter(ParameterInvalid):
#     def __init__(self, parameter_value):
#         super().__init__(parameter_name='page[count]',
#                          parameter_value=parameter_value)
#         self.error_description = "Page sizes must be integers."
# 
# class BadPageCursorParameter(ParameterInvalid):
#     def __init__(self, parameter_value):
#         super().__init__(parameter_name='page[cursor]',
#                          parameter_value=parameter_value)
#         self.error_description = "Provided cursor was not parsable."
# 
# class BadPageOffsetParameter(ParameterInvalid):
#     def __init__(self, parameter_value):
#         super().__init__(parameter_name='page[offset]',
#                          parameter_value=parameter_value)
#         self.error_description = "Page offsets must be integers."
# 
# Path: cartographer/requests/jsonapi_request_interface.py
# class JSONAPIRequestInterface(object):
#     _metaclass__ = ABCMeta
# 
#     @abstractmethod
#     def get_json_api_version(self):
#         return
# 
#     @abstractmethod
#     def get_json(self, force=False):
#         return
# 
#     @abstractmethod
#     def get_includes(self):
#         return
# 
#     @abstractmethod
#     def get_requested_fields(self):
#         return
# 
# Path: cartographer/utils/version.py
# class JSONAPIVersion(Enum):
#     JSONAPI_RC2 = "1.0RC2"
#     JSONAPI_RC3 = "1.0RC3"
#     JSONAPI_1_0 = "1.0"
# 
# def get_default_version():
#     return _JSONAPI_DEFAULT_VERSION


import json
import re
from cartographer.exceptions.request_exceptions import DataMissing, BadPageCountParameter, BadPageCursorParameter, \
    BadPageOffsetParameter
from cartographer.requests.jsonapi_request_interface import JSONAPIRequestInterface
from cartographer.utils.version import JSONAPIVersion, get_default_version
    def get_sort(self):
        return self.args.get('sort')

    def get_pagination(self, page_count_default=10, cursor_formatter=None):
        per_page = self.args.get('page[count]')
        if per_page is not None:
            if per_page != 'infinity':
                try:
                    per_page = int(per_page)
                except TypeError:
                    raise BadPageCountParameter(per_page)
        else:
            per_page = page_count_default

        page_cursor = self.args.get('page[cursor]')
        if page_cursor is not None and cursor_formatter is not None:
            try:
                page_cursor = cursor_formatter(page_cursor)
            except:
                raise BadPageCursorParameter(page_cursor)

        page_offset = self.args.get('page[offset]')
        if page_offset is not None:
            try:
                page_offset = int(page_offset)
            except TypeError:
                raise BadPageOffsetParameter(page_offset)

        return page_cursor, page_offset, per_page


# Path: cartographer/exceptions/request_exceptions.py
# class DataMissing(ParameterMissing):
#     parameter_name = 'data'
# 
# class BadPageCountParameter(ParameterInvalid):
#     def __init__(self, parameter_value):
#         super().__init__(parameter_name='page[count]',
#                          parameter_value=parameter_value)
#         self.error_description = "Page sizes must be integers."
# 
# class BadPageCursorParameter(ParameterInvalid):
#     def __init__(self, parameter_value):
#         super().__init__(parameter_name='page[cursor]',
#                          parameter_value=parameter_value)
#         self.error_description = "Provided cursor was not parsable."
# 
# class BadPageOffsetParameter(ParameterInvalid):
#     def __init__(self, parameter_value):
#         super().__init__(parameter_name='page[offset]',
#                          parameter_value=parameter_value)
#         self.error_description = "Page offsets must be integers."
# 
# Path: cartographer/requests/jsonapi_request_interface.py
# class JSONAPIRequestInterface(object):
#     _metaclass__ = ABCMeta
# 
#     @abstractmethod
#     def get_json_api_version(self):
#         return
# 
#     @abstractmethod
#     def get_json(self, force=False):
#         return
# 
#     @abstractmethod
#     def get_includes(self):
#         return
# 
#     @abstractmethod
#     def get_requested_fields(self):
#         return
# 
# Path: cartographer/utils/version.py
# class JSONAPIVersion(Enum):
#     JSONAPI_RC2 = "1.0RC2"
#     JSONAPI_RC3 = "1.0RC3"
#     JSONAPI_1_0 = "1.0"
# 
# def get_default_version():
#     return _JSONAPI_DEFAULT_VERSION


# Path: cartographer/requests/jsonapi_flask_request_mixin.py
import json
import re
from cartographer.exceptions.request_exceptions import DataMissing, BadPageCountParameter, BadPageCursorParameter, \
    BadPageOffsetParameter
from cartographer.requests.jsonapi_request_interface import JSONAPIRequestInterface
from cartographer.utils.version import JSONAPIVersion, get_default_version

    def get_sort(self):
        return self.args.get('sort')

    def get_pagination(self, page_count_default=10, cursor_formatter=None):
        per_page = self.args.get('page[count]')
        if per_page is not None:
            if per_page != 'infinity':
                try:
                    per_page = int(per_page)
                except TypeError:
                    raise BadPageCountParameter(per_page)
        else:
            per_page = page_count_default

        page_cursor = self.args.get('page[cursor]')
        if page_cursor is not None and cursor_formatter is not None:
            try:
                page_cursor = cursor_formatter(page_cursor)
            except:
                raise BadPageCursorParameter(page_cursor)

        page_offset = self.args.get('page[offset]')
        if page_offset is not None:
            try:
                page_offset = int(page_offset)
            except TypeError:
                raise BadPageOffsetParameter(page_offset)

        return page_cursor, page_offset, per_page


    def get_includes(self):