MOBILE-477 Add support for the Connection API

We also fix an issue of checking an undefined variable
Merge pull request #22 from moodlehq/MOBILE-477

MOBILE-477 Add support for the Connection API