split code into library and cli
parse status code, headers and body
add error handler