Added 'environment' parameter to API calls

Baker will set the parameter as follows:
- 'debug' when the DEBUG preprocessor directive is set to 1
- 'production' otherwise

Closes #1017, closes #1005.