import json
from utils.base import APIView, get_offset_count
from utils.logger import error_logger


class CategoryListView(APIView):

    def get(self, request):
        offset, count = get_offset_count(request)
        cn_name = request.GET.get('cn_name')

        data = self.rpc['neptune/commodity/category/list'](
            offset=offset, count=count, cn_name=cn_name).unwrap()

        for obj in data.get('list'):
            obj.pop('platform')
        return data
