Skip to content

Add flatten_response capabilities to make working with the Omniture API Responses Easier#6

Open
RobGoretsky wants to merge 4 commits into
msukmanowsky:masterfrom
RobGoretsky:flatten_response
Open

Add flatten_response capabilities to make working with the Omniture API Responses Easier#6
RobGoretsky wants to merge 4 commits into
msukmanowsky:masterfrom
RobGoretsky:flatten_response

Conversation

@RobGoretsky
Copy link
Copy Markdown
Contributor

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:

 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)

@msukmanowsky
Copy link
Copy Markdown
Owner

Will try to review these changes in the next week or so @RobGoretsky, thanks for the contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants