Commit 29f02cb8 by Tan Phat Nguyen

delete amazon controller

parent c8a1c53e
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
// Place all the styles related to the Amazon controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
class AmazonController < ApplicationController
def welcome
req = Vacuum.new
req.configure(
aws_access_key_id: 'AKIAI4FGZR4YFCAP4DVQ',
aws_secret_access_key: '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',
associate_tag: 'tag'
)
rg = %w(ItemAttributes Images).join(',')
@res = req.item_lookup(query: { 'IdType' => 'ASIN', 'VariationPage' => 1,
'SearchIndex' => 'Books', 'ResponseGroup' => rg} )
end
def index
req = Vacuum.new
req.configure(
aws_access_key_id: 'AKIAI4FGZR4YFCAP4DVQ',
aws_secret_access_key: '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',
associate_tag: 'tag'
)
req.associate_tag = 'foobar'
# Amazon now only paginates to page 5.
params = {
'SearchIndex' => 'All',
'Keywords' => 'Books',
'ItemPage' => 5
}
#@res = req.item_search(query: params)
#@res = req.item_lookup(query: { 'IdType' => 'ASIN', 'ItemId' => '0679753354'})
# ItemAttributes Images AlternateVersions Offers
rg = %w(ItemAttributes Images EditorialReview).join(',')
@res = req.item_search(query: {
'ItemSearch.Shared.SearchIndex' => 'All',
'ItemSearch.Shared.Keywords' => '*',
'ItemSearch.Shared.ResponseGroup' => rg,
'ItemSearch.SearchIndex' => 'Books',
'ItemSearch.1.ItemPage' => 1,
'ItemSearch.2.ItemPage' => 2
})
@result = @res.to_h["ItemSearchResponse"].to_h["Items"].to_a[0].to_h["Item"].to_a[1].to_h
@add_new = []
@res.to_h["ItemSearchResponse"].to_h["Items"].to_a[0].to_h["Item"].to_a.each do |value|
book_tmp = value.to_h
@add_new.push(details: book_tmp['DetailPageURL'], image: book_tmp['LargeImage'], item: book_tmp['ItemAttributes'], editor: book_tmp['EditorialReviews'])
end
@ret = []
@result.each {|k, v| @ret.push(k)}
end
end
<h1>Amazon#index</h1>
<p>Find me in app/views/amazon/index.html.erb</p>
<h2>Count: <%= @result.length %></h2>
<h2>Add_new: <%= @add_new.length %></h2>
<%= @ret %> <br>
<h2>Item 0: </h2>
<%= @add_new %>
\ No newline at end of file
<h1>Amazon#welcome</h1>
<p>Find me in app/views/amazon/welcome.html.erb</p>
......@@ -13,7 +13,8 @@ default: &default
socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: demo_dev
# database: demo_dev
database: amazon_dev
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
......
require 'test_helper'
class AmazonControllerTest < ActionController::TestCase
test "should get welcome" do
get :welcome
assert_response :success
end
test "should get index" do
get :index
assert_response :success
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment