rebay 1.0.2 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/config.rb +3 -0
- data/lib/rebay/finding.rb +23 -0
- data/lib/rebay/response.rb +23 -4
- data/lib/rebay/shopping.rb +54 -12
- data/rebay.gemspec +4 -3
- data/spec/finding_spec.rb +64 -0
- data/spec/response_spec.rb +65 -0
- data/spec/shopping_spec.rb +60 -0
- metadata +5 -8
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.1
|
data/config.rb
ADDED
data/lib/rebay/finding.rb
CHANGED
@@ -8,6 +8,9 @@ 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
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
12
|
+
response.results = response.response['searchResult']['item']
|
13
|
+
end
|
11
14
|
return response
|
12
15
|
end
|
13
16
|
|
@@ -16,6 +19,9 @@ module Rebay
|
|
16
19
|
raise ArgumentError unless params[:categoryId]
|
17
20
|
response = get_json_response(build_request_url('findItemsByCategory', params))
|
18
21
|
response.trim(:findItemsByCategoryResponse)
|
22
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
23
|
+
response.results = response.response['searchResult']['item']
|
24
|
+
end
|
19
25
|
return response
|
20
26
|
end
|
21
27
|
|
@@ -24,6 +30,9 @@ module Rebay
|
|
24
30
|
raise ArgumentError unless params[:keywords]
|
25
31
|
response = get_json_response(build_request_url('findItemsByKeywords', params))
|
26
32
|
response.trim(:findItemsByKeywordsResponse)
|
33
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
34
|
+
response.results = response.response['searchResult']['item']
|
35
|
+
end
|
27
36
|
return response
|
28
37
|
end
|
29
38
|
|
@@ -33,6 +42,9 @@ module Rebay
|
|
33
42
|
params['productId.@type'] = 'ReferenceID'
|
34
43
|
response = get_json_response(build_request_url('findItemsByProduct', params))
|
35
44
|
response.trim(:findItemsByProductResponse)
|
45
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
46
|
+
response.results = response.response['searchResult']['item']
|
47
|
+
end
|
36
48
|
return response
|
37
49
|
end
|
38
50
|
|
@@ -41,6 +53,9 @@ module Rebay
|
|
41
53
|
raise ArgumentError unless params[:keywords] or params[:storeName]
|
42
54
|
response = get_json_response(build_request_url('findItemsIneBayStores', params))
|
43
55
|
response.trim(:findItemsIneBayStoresResponse)
|
56
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
57
|
+
response.results = response.response['searchResult']['item']
|
58
|
+
end
|
44
59
|
return response
|
45
60
|
end
|
46
61
|
|
@@ -57,12 +72,20 @@ module Rebay
|
|
57
72
|
raise ArgumentError unless params[:keywords]
|
58
73
|
response = get_json_response(build_request_url('getSearchKeywordsRecommendation', params))
|
59
74
|
response.trim(:getSearchKeywordsRecommendationResponse)
|
75
|
+
if response.response.has_key?('keywords')
|
76
|
+
response.results = response.response['keywords']
|
77
|
+
end
|
60
78
|
return response
|
61
79
|
end
|
62
80
|
|
63
81
|
#http://developer.ebay.com/DevZone/finding/CallRef/getVersion.html
|
64
82
|
def get_version
|
65
83
|
response = get_json_response(build_request_url('getVersion'))
|
84
|
+
response.trim(:getVersionResponse)
|
85
|
+
if response.response.has_key?('version')
|
86
|
+
response.results = response.response['version']
|
87
|
+
end
|
88
|
+
return response
|
66
89
|
end
|
67
90
|
|
68
91
|
private
|
data/lib/rebay/response.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Rebay
|
2
2
|
class Response
|
3
3
|
attr_accessor :response
|
4
|
+
attr_accessor :results
|
4
5
|
|
5
6
|
def initialize(json_response)
|
6
7
|
@response = transform_json_response(json_response)
|
@@ -15,8 +16,18 @@ module Rebay
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def trim(key)
|
18
|
-
if @response.has_key?(key)
|
19
|
-
@response = @response[key]
|
19
|
+
if @response.has_key?(key.to_s)
|
20
|
+
@response = @response[key.to_s]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def each
|
25
|
+
unless @results.nil?
|
26
|
+
if @results.class == Array
|
27
|
+
@results.each { |r| yield r }
|
28
|
+
else
|
29
|
+
yield @results
|
30
|
+
end
|
20
31
|
end
|
21
32
|
end
|
22
33
|
|
@@ -28,8 +39,16 @@ module Rebay
|
|
28
39
|
r[k] = transform_json_response(response[k])
|
29
40
|
end
|
30
41
|
return r
|
31
|
-
elsif response.class == Array
|
32
|
-
|
42
|
+
elsif response.class == Array
|
43
|
+
if response.size == 1
|
44
|
+
return transform_json_response(response[0])
|
45
|
+
else
|
46
|
+
r = Array.new
|
47
|
+
response.each do |a|
|
48
|
+
r.push(transform_json_response(a))
|
49
|
+
end
|
50
|
+
return r
|
51
|
+
end
|
33
52
|
else
|
34
53
|
return response
|
35
54
|
end
|
data/lib/rebay/shopping.rb
CHANGED
@@ -6,71 +6,113 @@ module Rebay
|
|
6
6
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindProducts.html
|
7
7
|
def find_products(params)
|
8
8
|
raise ArgumentError unless params[:categoryId] or params[:productId] or params[:queryKeywords]
|
9
|
-
get_json_response(build_request_url('FindProducts', params))
|
9
|
+
response = get_json_response(build_request_url('FindProducts', params))
|
10
|
+
if response.response.has_key?('Product')
|
11
|
+
response.results = response.response['Product']
|
12
|
+
end
|
13
|
+
return response
|
10
14
|
end
|
11
15
|
|
12
16
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindHalfProducts.html
|
13
17
|
def find_half_products(params)
|
14
18
|
raise ArgumentError unless params[:productId] or params[:queryKeywords]
|
15
|
-
get_json_response(build_request_url('FindHalfProducts', params))
|
19
|
+
response = get_json_response(build_request_url('FindHalfProducts', params))
|
20
|
+
if response.response.has_key?('Products') && response.response['Products'].has_key?('Product')
|
21
|
+
response.results = response.response['Products']['Product']
|
22
|
+
end
|
23
|
+
return response
|
16
24
|
end
|
17
25
|
|
18
26
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetSingleItem.html
|
19
27
|
def get_single_item(params)
|
20
28
|
raise ArgumentError unless params[:itemId]
|
21
|
-
get_json_response(build_request_url('GetSingleItem', params))
|
29
|
+
response = get_json_response(build_request_url('GetSingleItem', params))
|
30
|
+
if response.response.has_key?('Item')
|
31
|
+
response.results = response.response['Item']
|
32
|
+
end
|
33
|
+
return response
|
22
34
|
end
|
23
35
|
|
24
36
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetItemStatus.html
|
25
37
|
def get_item_status(params)
|
26
38
|
raise ArgumentError unless params[:itemId]
|
27
|
-
get_json_response(build_request_url('GetItemStatus', params))
|
39
|
+
response = get_json_response(build_request_url('GetItemStatus', params))
|
40
|
+
if response.response.has_key?('Item')
|
41
|
+
response.results = response.response['Item']
|
42
|
+
end
|
43
|
+
return response
|
28
44
|
end
|
29
45
|
|
30
46
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetShippingCosts.html
|
31
47
|
def get_shipping_costs(params)
|
32
48
|
raise ArgumentError unless params[:itemId]
|
33
|
-
get_json_response(build_request_url('GetShippingCosts', params))
|
49
|
+
response = get_json_response(build_request_url('GetShippingCosts', params))
|
50
|
+
return response
|
34
51
|
end
|
35
52
|
|
36
53
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetMultipleItems.html
|
37
54
|
def get_multiple_items(params)
|
38
55
|
raise ArgumentError unless params[:itemId]
|
39
|
-
get_json_response(build_request_url('GetMultipleItems', params))
|
56
|
+
response = get_json_response(build_request_url('GetMultipleItems', params))
|
57
|
+
if response.response.has_key?('Item')
|
58
|
+
response.results = response.response['Item']
|
59
|
+
end
|
60
|
+
return response
|
40
61
|
end
|
41
62
|
|
42
63
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetUserProfile.html
|
43
64
|
def get_user_profile(params)
|
44
65
|
raise ArgumentError unless params[:userId]
|
45
|
-
get_json_response(build_request_url('GetUserProfile', params))
|
66
|
+
response = get_json_response(build_request_url('GetUserProfile', params))
|
67
|
+
if response.response.has_key?('User')
|
68
|
+
response.results = response.response['User']
|
69
|
+
end
|
70
|
+
return response
|
46
71
|
end
|
47
72
|
|
48
73
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindPopularSearches.html
|
49
74
|
def find_popular_searches(params)
|
50
75
|
raise ArgumentError unless params[:categoryId]
|
51
|
-
get_json_response(build_request_url('FindPopularSearches', params))
|
76
|
+
response = get_json_response(build_request_url('FindPopularSearches', params))
|
77
|
+
if response.response.has_key?('PopularSearchResult')
|
78
|
+
response.results = response.response['PopularSearchResult']
|
79
|
+
end
|
80
|
+
return response
|
52
81
|
end
|
53
82
|
|
54
83
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindPopularItems.html
|
55
84
|
def find_popular_items(params={})
|
56
85
|
raise ArgumentError unless params[:categoryId] or params[:queryKeywords]
|
57
|
-
get_json_response(build_request_url('FindPopularItems', params))
|
86
|
+
response = get_json_response(build_request_url('FindPopularItems', params))
|
87
|
+
if response.response.has_key?('ItemArray') && response.response['ItemArray'].has_key?('Item')
|
88
|
+
response.results = response.response['ItemArray']['Item']
|
89
|
+
end
|
90
|
+
return response
|
58
91
|
end
|
59
92
|
|
60
93
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindReviewsandGuides.html
|
61
94
|
def find_reviews_and_guides(params={})
|
62
|
-
get_json_response(build_request_url('FindReviewsAndGuides', params))
|
95
|
+
response = get_json_response(build_request_url('FindReviewsAndGuides', params))
|
96
|
+
if response.response.has_key?('BuyingGuideDetails') && response.response['BuyingGuideDetails'].has_key?('BuyingGuide')
|
97
|
+
response.results = response.response['BuyingGuideDetails']['BuyingGuide']
|
98
|
+
end
|
99
|
+
return response
|
63
100
|
end
|
64
101
|
|
65
102
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetCategoryInfo.html
|
66
103
|
def get_category_info(params)
|
67
104
|
raise ArgumentError unless params[:categoryId]
|
68
|
-
get_json_response(build_request_url('GetCategoryInfo', params))
|
105
|
+
response = get_json_response(build_request_url('GetCategoryInfo', params))
|
106
|
+
if response.response.has_key?('CategoryArray') && response.response['CategoryArray'].has_key?('Category')
|
107
|
+
response.results = response.response['CategoryArray']['Category']
|
108
|
+
end
|
109
|
+
return response
|
69
110
|
end
|
70
111
|
|
71
112
|
def get_category_info_with_children(params)
|
72
113
|
params[:IncludeSelector] = 'ChildCategories'
|
73
|
-
get_category_info(params)
|
114
|
+
response = get_category_info(params)
|
115
|
+
return response
|
74
116
|
end
|
75
117
|
|
76
118
|
private
|
data/rebay.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rebay}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.1.1"
|
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-10-05}
|
13
13
|
s.email = %q{chuck.collins@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
"README.md",
|
21
21
|
"Rakefile",
|
22
22
|
"VERSION",
|
23
|
+
"config.rb",
|
23
24
|
"init.rb",
|
24
25
|
"lib/rebay.rb",
|
25
26
|
"lib/rebay/api.rb",
|
data/spec/finding_spec.rb
CHANGED
@@ -61,6 +61,16 @@ module Rebay
|
|
61
61
|
it "should succeed" do
|
62
62
|
@finder.find_items_advanced({:keywords => 'feist'}).success?.should be_true
|
63
63
|
end
|
64
|
+
|
65
|
+
it "should iterate over results" do
|
66
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced.json"))
|
67
|
+
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
68
|
+
response = @finder.find_items_advanced({:keywords => 'whatevs'})
|
69
|
+
|
70
|
+
count = 0
|
71
|
+
response.each { |r| count = count + 1 }
|
72
|
+
count.should eq(2)
|
73
|
+
end
|
64
74
|
end
|
65
75
|
|
66
76
|
context "when calling find_items_by_category" do
|
@@ -75,6 +85,16 @@ module Rebay
|
|
75
85
|
it "should succeed" do
|
76
86
|
@finder.find_items_by_category({:categoryId => 1}).success?.should be_true
|
77
87
|
end
|
88
|
+
|
89
|
+
it "should iterate over results" do
|
90
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_category.json"))
|
91
|
+
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
92
|
+
response = @finder.find_items_by_category({:categoryId => 1})
|
93
|
+
|
94
|
+
count = 0
|
95
|
+
response.each { |r| count = count + 1 }
|
96
|
+
count.should eq(2)
|
97
|
+
end
|
78
98
|
end
|
79
99
|
|
80
100
|
context "when calling find_items_by_product" do
|
@@ -89,6 +109,16 @@ module Rebay
|
|
89
109
|
it "should succeed" do
|
90
110
|
@finder.find_items_by_product({:productId => 53039031}).success?.should be_true
|
91
111
|
end
|
112
|
+
|
113
|
+
it "should iterate over results" do
|
114
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_product.json"))
|
115
|
+
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
116
|
+
response = @finder.find_items_by_product({:productId => 1})
|
117
|
+
|
118
|
+
count = 0
|
119
|
+
response.each { |r| count = count + 1 }
|
120
|
+
count.should eq(2)
|
121
|
+
end
|
92
122
|
end
|
93
123
|
|
94
124
|
context "when calling find_items_by_keywords" do
|
@@ -103,6 +133,16 @@ module Rebay
|
|
103
133
|
it "should succeed" do
|
104
134
|
@finder.find_items_by_keywords({:keywords => 'feist'}).success?.should be_true
|
105
135
|
end
|
136
|
+
|
137
|
+
it "should iterate over results" do
|
138
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_by_keywords.json"))
|
139
|
+
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
140
|
+
response = @finder.find_items_by_keywords({:keywords => 'whatevs'})
|
141
|
+
|
142
|
+
count = 0
|
143
|
+
response.each { |r| count = count + 1 }
|
144
|
+
count.should eq(2)
|
145
|
+
end
|
106
146
|
end
|
107
147
|
|
108
148
|
context "when calling find_items_in_ebay_stores" do
|
@@ -149,6 +189,18 @@ module Rebay
|
|
149
189
|
it "should succeed" do
|
150
190
|
@finder.get_search_keywords_recommendation({:keywords => 'feist'}).success?.should be_true
|
151
191
|
end
|
192
|
+
|
193
|
+
it "should iterate over results" do
|
194
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_search_keywords_recommendation.json"))
|
195
|
+
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
196
|
+
response = @finder.get_search_keywords_recommendation({:keywords => 'whatevs'})
|
197
|
+
|
198
|
+
count = 0
|
199
|
+
response.each { |r| count = count + 1 }
|
200
|
+
count.should eq(1)
|
201
|
+
|
202
|
+
response.results.should eq('harry potter phoenix')
|
203
|
+
end
|
152
204
|
end
|
153
205
|
|
154
206
|
context "when calling get_version" do
|
@@ -159,6 +211,18 @@ module Rebay
|
|
159
211
|
it "should succeed" do
|
160
212
|
@finder.get_version.success?.should be_true
|
161
213
|
end
|
214
|
+
|
215
|
+
it "should iterate over results" do
|
216
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/get_version.json"))
|
217
|
+
@finder.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
218
|
+
response = @finder.get_version
|
219
|
+
|
220
|
+
count = 0
|
221
|
+
response.each { |r| count = count + 1 }
|
222
|
+
count.should eq(1)
|
223
|
+
|
224
|
+
response.results.should eq('1.8.0')
|
225
|
+
end
|
162
226
|
end
|
163
227
|
end
|
164
228
|
end
|
data/spec/response_spec.rb
CHANGED
@@ -41,11 +41,76 @@ module Rebay
|
|
41
41
|
response.trim("test")
|
42
42
|
response.response.should eq("test")
|
43
43
|
end
|
44
|
+
|
45
|
+
it "should trim response with syn" do
|
46
|
+
response = Response.new({"Ack" => "Failure", "test" => "test"})
|
47
|
+
response.trim(:test)
|
48
|
+
response.response.should eq("test")
|
49
|
+
end
|
44
50
|
|
45
51
|
it "should not trim response" do
|
46
52
|
response = Response.new({"Ack" => "Failure", "test" => "test"})
|
47
53
|
response.trim(:nothing)
|
48
54
|
response.response.should eq({"Ack" => "Failure", "test" => "test"})
|
49
55
|
end
|
56
|
+
|
57
|
+
it "should set result key" do
|
58
|
+
response = Response.new({})
|
59
|
+
response.should respond_to(:results)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should provide empty iterator without a result key" do
|
63
|
+
response = Response.new({})
|
64
|
+
count = 0
|
65
|
+
response.each { |r| count = count + 1 }
|
66
|
+
count.should eq(0)
|
67
|
+
end
|
68
|
+
|
69
|
+
context "using find items advanced json" do
|
70
|
+
before(:each) do
|
71
|
+
@json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/finding/find_items_advanced.json"))
|
72
|
+
@response = Response.new(@json)
|
73
|
+
@response.trim(:findItemsAdvancedResponse)
|
74
|
+
@proper = {"ack"=>"Success", "version"=>"1.7.0", "timestamp"=>"2010-09-29T01:53:58.039Z",
|
75
|
+
"searchResult"=>{"@count"=>"2",
|
76
|
+
"item"=>[{"itemId"=>"300471157219","title"=>"Minas Tirith 1990 Tolkien fanzine journal LOTR Hobbit",
|
77
|
+
"globalId"=>"EBAY-US","primaryCategory"=>{"categoryId"=>"280","categoryName"=>"Magazine Back Issues"},
|
78
|
+
"secondaryCategory"=>{"categoryId"=>"29799","categoryName"=>"Other"},
|
79
|
+
"galleryURL"=>"http:\/\/thumbs4.ebaystatic.com\/pict\/3004711572198080_1.jpg",
|
80
|
+
"viewItemURL"=>"http:\/\/cgi.ebay.com\/Minas-Tirith-1990-Tolkien-fanzine-journal-LOTR-Hobbit-\/300471157219?pt=Magazines",
|
81
|
+
"paymentMethod"=>"PayPal","autoPay"=>"false","postalCode"=>"55403","location"=>"Minneapolis,MN,USA",
|
82
|
+
"country"=>"US","shippingInfo"=>{"shippingServiceCost"=>{"@currencyId"=>"USD","__value__"=>"2.99"},
|
83
|
+
"shippingType"=>"Flat","shipToLocations"=>"Worldwide"},
|
84
|
+
"sellingStatus"=>{"currentPrice"=>{"@currencyId"=>"USD","__value__"=>"16.99"},
|
85
|
+
"convertedCurrentPrice"=>{"@currencyId"=>"USD","__value__"=>"16.99"},
|
86
|
+
"bidCount"=>"1","sellingState"=>"Active","timeLeft"=>"P0DT0H3M56S"},
|
87
|
+
"listingInfo"=>{"bestOfferEnabled"=>"false","buyItNowAvailable"=>"false",
|
88
|
+
"startTime"=>"2010-09-22T01:57:54.000Z","endTime"=>"2010-09-29T01:57:54.000Z",
|
89
|
+
"listingType"=>"Auction","gift"=>"false"},
|
90
|
+
"condition"=>{"conditionId"=>"4000","conditionDisplayName"=>"Very Good"}},
|
91
|
+
{"itemId"=>"300471157219","title"=>"Minas Tirith 1990 Tolkien fanzine journal LOTR Hobbit",
|
92
|
+
"globalId"=>"EBAY-US","primaryCategory"=>{"categoryId"=>"280","categoryName"=>"Magazine Back Issues"},
|
93
|
+
"secondaryCategory"=>{"categoryId"=>"29799","categoryName"=>"Other"},
|
94
|
+
"galleryURL"=>"http:\/\/thumbs4.ebaystatic.com\/pict\/3004711572198080_1.jpg",
|
95
|
+
"viewItemURL"=>"http:\/\/cgi.ebay.com\/Minas-Tirith-1990-Tolkien-fanzine-journal-LOTR-Hobbit-\/300471157219?pt=Magazines",
|
96
|
+
"paymentMethod"=>"PayPal","autoPay"=>"false","postalCode"=>"55403","location"=>"Minneapolis,MN,USA",
|
97
|
+
"country"=>"US","shippingInfo"=>{"shippingServiceCost"=>{"@currencyId"=>"USD","__value__"=>"2.99"},
|
98
|
+
"shippingType"=>"Flat","shipToLocations"=>"Worldwide"},
|
99
|
+
"sellingStatus"=>{"currentPrice"=>{"@currencyId"=>"USD","__value__"=>"16.99"},
|
100
|
+
"convertedCurrentPrice"=>{"@currencyId"=>"USD","__value__"=>"16.99"},
|
101
|
+
"bidCount"=>"1","sellingState"=>"Active","timeLeft"=>"P0DT0H3M56S"},
|
102
|
+
"listingInfo"=>{"bestOfferEnabled"=>"false","buyItNowAvailable"=>"false",
|
103
|
+
"startTime"=>"2010-09-22T01:57:54.000Z","endTime"=>"2010-09-29T01:57:54.000Z",
|
104
|
+
"listingType"=>"Auction","gift"=>"false"},
|
105
|
+
"condition"=>{"conditionId"=>"4000","conditionDisplayName"=>"Very Good"}}]},
|
106
|
+
"paginationOutput"=>{"pageNumber"=>"1","entriesPerPage"=>"2","totalPages"=>"2359","totalEntries"=>"4717"},
|
107
|
+
"itemSearchURL"=>"http:\/\/shop.ebay.com\/i.html?_nkw=tolkien&_ddo=1&_ipg=2&_pgn=1"}
|
108
|
+
@response.results = @response.response['searchResult']['item']
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should trim format response correctly" do
|
112
|
+
@response.response.should eq(@proper)
|
113
|
+
end
|
114
|
+
end
|
50
115
|
end
|
51
116
|
end
|
data/spec/shopping_spec.rb
CHANGED
@@ -77,6 +77,16 @@ module Rebay
|
|
77
77
|
it "should succeed" do
|
78
78
|
@shopper.get_category_info({:categoryId => 29223}).success?.should be_true
|
79
79
|
end
|
80
|
+
|
81
|
+
it "should iterate over results" do
|
82
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/get_category_info.json"))
|
83
|
+
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
84
|
+
response = @shopper.get_category_info({:categoryId => 1})
|
85
|
+
|
86
|
+
count = 0
|
87
|
+
response.each { |r| count = count + 1 }
|
88
|
+
count.should eq(1)
|
89
|
+
end
|
80
90
|
end
|
81
91
|
|
82
92
|
context "when calling find_products" do
|
@@ -91,6 +101,16 @@ module Rebay
|
|
91
101
|
it "should succeed" do
|
92
102
|
@shopper.find_products({:queryKeywords => 'harry potter'}).success?.should be_true
|
93
103
|
end
|
104
|
+
|
105
|
+
it "should iterate over results" do
|
106
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_products.json"))
|
107
|
+
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
108
|
+
response = @shopper.find_products({:queryKeywords => 'whatevs'})
|
109
|
+
|
110
|
+
count = 0
|
111
|
+
response.each { |r| count = count + 1 }
|
112
|
+
count.should eq(2)
|
113
|
+
end
|
94
114
|
end
|
95
115
|
|
96
116
|
context "when calling find_half_products" do
|
@@ -105,6 +125,16 @@ module Rebay
|
|
105
125
|
it "should succeed" do
|
106
126
|
@shopper.find_half_products({:queryKeywords => 'harry potter'}).success?.should be_true
|
107
127
|
end
|
128
|
+
|
129
|
+
it "should iterate over results" do
|
130
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_half_products.json"))
|
131
|
+
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
132
|
+
response = @shopper.find_half_products({:queryKeywords => 'whatevs'})
|
133
|
+
|
134
|
+
count = 0
|
135
|
+
response.each { |r| count = count + 1 }
|
136
|
+
count.should eq(2)
|
137
|
+
end
|
108
138
|
end
|
109
139
|
|
110
140
|
context "when calling get_single_item" do
|
@@ -189,6 +219,16 @@ module Rebay
|
|
189
219
|
it "should succeed" do
|
190
220
|
@shopper.find_popular_searches({:categoryId => 1}).success?.should be_true
|
191
221
|
end
|
222
|
+
|
223
|
+
it "should iterate over results" do
|
224
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_popular_searches.json"))
|
225
|
+
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
226
|
+
response = @shopper.find_popular_searches({:categoryId => 1})
|
227
|
+
|
228
|
+
count = 0
|
229
|
+
response.each { |r| count = count + 1 }
|
230
|
+
count.should eq(1)
|
231
|
+
end
|
192
232
|
end
|
193
233
|
|
194
234
|
context "when calling find_popular_items" do
|
@@ -199,6 +239,16 @@ module Rebay
|
|
199
239
|
it "should succeed" do
|
200
240
|
@shopper.find_popular_items({:categoryId => 1}).success?.should be_true
|
201
241
|
end
|
242
|
+
|
243
|
+
it "should iterate over results" do
|
244
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_popular_items.json"))
|
245
|
+
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
246
|
+
response = @shopper.find_popular_items({:categoryId => 1})
|
247
|
+
|
248
|
+
count = 0
|
249
|
+
response.each { |r| count = count + 1 }
|
250
|
+
count.should eq(19)
|
251
|
+
end
|
202
252
|
end
|
203
253
|
|
204
254
|
context "when calling find_reviews_and_guides" do
|
@@ -209,6 +259,16 @@ module Rebay
|
|
209
259
|
it "should succeed" do
|
210
260
|
@shopper.find_reviews_and_guides.success?.should be_true
|
211
261
|
end
|
262
|
+
|
263
|
+
it "should iterate over results" do
|
264
|
+
json = JSON.parse(File.read(File.dirname(__FILE__) + "/json_responses/shopping/find_reviews_and_guides.json"))
|
265
|
+
@shopper.stub!(:get_json_response).and_return(Rebay::Response.new(json))
|
266
|
+
response = @shopper.find_reviews_and_guides
|
267
|
+
|
268
|
+
count = 0
|
269
|
+
response.each { |r| count = count + 1 }
|
270
|
+
count.should eq(5)
|
271
|
+
end
|
212
272
|
end
|
213
273
|
end
|
214
274
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rebay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 19
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
version: 1.1.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Chuck Collins
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-10-05 00:00:00 -05:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
28
|
segments:
|
31
29
|
- 0
|
32
30
|
version: "0"
|
@@ -46,6 +44,7 @@ files:
|
|
46
44
|
- README.md
|
47
45
|
- Rakefile
|
48
46
|
- VERSION
|
47
|
+
- config.rb
|
49
48
|
- init.rb
|
50
49
|
- lib/rebay.rb
|
51
50
|
- lib/rebay/api.rb
|
@@ -73,7 +72,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
72
|
requirements:
|
74
73
|
- - ">="
|
75
74
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 3
|
77
75
|
segments:
|
78
76
|
- 0
|
79
77
|
version: "0"
|
@@ -82,7 +80,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
80
|
requirements:
|
83
81
|
- - ">="
|
84
82
|
- !ruby/object:Gem::Version
|
85
|
-
hash: 3
|
86
83
|
segments:
|
87
84
|
- 0
|
88
85
|
version: "0"
|