rebay 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rebay/finding.rb +1 -0
- data/lib/rebay/response.rb +10 -0
- data/rebay.gemspec +2 -2
- data/spec/finding_spec.rb +16 -6
- data/spec/response_spec.rb +7 -3
- data/spec/shopping_spec.rb +6 -6
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
data/lib/rebay/finding.rb
CHANGED
@@ -8,6 +8,7 @@ module Rebay
|
|
8
8
|
raise ArgumentError unless params[:keywords] or params[:categoryId]
|
9
9
|
response = get_json_response(build_request_url('findItemsAdvanced', params))
|
10
10
|
response.trim(:findItemsAdvancedResponse)
|
11
|
+
|
11
12
|
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
12
13
|
response.results = response.response['searchResult']['item']
|
13
14
|
end
|
data/lib/rebay/response.rb
CHANGED
@@ -31,6 +31,16 @@ module Rebay
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
def size
|
35
|
+
if @results.nil?
|
36
|
+
return 0
|
37
|
+
elsif @results.class == Array
|
38
|
+
return @results.size
|
39
|
+
else
|
40
|
+
return 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
34
44
|
protected
|
35
45
|
def transform_json_response(response)
|
36
46
|
if response.class == Hash
|
data/rebay.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rebay}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Chuck Collins"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-06}
|
13
13
|
s.email = %q{chuck.collins@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
data/spec/finding_spec.rb
CHANGED
@@ -63,7 +63,7 @@ module Rebay
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should iterate over results" do
|
66
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced
|
66
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced"))
|
67
67
|
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
68
68
|
response = @finder.find_items_advanced({:keywords => 'whatevs'})
|
69
69
|
|
@@ -71,6 +71,16 @@ module Rebay
|
|
71
71
|
response.each { |r| count = count + 1 }
|
72
72
|
count.should eq(2)
|
73
73
|
end
|
74
|
+
|
75
|
+
it "should work with 1 result" do
|
76
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced_one_item"))
|
77
|
+
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
78
|
+
response = @finder.find_items_advanced({:categoryId => 1})
|
79
|
+
count = 0
|
80
|
+
|
81
|
+
response.each { |r| count = count + 1 }
|
82
|
+
count.should eq(1)
|
83
|
+
end
|
74
84
|
end
|
75
85
|
|
76
86
|
context "when calling find_items_by_category" do
|
@@ -87,7 +97,7 @@ module Rebay
|
|
87
97
|
end
|
88
98
|
|
89
99
|
it "should iterate over results" do
|
90
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_category
|
100
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_category"))
|
91
101
|
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
92
102
|
response = @finder.find_items_by_category({:categoryId => 1})
|
93
103
|
|
@@ -111,7 +121,7 @@ module Rebay
|
|
111
121
|
end
|
112
122
|
|
113
123
|
it "should iterate over results" do
|
114
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_product
|
124
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_product"))
|
115
125
|
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
116
126
|
response = @finder.find_items_by_product({:productId => 1})
|
117
127
|
|
@@ -135,7 +145,7 @@ module Rebay
|
|
135
145
|
end
|
136
146
|
|
137
147
|
it "should iterate over results" do
|
138
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_keywords
|
148
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_keywords"))
|
139
149
|
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
140
150
|
response = @finder.find_items_by_keywords({:keywords => 'whatevs'})
|
141
151
|
|
@@ -191,7 +201,7 @@ module Rebay
|
|
191
201
|
end
|
192
202
|
|
193
203
|
it "should iterate over results" do
|
194
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation
|
204
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation"))
|
195
205
|
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
196
206
|
response = @finder.get_search_keywords_recommendation({:keywords => 'whatevs'})
|
197
207
|
|
@@ -213,7 +223,7 @@ module Rebay
|
|
213
223
|
end
|
214
224
|
|
215
225
|
it "should iterate over results" do
|
216
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_version
|
226
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_version"))
|
217
227
|
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
218
228
|
response = @finder.get_version
|
219
229
|
|
data/spec/response_spec.rb
CHANGED
@@ -4,14 +4,14 @@ module Rebay
|
|
4
4
|
describe Response do
|
5
5
|
context "on creation" do
|
6
6
|
it "should transform the happy json" do
|
7
|
-
json_happy = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation_happy
|
7
|
+
json_happy = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation_happy"))
|
8
8
|
response = Response.new(json_happy)
|
9
9
|
response.response.should eq({"getSearchKeywordsRecommendationResponse" => {"ack" => "Success", "version" => "1.5.0",
|
10
10
|
"timestamp" => "2010-08-13T21:11:02.539Z", "keywords" => "accordion"}})
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should transform the sad json" do
|
14
|
-
json_sad = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation_sad
|
14
|
+
json_sad = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation_sad"))
|
15
15
|
response = Response.new(json_sad)
|
16
16
|
response.response.should eq({"getSearchKeywordsRecommendationResponse" =>
|
17
17
|
{"ack" => "Warning",
|
@@ -68,7 +68,7 @@ module Rebay
|
|
68
68
|
|
69
69
|
context "using find items advanced json" do
|
70
70
|
before(:each) do
|
71
|
-
@json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced
|
71
|
+
@json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced"))
|
72
72
|
@response = Response.new(@json)
|
73
73
|
@response.trim(:findItemsAdvancedResponse)
|
74
74
|
@proper = {"ack"=>"Success", "version"=>"1.7.0", "timestamp"=>"2010-09-29T01:53:58.039Z",
|
@@ -111,6 +111,10 @@ module Rebay
|
|
111
111
|
it "should trim format response correctly" do
|
112
112
|
@response.response.should eq(@proper)
|
113
113
|
end
|
114
|
+
|
115
|
+
it "should show correct size" do
|
116
|
+
@response.size.should eq(2)
|
117
|
+
end
|
114
118
|
end
|
115
119
|
end
|
116
120
|
end
|
data/spec/shopping_spec.rb
CHANGED
@@ -79,7 +79,7 @@ module Rebay
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should iterate over results" do
|
82
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/get_category_info
|
82
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/get_category_info"))
|
83
83
|
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
84
84
|
response = @shopper.get_category_info({:categoryId => 1})
|
85
85
|
|
@@ -103,7 +103,7 @@ module Rebay
|
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should iterate over results" do
|
106
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_products
|
106
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_products"))
|
107
107
|
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
108
108
|
response = @shopper.find_products({:queryKeywords => 'whatevs'})
|
109
109
|
|
@@ -127,7 +127,7 @@ module Rebay
|
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should iterate over results" do
|
130
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_half_products
|
130
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_half_products"))
|
131
131
|
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
132
132
|
response = @shopper.find_half_products({:queryKeywords => 'whatevs'})
|
133
133
|
|
@@ -221,7 +221,7 @@ module Rebay
|
|
221
221
|
end
|
222
222
|
|
223
223
|
it "should iterate over results" do
|
224
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_popular_searches
|
224
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_popular_searches"))
|
225
225
|
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
226
226
|
response = @shopper.find_popular_searches({:categoryId => 1})
|
227
227
|
|
@@ -241,7 +241,7 @@ module Rebay
|
|
241
241
|
end
|
242
242
|
|
243
243
|
it "should iterate over results" do
|
244
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_popular_items
|
244
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_popular_items"))
|
245
245
|
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
246
246
|
response = @shopper.find_popular_items({:categoryId => 1})
|
247
247
|
|
@@ -261,7 +261,7 @@ module Rebay
|
|
261
261
|
end
|
262
262
|
|
263
263
|
it "should iterate over results" do
|
264
|
-
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_reviews_and_guides
|
264
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_reviews_and_guides"))
|
265
265
|
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
266
266
|
response = @shopper.find_reviews_and_guides
|
267
267
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 2
|
9
|
+
version: 1.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Chuck Collins
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-06 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|