piwik-ruby-api
piwik-ruby-api copied to clipboard
Responses should follow the principle of least astonishment
For example, Piwik::Referers.getKeywords will normally return an array of hashes if the site has multiple keywords.
However, if the site is new and has a single keyword, won't return a hash but instead a single hash. Instead, that same hash should be returned inside an array to reduce the extra code necessary.
If a site has no keywords, the response is a single hash: {"nb_visits" => 0}
This is not only unnecessary, but it is yet again another case that require extra code to be written.
Instead, an empty array should be the result.