move connection logic into connection class

APIClient is now a module