amazon-ruby 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,11 +8,9 @@ require "amazon-ruby/client"
8
8
 
9
9
  module AmazonRuby
10
10
 
11
- class << self
12
- #Alias for AmazonRuby::Client.new
13
- def new(country, amazon_key, amazon_secret, amazon_associate_tag)
14
- AmazonRuby::Client.new(country, amazon_key, amazon_secret, amazon_associate_tag);
15
- end
11
+ #Alias for AmazonRuby::Client.new
12
+ def self.new(country, amazon_key, amazon_secret, amazon_associate_tag)
13
+ AmazonRuby::Client.new(country, amazon_key, amazon_secret, amazon_associate_tag)
16
14
  end
17
15
 
18
16
  end
@@ -12,8 +12,8 @@ module AmazonRuby
12
12
  API_SERVICE = 'AWSECommerceService'
13
13
 
14
14
  def initialize(country, amazon_key, amazon_secret, amazon_associate_tag)
15
- @locale = Locale.new(country);
16
- @amazon_key = amazon_key
15
+ @locale = Locale.new(country);
16
+ @amazon_key = amazon_key
17
17
  @amazon_secret = amazon_secret
18
18
  @amazon_associate_tag = amazon_associate_tag
19
19
  end
@@ -96,10 +96,6 @@ module AmazonRuby
96
96
 
97
97
  #Perform request
98
98
  def get(request_params)
99
- raise KeyNotFound unless @amazon_key
100
- raise TagNotFound unless @amazon_associate_tag
101
- raise SecretNotFound unless @amazon_secret
102
-
103
99
  #Do request
104
100
  response = Net::HTTP.get_response(url(request_params))
105
101
  Response.new(response)
@@ -112,19 +108,19 @@ module AmazonRuby
112
108
  hmac = OpenSSL::HMAC.digest(digest, @amazon_secret, url_string)
113
109
  signature = escape([hmac].pack('m').chomp)
114
110
 
115
- "#{unsigned_query}&Signature=#{signature}"
111
+ "#{unsigned_query}&Signature=#{signature}"
116
112
  end
117
113
 
118
114
  # The Amazon URL.
119
115
  def url(request_params)
120
116
  combined_params = base_params.merge(request_params)
121
- query_string = combined_params.sort.map { |k, v| "#{k}=" + escape(v) }.join('&')
117
+ query_string = combined_params.sort.map {|key, value| "#{key}=" + escape(value)}.join('&')
122
118
 
123
119
  URI::HTTP.build(
124
120
  :host => @locale.host,
125
121
  :path => '/onca/xml',
126
122
  :query => sign(query_string))
127
- end
123
+ end
128
124
 
129
125
  #Escape value
130
126
  def escape(value)
@@ -1,22 +1,9 @@
1
1
  module AmazonRuby
2
2
 
3
- #Amazon key not found
4
- class KeyNotFound < ArgumentError; end
5
-
6
- #Amazon secret not found
7
- class SecretNotFound < ArgumentError; end
8
-
9
- #Amazon tag not found
10
- class TagNotFound < ArgumentError; end
11
-
12
- #Unsupported Country
13
- class UnsupportedCountry < ArgumentError; end
14
-
15
- #Invalid HTTP Client
16
- class InvalidHttpClient < ArgumentError; end
17
-
18
- #Unsupported Feature
19
- class UnsupportedFeature < ArgumentError; end
3
+ #Unsupported Country
4
+ class UnsupportedCountry < StandardError; end
20
5
 
6
+ #Unsupported Feature
7
+ class UnsupportedFeature < StandardError; end
21
8
 
22
9
  end
@@ -4,7 +4,7 @@ module AmazonRuby
4
4
  class Locale
5
5
 
6
6
  #Country hosts
7
- HOSTS = {
7
+ HOSTS = {
8
8
  'ca' => 'ecs.amazonaws.ca',
9
9
  'cn' => 'webservices.amazon.cn',
10
10
  'de' => 'ecs.amazonaws.de',
@@ -13,7 +13,7 @@ module AmazonRuby
13
13
  'jp' => 'ecs.amazonaws.jp',
14
14
  'us' => 'ecs.amazonaws.com',
15
15
  'uk' => 'ecs.amazonaws.co.uk'
16
- }
16
+ }
17
17
 
18
18
  #Set country on initialization, raise InvalidLocale if not found
19
19
  def initialize(country)
@@ -22,12 +22,12 @@ module AmazonRuby
22
22
  @country = country
23
23
  end
24
24
 
25
- #Host
25
+ #Host
26
26
  def host
27
27
  @host
28
28
  end
29
29
 
30
- #Country
30
+ #Country
31
31
  def country
32
32
  @country
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module AmazonRuby
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-14 00:00:00.000000000Z
12
+ date: 2011-12-15 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70205913570620 !ruby/object:Gem::Requirement
16
+ requirement: &70224015942460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '1.4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70205913570620
24
+ version_requirements: *70224015942460
25
25
  description: A Ruby wrapper for the Amazon Advertising API
26
26
  email:
27
27
  - rhoppes@zappos.com