jugend / amazon-ecs

Amazon Product Advertising Ruby API
MIT License
554 stars 95 forks source link

Make the options setter append the options instead of replacing them #41

Closed ferdynton closed 9 years ago

ferdynton commented 9 years ago

Might fix issue #26 and issue #39

Certain Amazon Product APIs such as es, it or cn require that the options include

:service => "AWSECommerceService"

in the query. These options are set by default on Amazon::Ec2.options, but configuring the gem like

Amazon::Ecs.options = {
  :associate_tag => '[your associate tag]',
  :AWS_access_key_id => '[your developer token]',       
  :AWS_secret_key => '[your secret access key]'
}

overrides them. With this fix, the options now are merged with the ones previously set. Another maybe cleaner way to go would be to separate the defaults into a separate variable and manually merge them before each request.

jugend commented 9 years ago

This would cause some ambiguity, the options setter was meant to overwrite, you could use .configure to update add/update the existing options. Amazon::Ecs.configure do |options| options['key'] = 'value' end

ferdynton commented 9 years ago

You probably want to clarify that in the README. There are issues claiming that the gem does not work and it's because of this. You probably want to notify that there are certain mandatory parameters that your code is adding to the request under the hood, and that using the options will overwrite them. I do understand your comment, but I do because I read the code, not because the documentation is clear on that matter.

omederos commented 9 years ago

Yes, it definitely should be on the README.

I was getting a response from Amazon saying that version 2005-10-05 was unsupported, and pointing me to 2011-08-01.

When people look at the README, the first thing that appears is how to set the options by doing:

Amazon::Ecs.options = {
  ...
}

which overrides the version and service default values.

jugend commented 9 years ago

Thanks for the note guys, I'm updating the README.