Commit 5b1a2483
Changed files (2)
app
controllers
admin
services
infrastructure
app/controllers/admin/tools_controller.rb
@@ -1,15 +1,7 @@
module Admin
class ToolsController < AdminController
def index
- @tools = search_for_tools(params[:q])
- end
-
- private
-
- def search_for_tools(query)
- return [] if query.blank?
- client = ASIN::Client.instance
- client.search(Keywords: query, SearchIndex: :Kitchen, Sort: :salesrank)
+ @tools = AmazonAPI.new.search(params[:q])
end
end
end
app/services/infrastructure/amazon_api.rb
@@ -0,0 +1,12 @@
+class AmazonAPI
+ attr_reader :client
+
+ def initialize(client = ASIN::Client.instance)
+ @client = client
+ end
+
+ def search(query)
+ return [] if query.blank?
+ client.search(Keywords: query, SearchIndex: :Kitchen, Sort: :salesrank)
+ end
+end