msukmanowsky/ROmniture — pull request #6 by RobGoretsky (2013-05-02 21:42:47+00:00)
Title: Add flatten_response capabilities to make working with the Omniture API Responses Easier

One of the more time-consuming parts of working with Omniture's API has been working with the hierarchical, deeply-nested responses that the API provides for Trended reports. For example, if you request a report with two elements (say, 'browser' and 'page') plus the date, Omniture returns a tree-like response that may first have the browser, then all of the pages broken down underneath that, and then all of the dates broken down underneath that.

This commit contains something I have found to be very helpful - it basically flattens/denormalizes the response so you always end up with just a simple array of hashes. So for the example above you'd end up with something like the following:

```
[
{browser: "Google Chrome 25.0", page: "Home Page", datetime: "Fri. 1 Mar. 2013", visits: 2000},
{browser: "Internet Explorer 10", page: "Home Page", datetime: "Fri. 1 Mar. 2013", visits: 1442},
... etc...
```

To invoke this flattening capability, just call it like this:
```ruby
resp = @client.get_report "Report.QueueOvertime", @request
flattened = @client.flatten_response(resp)
```

I have included a set of Unit Tests for this functionality as well that confirm that it works with Trended reports for 1 or 2 elements, and for Overtime reports (with 0 elements)