[requires api-rebuild] Refactor apirequest.js

While studying the apirequest.js code, I frequently found myself jumping up and down the code to see where a variable is declared and what it holds etc. and some parts were not very clear what they are supposed to do. So I decided to do a little bit of cleanup in hopes that it will help me as well as other devs to better understand the code and make it more readable and maintainable.

I could not help but add a single big commit. Below is the summary of changes.

- reduce the amount of `var` declarations as much as possible
- for readability, replace `for` loops with `Array.prototype.forEach` where suitable (I know that `forEach` is less performant than `for` loop but we will be mostly waiting for the remote endpoint to respond, and compared to that, the performace hit is negligible)
- add more comments to better describe what a particular code block is supposed to do
- When required params are missing from an API call, list them all at once in the Error message
- define `pathParams` and `requiredParams` on API methods even if there are none (reduces clutter by not needing to check for their presence first in apirequest)

I am open for further discussion or improvements. Let me know if there is anything you would like to change.

Tests are passing after regenerating the clients, `npm run lint`-free.