Beautify the parsing of API response using Hashie Rash
- Full example: https://gist.github.com/frankie-loves-jesus/89d24dd88579c7f912f3
 - Live demo: http://runnable.com/U9RltBIJZFsY9s0O/amazon-api-old-
 
raw_products = request.item_search(query: params)
hashed_products = raw_products.to_h
 
@products = []
  
hashed_products['ItemSearchResponse']['Items']['Item'].each do |item|
  product = OpenStruct.new
  product.name = item['ItemAttributes']['Title']
  product.url = item['DetailPageURL']
  product.image_url = item['LargeImage']['URL']
  
  @products << product 
end
- New live demo: http://runnable.com/U9R38bPFYjwD8plA/amazon-api-rash-
 
raw_products = request.item_search(query: params)
@products = Hashie::Rash.new(raw_products.to_h)
@products.item_search_response.items.item.each do |item|
  product = OpenStruct.new
  product.name = item['item_attributes']['title']
  product.url = item['detail_page_url']
  product.image_url = item['large_image']['url']
  
  @products << product 
end
undefined