Class: RECS4::Operation
- Inherits:
-
Object
- Object
- RECS4::Operation
- Defined in:
- lib/recs4/operation.rb
Overview
This class wraps the Amazon ECS4.0 API
Using REST request internally.
Example to use:
o = RECS4::Operation.new("Your AWSAccessKeyId", :locale => "jp")
# ItemLookup Operation
r = o.item_lookup("some asin", :response_group => "Large")
# Get element value
r[:items][:item][:asin].text #=> "some asin"
# Get attribute value
r[:items][:item][:item_attributes][:creator].a("Role") #=> "Artist"
# ItemSearch Operation
r = o.item_search("keywords")
# Get total pages
r[:items][:total_pages].text.to_i
# Get All items
r[:items][:item].each do |item|
item[:item_attributes][:artist].text
end
Instance Method Summary collapse
-
#browse_node_lookup(browse_node_id, options = {}) ⇒ Object
Available options: Look BROWSE_NODE_LOOKUP_PARAMS.
-
#cart_add ⇒ Object
Not implemented yet.
-
#cart_clear ⇒ Object
Not implemented yet.
-
#cart_get ⇒ Object
Not implemented yet.
-
#cart_modify ⇒ Object
Not implemented yet.
-
#customer_controller_lookup ⇒ Object
Not implemented yet.
-
#customer_controller_search ⇒ Object
Not implemented yet.
-
#help ⇒ Object
Not implemented yet.
-
#initialize(aws_access_key_id, options = {}) ⇒ Operation
constructor
Available options: Look RECS4::GLOBAL_PARAMS.
-
#item_lookup(item_id, options = {}) ⇒ Object
Available options: Look RECS4::ITEM_LOOKUP_PARAMS.
-
#item_search(keywords, options = {}) ⇒ Object
Available options: Look RECS4::ITEM_SEARCH_PARAMS.
-
#list_lookup ⇒ Object
Not implemented yet.
-
#list_search ⇒ Object
Not implemented yet.
-
#seller_listing_lookup ⇒ Object
Not implemented yet.
-
#seller_listing_search ⇒ Object
Not implemented yet.
-
#seller_lookup ⇒ Object
Not implemented yet.
-
#similarity_lookup ⇒ Object
Not implemented yet.
-
#transaction_lookup ⇒ Object
Not implemented yet.
Constructor Details
#initialize(aws_access_key_id, options = {}) ⇒ Operation
Available options: Look RECS4::GLOBAL_PARAMS
"Locale" parameter is required in ECS4.0 API. But :locale option can be skipped in RECS4. DEFAULT_LOCALE is used.
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/recs4/operation.rb', line 151 def initialize(aws_access_key_id, = {}) @aws_access_key_id = aws_access_key_id @options = {} GLOBAL_PARAMS.each_key do |key| @options[key] = [key] end unless @options.keys.include?(:locale) @options[:locale] = DEFAULT_LOCALE end @element_names = {} end |
Instance Method Details
#browse_node_lookup(browse_node_id, options = {}) ⇒ Object
Available options: Look BROWSE_NODE_LOOKUP_PARAMS
199 200 201 202 203 204 205 206 207 |
# File 'lib/recs4/operation.rb', line 199 def browse_node_lookup(browse_node_id, = {}) unless has_valid_browse_node_lookup_query(browse_node_id, ) return nil end url = browse_node_lookup_url(browse_node_id, ) response_xml = get_response(url) parsed_xml = REXML::Document.new(response_xml) return RECS4::XML::Element.new(parsed_xml.root) end |
#cart_add ⇒ Object
Not implemented yet
210 211 |
# File 'lib/recs4/operation.rb', line 210 def cart_add end |
#cart_clear ⇒ Object
Not implemented yet
213 214 |
# File 'lib/recs4/operation.rb', line 213 def cart_clear end |
#cart_get ⇒ Object
Not implemented yet
216 217 |
# File 'lib/recs4/operation.rb', line 216 def cart_get end |
#cart_modify ⇒ Object
Not implemented yet
219 220 |
# File 'lib/recs4/operation.rb', line 219 def cart_modify end |
#customer_controller_lookup ⇒ Object
Not implemented yet
222 223 |
# File 'lib/recs4/operation.rb', line 222 def customer_controller_lookup end |
#customer_controller_search ⇒ Object
Not implemented yet
225 226 |
# File 'lib/recs4/operation.rb', line 225 def customer_controller_search end |
#help ⇒ Object
Not implemented yet
228 229 |
# File 'lib/recs4/operation.rb', line 228 def help end |
#item_lookup(item_id, options = {}) ⇒ Object
Available options: Look RECS4::ITEM_LOOKUP_PARAMS
166 167 168 169 170 171 172 173 174 |
# File 'lib/recs4/operation.rb', line 166 def item_lookup(item_id, = {}) unless has_valid_item_lookup_query(item_id, ) return nil end url = item_lookup_url(item_id, ) response_xml = get_response(url) parsed_xml = REXML::Document.new(response_xml) return RECS4::XML::Element.new(parsed_xml.root) end |
#item_search(keywords, options = {}) ⇒ Object
Available options: Look RECS4::ITEM_SEARCH_PARAMS
"keywords" can be nil. If "keywords" is nil, other options for searching must not be nil. For example, :artist, :author, and so on.
183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/recs4/operation.rb', line 183 def item_search(keywords, = {}) unless [:search_index] [:search_index] = "Blended" end unless has_valid_item_search_query(keywords, ) return nil end url = item_search_url(keywords, ) response_xml = get_response(url) parsed_xml = REXML::Document.new(response_xml) return RECS4::XML::Element.new(parsed_xml.root) end |
#list_lookup ⇒ Object
Not implemented yet
231 232 |
# File 'lib/recs4/operation.rb', line 231 def list_lookup end |
#list_search ⇒ Object
Not implemented yet
234 235 |
# File 'lib/recs4/operation.rb', line 234 def list_search end |
#seller_listing_lookup ⇒ Object
Not implemented yet
237 238 |
# File 'lib/recs4/operation.rb', line 237 def seller_listing_lookup end |
#seller_listing_search ⇒ Object
Not implemented yet
240 241 |
# File 'lib/recs4/operation.rb', line 240 def seller_listing_search end |
#seller_lookup ⇒ Object
Not implemented yet
243 244 |
# File 'lib/recs4/operation.rb', line 243 def seller_lookup end |
#similarity_lookup ⇒ Object
Not implemented yet
246 247 |
# File 'lib/recs4/operation.rb', line 246 def similarity_lookup end |
#transaction_lookup ⇒ Object
Not implemented yet
249 250 |
# File 'lib/recs4/operation.rb', line 249 def transaction_lookup end |