awis-wrapper

This is the wrapper for AWIS service, this thought derive from Ishango2 project.

Usage

Amazon::Awis.options = {:aws_access_key_id => "123", :aws_secret_key => "456", :action => "UrlInfo", :responsegroup => "RankByCountry"}

  #Or with one block
  Amazon::Awis.configure do |options|
      # options[:aws_access_key_id] = [your access key]
      # options[:aws_secret_key] = [you secret key]
      options[:responsegroup] = 'Rank'
  end

  #Call get_info method to get single website info
  res = Amazon::Awis.get_info('yahoo.com')
  if res.success? 
    all_countries = res.get_all('country')
    all_countries.each do |c|
      c.contribution.first.users.first  #navigate into the children tree. the accociations always return Array, so note the 'first' method.
    end
  end
  
  #Or get multiple websites info with batch request
  res = Amazon::Awis.get_info(]'yahoo.com', 'cnn.com')
  if res.success?
    res.get_all('response') # get all repsonse items in the document, then you can iterate all the response data with each "aws:Response"
    element = res.get('response') # this would get only one(the first) item in the document
    element.get_all_child('country') # all "aws:Country" items searched from current element. return Element class.
    #or directly access
    element.operation_request.first.request_id # would convert to camel case automaticly
    # to access the attribute
    element['Code'] == "US"
  end

Contributing to awis-wrapper

Copyright © 2013 Vincent.Z. See LICENSE.txt for further details.