def create(self, api_request):

        new_uuid = str(uuid.uuid4())
        request = self.validate_request(api_request)
        data = request['where']

        if data is None:
            api_ex = ApiException(MessagesEnum.CREATE_ERROR)
            api_ex.set_params(data)
            raise api_ex

        try:
            result = self._repository.create(new_uuid, data)

            if result is None:
                api_ex = ApiException(MessagesEnum.CREATE_ERROR)
                api_ex.set_params(data)
                raise api_ex

        except Exception as err:
            self.logger.error(err)
            if data is None:
                api_ex = ApiException(MessagesEnum.CREATE_ERROR)
                raise api_ex

        return data
    def delete(self, api_request, record_uuid):
        if not record_uuid:
            api_ex = ApiException(MessagesEnum.PARAM_REQUIRED_ERROR)
            api_ex.set_params('uuid')
            raise api_ex

        # valida a request, validando os campos
        request = self.validate_request(api_request)

        result = self._repository.delete(record_uuid)

        if result is not True:
            api_ex = ApiException(MessagesEnum.DELETE_ERROR)
            api_ex.set_params(uuid)
            raise api_ex

        return result
    def get(self, api_request, record_uuid):
        if not record_uuid:
            api_ex = ApiException(MessagesEnum.PARAM_REQUIRED_ERROR)
            api_ex.set_params('uuid')
            raise api_ex

        # valida a request, validando os campos
        request = self.validate_request(api_request)

        data = self._repository.get(record_uuid, request['fields'])

        if data is None:
            api_ex = ApiException(MessagesEnum.FIND_ERROR)
            api_ex.set_params(record_uuid)
            raise api_ex

        return data
    def update(self, api_request, record_uuid):
        if not record_uuid:
            api_ex = ApiException(MessagesEnum.PARAM_REQUIRED_ERROR)
            api_ex.set_params('uuid')
            raise api_ex

        # valida a request, validando os campos
        request = self.validate_request(api_request)
        data = request['where']

        data = self._repository.update(record_uuid, data)

        if data is None:
            api_ex = ApiException(MessagesEnum.UPDATE_ERROR)
            api_ex.set_params(uuid)
            raise api_ex

        return data