# Path: rakuten_ws/utils.py
# def camelize(string, uppercase_first_letter=True):
#     """
#     Convert strings to CamelCase.
# 
#     From inflection package: https://github.com/jpvanhal/inflection
# 
#     Examples::
# 
#     >>> camelize("device_type")
#     'DeviceType'
#     >>> camelize("device_type", False)
#     'deviceType'
#     """
#     if not string.islower():
#         return string
#     if uppercase_first_letter:
#         return re.sub(r"(?:^|_)(.)", lambda m: m.group(1).upper(), string)
#     else:
#         return string[0].lower() + camelize(string)[1:]
# 
# def camelize_dict(data, uppercase_first_letter=False):
#     """ Returns a dict with camel case keys.
# 
#     >>> d = {'a_simple_key': '1', 'Another_key': '2', 'CamelKey': '3'}
#     >>> sorted(camelize_dict(d).keys())
#     ['Another_key', 'CamelKey', 'aSimpleKey']
#     >>> camelize_dict(d)['aSimpleKey']
#     '1'
#     """
#     new_dict = data.__class__()
#     for k, v in iteritems(data):
#         new_v = v
#         if isinstance(v, dict):
#             new_v = camelize_dict(v, uppercase_first_letter)
#         elif isinstance(v, list):
#             new_v = list()
#             for x in v:
#                 if isinstance(x, dict):
#                     new_v.append(camelize_dict(x, uppercase_first_letter))
#                 else:
#                     camelize(k, uppercase_first_letter)
#         new_dict[camelize(k, uppercase_first_letter)] = new_v
#     return new_dict
# 
# def sorted_dict(d, key=None):
#     """ Sort dict by keys.
# 
#     Examples::
# 
#     >>> sorted_dict({'3': 3, '1': 10})
#     OrderedDict([('1', 10), ('3', 3)])
#     >>> sorted_dict({'1': 10, '3': 3})
#     OrderedDict([('1', 10), ('3', 3)])
#     """
#     new_dict = OrderedDict()
#     for k, v in sorted(iteritems(d), key=key):
#         new_v = v
#         if isinstance(v, dict):
#             new_v = sorted_dict(v)
#         elif isinstance(v, list):
#             new_v = list()
#             for x in v:
#                 if isinstance(x, dict):
#                     new_v.append(sorted_dict(x))
#                 else:
#                     new_v.append(x)
#         new_dict[k] = new_v
#     return new_dict
# 
# def clean_python_variable_name(s):
#     """ Convert a string to a valid python variable name.
# 
#     Examples::
# 
#     >>> clean_python_variable_name("    ")
#     '____'
#     >>> clean_python_variable_name("my 2@'(")
#     'my_2___'
#     >>> clean_python_variable_name("my superS@---variable")
#     'my_superS____variable'
#     """
#     return re.sub('\W|^(?=\d)', '_', s)
# 
# class PrettyStringRepr(str):
#     # Useful for debug
#     def __repr__(self):
#         if is_py2:
#             return to_unicode(self.replace(' \n', '\n').strip()).encode('utf-8')
#         else:
#             return to_unicode(self.replace(' \n', '\n').strip())
# 
# Path: rakuten_ws/compat.py
#     def iteritems(d):
#     def is_bytes(x):
#     def callable(obj):
#     def iteritems(d):
#     def is_bytes(x):
# def to_unicode(obj, encoding='utf-8'):


import json
import requests
from furl import furl
from .utils import (camelize, camelize_dict, sorted_dict, clean_python_variable_name, PrettyStringRepr)
from .compat import UserDict
        }
        if 'page' in kwargs:
            request_params.update(page=kwargs['page'])

        request_params.update(camelize_dict(kwargs))
        api_request.add(sorted_dict(request_params))
        return api_request.url

    def __call__(self, *args, **kwargs):
        url = self.build_url(*args, **kwargs)
        session = self.endpoint.service.webservice.session
        return ApiResponse(session, url)


class ApiEndpoint(object):
    api_version = None

    def __init__(self, *methods, **kwargs):
        self.service = None
        self.name = kwargs.get('name', None)
        self.api_endpoint = kwargs.get('api_endpoint', None)

        for method in methods:
            method_name = clean_python_variable_name(method.name)
            setattr(self, method_name, ApiRequest(self, method))

    def __get__(self, service, cls):
        if service is not None:
            self.service = service
            if getattr(self, 'api_endpoint', None) is None:

# Path: rakuten_ws/utils.py
# def camelize(string, uppercase_first_letter=True):
#     """
#     Convert strings to CamelCase.
# 
#     From inflection package: https://github.com/jpvanhal/inflection
# 
#     Examples::
# 
#     >>> camelize("device_type")
#     'DeviceType'
#     >>> camelize("device_type", False)
#     'deviceType'
#     """
#     if not string.islower():
#         return string
#     if uppercase_first_letter:
#         return re.sub(r"(?:^|_)(.)", lambda m: m.group(1).upper(), string)
#     else:
#         return string[0].lower() + camelize(string)[1:]
# 
# def camelize_dict(data, uppercase_first_letter=False):
#     """ Returns a dict with camel case keys.
# 
#     >>> d = {'a_simple_key': '1', 'Another_key': '2', 'CamelKey': '3'}
#     >>> sorted(camelize_dict(d).keys())
#     ['Another_key', 'CamelKey', 'aSimpleKey']
#     >>> camelize_dict(d)['aSimpleKey']
#     '1'
#     """
#     new_dict = data.__class__()
#     for k, v in iteritems(data):
#         new_v = v
#         if isinstance(v, dict):
#             new_v = camelize_dict(v, uppercase_first_letter)
#         elif isinstance(v, list):
#             new_v = list()
#             for x in v:
#                 if isinstance(x, dict):
#                     new_v.append(camelize_dict(x, uppercase_first_letter))
#                 else:
#                     camelize(k, uppercase_first_letter)
#         new_dict[camelize(k, uppercase_first_letter)] = new_v
#     return new_dict
# 
# def sorted_dict(d, key=None):
#     """ Sort dict by keys.
# 
#     Examples::
# 
#     >>> sorted_dict({'3': 3, '1': 10})
#     OrderedDict([('1', 10), ('3', 3)])
#     >>> sorted_dict({'1': 10, '3': 3})
#     OrderedDict([('1', 10), ('3', 3)])
#     """
#     new_dict = OrderedDict()
#     for k, v in sorted(iteritems(d), key=key):
#         new_v = v
#         if isinstance(v, dict):
#             new_v = sorted_dict(v)
#         elif isinstance(v, list):
#             new_v = list()
#             for x in v:
#                 if isinstance(x, dict):
#                     new_v.append(sorted_dict(x))
#                 else:
#                     new_v.append(x)
#         new_dict[k] = new_v
#     return new_dict
# 
# def clean_python_variable_name(s):
#     """ Convert a string to a valid python variable name.
# 
#     Examples::
# 
#     >>> clean_python_variable_name("    ")
#     '____'
#     >>> clean_python_variable_name("my 2@'(")
#     'my_2___'
#     >>> clean_python_variable_name("my superS@---variable")
#     'my_superS____variable'
#     """
#     return re.sub('\W|^(?=\d)', '_', s)
# 
# class PrettyStringRepr(str):
#     # Useful for debug
#     def __repr__(self):
#         if is_py2:
#             return to_unicode(self.replace(' \n', '\n').strip()).encode('utf-8')
#         else:
#             return to_unicode(self.replace(' \n', '\n').strip())
# 
# Path: rakuten_ws/compat.py
#     def iteritems(d):
#     def is_bytes(x):
#     def callable(obj):
#     def iteritems(d):
#     def is_bytes(x):
# def to_unicode(obj, encoding='utf-8'):


# Path: rakuten_ws/baseapi.py
import json
import requests
from furl import furl
from .utils import (camelize, camelize_dict, sorted_dict, clean_python_variable_name, PrettyStringRepr)
from .compat import UserDict

        }
        if 'page' in kwargs:
            request_params.update(page=kwargs['page'])

        request_params.update(camelize_dict(kwargs))
        api_request.add(sorted_dict(request_params))
        return api_request.url

    def __call__(self, *args, **kwargs):
        url = self.build_url(*args, **kwargs)
        session = self.endpoint.service.webservice.session
        return ApiResponse(session, url)


class ApiEndpoint(object):
    api_version = None

    def __init__(self, *methods, **kwargs):
        self.service = None
        self.name = kwargs.get('name', None)
        self.api_endpoint = kwargs.get('api_endpoint', None)

        for method in methods:
            method_name = clean_python_variable_name(method.name)
            setattr(self, method_name, ApiRequest(self, method))

    def __get__(self, service, cls):
        if service is not None:
            self.service = service
            if getattr(self, 'api_endpoint', None) is None:

                self.api_endpoint = camelize("%s_%s" % (self.service.name, self.name))