piwik-ruby-api icon indicating copy to clipboard operation
piwik-ruby-api copied to clipboard

Responses should follow the principle of least astonishment

Open Ravenstine opened this issue 11 years ago • 0 comments

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.

Ravenstine avatar Sep 04 '14 15:09 Ravenstine