# 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
        return {key: val.split(',') for key, val in type_to_list.items()}

    def get_included(self):
        """Returns a list of the included resources sent from the client"""
        sent_json = self.get_jsonapi_json()
        if not sent_json:
            raise DataMissing()

        return sent_json.get('included', [])

    def get_included_with_filter(self, type_, id_=None):
        included = self.get_included()
        return [
            resource
            for resource in included
            if resource.get('type') == type_ and (id_ is None or id_ == resource.get('id'))
        ]

    def get_filters(self):
        return self.dictionary_from_get('filter')

    def get_bool(self, key):
        val = self.args.get(key)
        if val is None:
            return None
        return bool(str(val).lower() not in ['false', '0'])

    def get_json_api_version(self, default_version=None):
        if default_version is None:
            default_version = get_default_version()

# 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

        return {key: val.split(',') for key, val in type_to_list.items()}

    def get_included(self):
        """Returns a list of the included resources sent from the client"""
        sent_json = self.get_jsonapi_json()
        if not sent_json:
            raise DataMissing()

        return sent_json.get('included', [])

    def get_included_with_filter(self, type_, id_=None):
        included = self.get_included()
        return [
            resource
            for resource in included
            if resource.get('type') == type_ and (id_ is None or id_ == resource.get('id'))
        ]

    def get_filters(self):
        return self.dictionary_from_get('filter')

    def get_bool(self, key):
        val = self.args.get(key)
        if val is None:
            return None
        return bool(str(val).lower() not in ['false', '0'])

    def get_json_api_version(self, default_version=None):
        if default_version is None:
            default_version = get_default_version()

        return JSONAPIVersion(self.args.get('json-api-version', default_version))