reduce json rest client class into function + fix flake8 issues