phoet / asin

:books: :package: Amazon Simple INterface - Support for ItemLookup, SimilarityLookup, Search, BrowseNode and Cart Operations
http://asin.herokuapp.com/
167 stars 59 forks source link

different languages #40

Closed mattherick closed 10 years ago

mattherick commented 10 years ago

Hi!

Is it possible to change the language dynamically for the amazon results? I only get US-results at the moment and I also like to receive german results. How could I change your gem to provide this feature also? Any suggestions? Best regards.

Matthias

mattherick commented 10 years ago

Okay my fault.. it is possible to configure the host for getting different results depending on the language. For others:

ASIN::Configuration.configure do |config|
  config.secret        = Rails.application.secrets.amazon["secret_access_key"]
  config.key           = Rails.application.secrets.amazon["access_key_id"]
  config.associate_tag = Rails.application.secrets.amazon["associate_tag"]
  config.host          = "webservices.amazon.de"
end

This would return german results.

Do you have a list of all possible hosts? And maybe you can update your README - the optional host configuration is not mentioned anywhere.

jaimerump commented 10 years ago

@mattherick I've found a list, but I think it's incomplete because I think I remember there being an Indian endpoint that isn't listed there. http://docs.aws.amazon.com/AWSECommerceService/latest/DG/AnatomyOfaRESTRequest.html

jaimerump commented 10 years ago

Springboarding off of this, what if I want to change it dynamically at runtime? I have users from all across the world, and I'd like to serve up their country's version if there is one. Could I do something like this at runtime to change which site I query just for that specific user?

ASIN::Configuration.configure do |config|
  config.host          = "webservices.amazon.de"
end
kurtfunai commented 10 years ago

:+1:

phoet commented 10 years ago

@jaimerump @kurtfunai :heart: for helping!

confiture has a feature that allows you to set block-scoped configuration. it's also thread-safe:

ASIN::Configuration.with_config(host: "webservices.amazon.de") do
  client.lookup('B0096BYG7C').first.detail_page_url # http://www.amazon.de/Practical...
end