Move API calls to own function

In preparation for switch to Admin SDK API, move all API calls to their
own functions. This will make it easier to code
the API change without changing program logic.

This is related to trevore/galias#4