implement the rest client methods

TODO: remove duplication