asin 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +17 -55
- data/README.md +86 -72
- data/asin.gemspec +1 -1
- data/lib/asin/adapter.rb +2 -2
- data/lib/asin/client.rb +2 -2
- data/lib/asin/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d24c856333d2ff7d131765947bd4d4abe8f1451
|
4
|
+
data.tar.gz: 2aa29f96ed6ec63316f37bfc8af91b4da330a498
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0ba427f9ae87eecbba63fc1ce18c783e246b0796fb2b4e73e1d173636c059f5ce569f82b7635937d24f867ce2cf9fdb25a3e8007aec6f43f694ee1fd7f7aa9b
|
7
|
+
data.tar.gz: 2df98bbd2428438fdd2c5179bd700de5aff4d98d7e3a15ab8746db2b7e0266d3e8142fb0ba493890a74ab6703c4387c4139c133b4aec4c0ec56757eb720c823a
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,77 +1,36 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
asin (2.0.
|
4
|
+
asin (2.0.2)
|
5
5
|
confiture (>= 0.1)
|
6
6
|
crack (>= 0.3)
|
7
7
|
hashie (>= 1.1)
|
8
8
|
httpi (>= 0.9)
|
9
|
-
|
9
|
+
snake_case_hash (>= 1.0.2)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: http://rubygems.org/
|
13
13
|
specs:
|
14
14
|
addressable (2.3.2)
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
byebug (3.5.1)
|
16
|
+
columnize (~> 0.8)
|
17
|
+
debugger-linecache (~> 1.2)
|
18
|
+
slop (~> 3.6)
|
18
19
|
codeclimate-test-reporter (0.3.0)
|
19
20
|
simplecov (>= 0.7.1, < 1.0.0)
|
20
|
-
|
21
|
-
columnize (0.3.6)
|
21
|
+
columnize (0.8.9)
|
22
22
|
confiture (0.1.4)
|
23
23
|
crack (0.3.1)
|
24
|
-
debug_inspector (0.0.2)
|
25
|
-
debugger (1.6.6)
|
26
|
-
columnize (>= 0.3.1)
|
27
|
-
debugger-linecache (~> 1.2.0)
|
28
|
-
debugger-ruby_core_source (~> 1.3.2)
|
29
24
|
debugger-linecache (1.2.0)
|
30
|
-
debugger-ruby_core_source (1.3.2)
|
31
25
|
diff-lcs (1.2.5)
|
32
26
|
docile (1.1.3)
|
33
|
-
hashie (
|
27
|
+
hashie (3.4.3)
|
34
28
|
httpclient (2.3.0.1)
|
35
|
-
httpi (2.1
|
29
|
+
httpi (2.4.1)
|
36
30
|
rack
|
37
|
-
rubyntlm (~> 0.3.2)
|
38
|
-
interception (0.5)
|
39
|
-
jist (1.5.1)
|
40
|
-
json
|
41
|
-
json (1.8.1)
|
42
|
-
method_source (0.8.2)
|
43
31
|
multi_json (1.10.0)
|
44
|
-
|
45
|
-
coderay (~> 1.0)
|
46
|
-
method_source (~> 0.8)
|
47
|
-
slop (~> 3.4)
|
48
|
-
pry-debugger (0.2.2)
|
49
|
-
debugger (~> 1.3)
|
50
|
-
pry (~> 0.9.10)
|
51
|
-
pry-doc (0.6.0)
|
52
|
-
pry (~> 0.9)
|
53
|
-
yard (~> 0.8)
|
54
|
-
pry-docmore (0.1.1)
|
55
|
-
pry
|
56
|
-
pry-doc
|
57
|
-
pry-plus (1.0.0)
|
58
|
-
bond
|
59
|
-
jist
|
60
|
-
pry-debugger
|
61
|
-
pry-doc
|
62
|
-
pry-docmore
|
63
|
-
pry-rescue
|
64
|
-
pry-stack_explorer
|
65
|
-
pry-rescue (1.4.0)
|
66
|
-
interception (>= 0.4)
|
67
|
-
pry
|
68
|
-
pry-stack_explorer (0.4.9.1)
|
69
|
-
binding_of_caller (>= 0.7)
|
70
|
-
pry (>= 0.9.11)
|
71
|
-
rack (1.5.2)
|
32
|
+
rack (1.6.4)
|
72
33
|
rake (0.9.2.2)
|
73
|
-
rash (0.4.0)
|
74
|
-
hashie (~> 2.0.0)
|
75
34
|
rspec (2.14.1)
|
76
35
|
rspec-core (~> 2.14.0)
|
77
36
|
rspec-expectations (~> 2.14.0)
|
@@ -80,18 +39,18 @@ GEM
|
|
80
39
|
rspec-expectations (2.14.5)
|
81
40
|
diff-lcs (>= 1.1.3, < 2.0)
|
82
41
|
rspec-mocks (2.14.6)
|
83
|
-
rubyntlm (0.3.4)
|
84
42
|
simplecov (0.8.2)
|
85
43
|
docile (~> 1.1.0)
|
86
44
|
multi_json
|
87
45
|
simplecov-html (~> 0.8.0)
|
88
46
|
simplecov-html (0.8.0)
|
89
|
-
slop (3.
|
47
|
+
slop (3.6.0)
|
48
|
+
snake_case_hash (1.0.2)
|
49
|
+
hashie (~> 3.0)
|
90
50
|
vcr (2.2.5)
|
91
51
|
webmock (1.8.11)
|
92
52
|
addressable (>= 2.2.7)
|
93
53
|
crack (>= 0.1.7)
|
94
|
-
yard (0.8.7.3)
|
95
54
|
|
96
55
|
PLATFORMS
|
97
56
|
java
|
@@ -99,10 +58,13 @@ PLATFORMS
|
|
99
58
|
|
100
59
|
DEPENDENCIES
|
101
60
|
asin!
|
61
|
+
byebug
|
102
62
|
codeclimate-test-reporter
|
103
63
|
httpclient (>= 2.2.3)
|
104
|
-
pry-plus
|
105
64
|
rake (~> 0.9.2)
|
106
65
|
rspec (~> 2.11)
|
107
66
|
vcr (~> 2.2)
|
108
67
|
webmock (~> 1.8)
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.11.2
|
data/README.md
CHANGED
@@ -20,108 +20,121 @@ Version 2 removes all the SimpleXXX classes in favor of [Hashie::Rash](https://g
|
|
20
20
|
|
21
21
|
The old API is available if you require `ASIN::Adapter`:
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
```ruby
|
24
|
+
require 'asin'
|
25
|
+
require 'asin/adapter'
|
26
|
+
```
|
25
27
|
|
26
28
|
It's also a good starting point for looking into writing your own asin-adapter.
|
27
29
|
|
28
30
|
|
29
31
|
## Installation
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
+
```bash
|
34
|
+
gem install asin
|
35
|
+
gem install curb # optional, see HTTPI
|
36
|
+
```
|
33
37
|
|
34
38
|
or in your Gemfile:
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
```ruby
|
41
|
+
gem 'asin'
|
42
|
+
gem 'curb' # optional, see HTTPI
|
43
|
+
```
|
39
44
|
|
40
45
|
## Configuration
|
41
46
|
|
42
47
|
Rails style initializer (`config/initializers/asin.rb`):
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
+
```ruby
|
50
|
+
ASIN::Configuration.configure do |config|
|
51
|
+
config.secret = 'your-secret'
|
52
|
+
config.key = 'your-key'
|
53
|
+
config.associate_tag = 'your-tag'
|
54
|
+
end
|
55
|
+
```
|
49
56
|
|
50
57
|
Have a look at `ASIN::Configuration` class for all the details.
|
51
58
|
|
52
|
-
|
53
59
|
## Usage
|
54
60
|
|
55
61
|
ASIN is designed as a module, so you can include it into any object you like:
|
56
62
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
# lookup an ASIN
|
62
|
-
lookup '1430218150'
|
63
|
+
```ruby
|
64
|
+
# require and include
|
65
|
+
require 'asin'
|
66
|
+
include ASIN::Client
|
63
67
|
|
64
|
-
|
65
|
-
|
68
|
+
# lookup an ASIN
|
69
|
+
lookup '1430218150'
|
70
|
+
|
71
|
+
# lookup multiple items by ASIN
|
72
|
+
lookup ['1430218150','1934356549']
|
73
|
+
```
|
66
74
|
|
67
75
|
But you can also use the *instance* method to get a proxy-object:
|
68
76
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
77
|
+
```ruby
|
78
|
+
# just require
|
79
|
+
require 'asin'
|
80
|
+
|
81
|
+
# create an ASIN client
|
82
|
+
client = ASIN::Client.instance
|
83
|
+
|
84
|
+
# lookup an item with the amazon standard identification number (asin)
|
85
|
+
items = client.lookup '1430218150'
|
86
|
+
|
87
|
+
# have a look at the title of the item
|
88
|
+
items.first.item_attributes.title
|
89
|
+
=> Learn Objective-C on the Mac (Learn Series)
|
90
|
+
|
91
|
+
# search for any kind of stuff on amazon with keywords
|
92
|
+
items = search_keywords 'Learn', 'Objective-C'
|
93
|
+
items.first.item_attributes.title
|
94
|
+
=> "Learn Objective-C on the Mac (Learn Series)"
|
95
|
+
|
96
|
+
# search for any kind of stuff on amazon with custom parameters
|
97
|
+
search :Keywords => 'Learn Objective-C', :SearchIndex => :Books
|
98
|
+
items.first.item_attributes.title
|
99
|
+
=> "Learn Objective-C on the Mac (Learn Series)"
|
100
|
+
|
101
|
+
# search for similar items like the one you already have
|
102
|
+
items = client.similar '1430218150'
|
103
|
+
```
|
94
104
|
|
95
105
|
There is an additional set of methods to support AWS cart operations:
|
96
106
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
107
|
+
```ruby
|
108
|
+
client = ASIN::Client.instance
|
109
|
+
|
110
|
+
# create a cart with an item
|
111
|
+
cart = client.create_cart({:asin => '1430218150', :quantity => 1})
|
112
|
+
cart.cart_items.cart_item
|
113
|
+
=> [<#Hashie::Rash ASIN="1430218150" CartItemId="U3G241HVLLB8N6" ... >]
|
114
|
+
|
115
|
+
# clear everything from the cart
|
116
|
+
cart = client.clear_cart(cart)
|
117
|
+
cart.cart_items.cart_item
|
118
|
+
=> []
|
119
|
+
|
120
|
+
# update items in the cart
|
121
|
+
cart = client.update_items(cart, {:cart_item_id => cart.items.first.CartItemId, :action => :SaveForLater}, {:cart_item_id => cart.items.first.CartItemId, :quantity => 7})
|
122
|
+
cart.saved_for_later_items.saved_for_later_item
|
123
|
+
=> [<#Hashie::Rash ASIN="1430218150" CartItemId="U3G241HVLLB8N6" ... >]
|
124
|
+
```
|
113
125
|
|
114
126
|
It's also possible to access browse nodes:
|
115
127
|
|
116
|
-
|
117
|
-
|
118
|
-
# create a cart with an item
|
119
|
-
node = client.browse_node('17', :ResponseGroup => :TopSellers)
|
120
|
-
node.first.browse_node_id
|
121
|
-
=> '163357'
|
122
|
-
node.first.name
|
123
|
-
=> 'Literature & Fiction'
|
128
|
+
```ruby
|
129
|
+
client = ASIN::Client.instance
|
124
130
|
|
131
|
+
# create a cart with an item
|
132
|
+
node = client.browse_node('17', :ResponseGroup => :TopSellers)
|
133
|
+
node.first.browse_node_id
|
134
|
+
=> '163357'
|
135
|
+
node.first.name
|
136
|
+
=> 'Literature & Fiction'
|
137
|
+
```
|
125
138
|
|
126
139
|
## HTTPI
|
127
140
|
|
@@ -129,8 +142,9 @@ ASIN uses [HTTPI](https://github.com/rubiii/httpi) as a HTTP-Client adapter.
|
|
129
142
|
See the HTTPI documentation for how to configure different clients or the logger.
|
130
143
|
As a default HTTPI uses _httpclient_ so you should add that dependency to your project:
|
131
144
|
|
132
|
-
|
133
|
-
|
145
|
+
```ruby
|
146
|
+
gem 'httpclient'
|
147
|
+
```
|
134
148
|
|
135
149
|
## Confiture
|
136
150
|
|
data/asin.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_dependency('crack', '>= 0.3')
|
21
21
|
s.add_dependency('hashie', '>= 1.1')
|
22
|
-
s.add_dependency('
|
22
|
+
s.add_dependency('snake_case_hash', '>= 1.0.2')
|
23
23
|
s.add_dependency('httpi', '>= 0.9')
|
24
24
|
s.add_dependency('confiture', '>= 0.1')
|
25
25
|
|
data/lib/asin/adapter.rb
CHANGED
data/lib/asin/client.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rexml/document' # https://github.com/phoet/asin/pull/23
|
|
3
3
|
require 'crack/xml'
|
4
4
|
require 'cgi'
|
5
5
|
require 'base64'
|
6
|
-
require '
|
6
|
+
require 'sc_hash'
|
7
7
|
|
8
8
|
module ASIN
|
9
9
|
module Client
|
@@ -216,7 +216,7 @@ module ASIN
|
|
216
216
|
end
|
217
217
|
|
218
218
|
def handle_type(data, type)
|
219
|
-
Hashie::
|
219
|
+
Hashie::SCHash.new(data)
|
220
220
|
end
|
221
221
|
|
222
222
|
def create_item_params(items)
|
data/lib/asin/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Schröder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: crack
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: snake_case_hash
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.0.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.0.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: httpi
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
220
|
version: '0'
|
221
221
|
requirements: []
|
222
222
|
rubyforge_project: asin
|
223
|
-
rubygems_version: 2.
|
223
|
+
rubygems_version: 2.5.1
|
224
224
|
signing_key:
|
225
225
|
specification_version: 4
|
226
226
|
summary: Amazon Simple INterface - Support for ItemLookup, SimilarityLookup, Search,
|
@@ -253,4 +253,3 @@ test_files:
|
|
253
253
|
- spec/lib/search_spec.rb
|
254
254
|
- spec/lib/similarity_spec.rb
|
255
255
|
- spec/spec_helper.rb
|
256
|
-
has_rdoc:
|