rebay 1.1.3 → 1.2.0
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/Gemfile +0 -2
- data/Gemfile.lock +9 -19
- data/README.md +23 -1
- data/VERSION +1 -1
- data/lib/rebay/api.rb +34 -13
- data/lib/rebay/finding.rb +6 -3
- data/lib/rebay/shopping.rb +39 -28
- data/rebay.gemspec +3 -9
- metadata +11 -23
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,30 +1,20 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
diff-lcs (1.1.
|
5
|
-
git (1.2.5)
|
6
|
-
jeweler (1.5.2)
|
7
|
-
bundler (~> 1.0.0)
|
8
|
-
git (>= 1.2.5)
|
9
|
-
rake
|
4
|
+
diff-lcs (1.1.3)
|
10
5
|
json (1.5.1)
|
11
|
-
|
12
|
-
|
13
|
-
rspec-
|
14
|
-
rspec-
|
15
|
-
|
16
|
-
rspec-
|
17
|
-
|
18
|
-
|
19
|
-
rspec-mocks (2.5.0)
|
20
|
-
watchr (0.7)
|
6
|
+
rspec (2.12.0)
|
7
|
+
rspec-core (~> 2.12.0)
|
8
|
+
rspec-expectations (~> 2.12.0)
|
9
|
+
rspec-mocks (~> 2.12.0)
|
10
|
+
rspec-core (2.12.2)
|
11
|
+
rspec-expectations (2.12.1)
|
12
|
+
diff-lcs (~> 1.1.3)
|
13
|
+
rspec-mocks (2.12.1)
|
21
14
|
|
22
15
|
PLATFORMS
|
23
16
|
ruby
|
24
17
|
|
25
18
|
DEPENDENCIES
|
26
|
-
bundler (>= 1.0.0)
|
27
|
-
jeweler (>= 1.5.2)
|
28
19
|
json
|
29
20
|
rspec
|
30
|
-
watchr
|
data/README.md
CHANGED
@@ -38,7 +38,29 @@ For my own sanity, I transform this response into a more standard ruby hash and
|
|
38
38
|
You can check for success or failure of the request:
|
39
39
|
response.success?
|
40
40
|
response.failure?
|
41
|
-
|
41
|
+
|
42
|
+
Recent Updates
|
43
|
+
--------------
|
44
|
+
[yarmiganosca](https://github.com/yarmiganosca)
|
45
|
+
|
46
|
+
Added support for using Ebay Sandbox urls (through a configuration
|
47
|
+
variable).
|
48
|
+
|
49
|
+
Changed the way Finding and Shopping generate their base urls. Instead
|
50
|
+
of a class variable, they now call self.base_url, which reads the
|
51
|
+
sandbox configuration variable and either creates a sandbox url or a
|
52
|
+
production url.
|
53
|
+
|
54
|
+
Updated the conditions under which the Shopping Api calls raise
|
55
|
+
ArgumentErrors, involved changing the cases of the parameters (they
|
56
|
+
changed in the Ebay Api) and adding support for specifying either a
|
57
|
+
ProductID or a ProductID.type, ProductID.Value pair for searching by
|
58
|
+
ProductIDs other than Ebay ReferenceIDs.
|
59
|
+
|
60
|
+
[peppyheppy](https://github.com/peppyheppy)
|
61
|
+
|
62
|
+
Added support for dynamic siteid in both configuration and by passing in params
|
63
|
+
|
42
64
|
MIT License
|
43
65
|
-----------
|
44
66
|
Copyright (c) 2010 Chuck Collins
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/lib/rebay/api.rb
CHANGED
@@ -4,25 +4,46 @@ require 'uri'
|
|
4
4
|
|
5
5
|
module Rebay
|
6
6
|
class Api
|
7
|
+
# default site is EBAY_US, for other available sites see eBay documentation:
|
8
|
+
# http://developer.ebay.com/DevZone/merchandising/docs/Concepts/SiteIDToGlobalID.html
|
7
9
|
EBAY_US = 0
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :app_id, :default_site_id, :sandbox
|
13
|
+
|
14
|
+
def base_url
|
15
|
+
[base_url_prefix,
|
16
|
+
sandbox ? "sandbox" : nil,
|
17
|
+
base_url_suffix].compact.join('.')
|
18
|
+
end
|
19
|
+
|
20
|
+
def base_url_prefix
|
21
|
+
"http://svcs"
|
22
|
+
end
|
23
|
+
|
24
|
+
def base_url_suffix
|
25
|
+
"ebay.com"
|
26
|
+
end
|
27
|
+
|
28
|
+
def sandbox
|
29
|
+
@sandbox ||= false
|
30
|
+
end
|
16
31
|
|
17
|
-
|
18
|
-
|
32
|
+
def default_site_id
|
33
|
+
@default_site_id || EBAY_US
|
34
|
+
end
|
35
|
+
|
36
|
+
def configure
|
37
|
+
yield self if block_given?
|
38
|
+
end
|
19
39
|
end
|
20
|
-
|
40
|
+
|
21
41
|
protected
|
42
|
+
|
22
43
|
def get_json_response(url)
|
23
44
|
Rebay::Response.new(JSON.parse(Net::HTTP.get_response(URI.parse(url)).body))
|
24
45
|
end
|
25
|
-
|
46
|
+
|
26
47
|
def build_rest_payload(params)
|
27
48
|
payload = ''
|
28
49
|
unless params.nil?
|
@@ -33,4 +54,4 @@ module Rebay
|
|
33
54
|
return payload
|
34
55
|
end
|
35
56
|
end
|
36
|
-
end
|
57
|
+
end
|
data/lib/rebay/finding.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module Rebay
|
2
2
|
class Finding < Rebay::Api
|
3
|
-
|
3
|
+
def self.base_url_suffix
|
4
|
+
"ebay.com/services/search/FindingService/v1"
|
5
|
+
end
|
6
|
+
|
4
7
|
VERSION = '1.0.0'
|
5
8
|
|
6
9
|
#http://developer.ebay.com/DevZone/finding/CallRef/findItemsAdvanced.html
|
@@ -91,9 +94,9 @@ module Rebay
|
|
91
94
|
|
92
95
|
private
|
93
96
|
def build_request_url(service, params=nil)
|
94
|
-
url = "#{
|
97
|
+
url = "#{self.class.base_url}?OPERATION-NAME=#{service}&SERVICE-VERSION=#{VERSION}&SECURITY-APPNAME=#{Rebay::Api.app_id}&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD"
|
95
98
|
url += build_rest_payload(params)
|
96
99
|
return url
|
97
100
|
end
|
98
101
|
end
|
99
|
-
end
|
102
|
+
end
|
data/lib/rebay/shopping.rb
CHANGED
@@ -1,95 +1,106 @@
|
|
1
1
|
module Rebay
|
2
2
|
class Shopping < Rebay::Api
|
3
|
-
|
4
|
-
|
3
|
+
VERSION = '793'
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def base_url_prefix
|
7
|
+
"http://open.api"
|
8
|
+
end
|
9
|
+
|
10
|
+
def base_url_suffix
|
11
|
+
"ebay.com/shopping"
|
12
|
+
end
|
13
|
+
end
|
5
14
|
|
6
15
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindProducts.html
|
7
16
|
def find_products(params)
|
8
|
-
raise ArgumentError unless params[:
|
17
|
+
raise ArgumentError unless params[:CategoryID] or params[:ProductID] or params[:QueryKeywords] or
|
18
|
+
(params[:'ProductID.Value'] && params[:'ProductID.type'])
|
9
19
|
response = get_json_response(build_request_url('FindProducts', params))
|
10
20
|
if response.response.has_key?('Product')
|
11
21
|
response.results = response.response['Product']
|
12
22
|
end
|
13
23
|
return response
|
14
24
|
end
|
15
|
-
|
25
|
+
|
16
26
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindHalfProducts.html
|
17
27
|
def find_half_products(params)
|
18
|
-
raise ArgumentError unless params[:
|
28
|
+
raise ArgumentError unless params[:ProductID] or params[:QueryKeywords] or
|
29
|
+
(params[:'ProductID.Value'] && params[:'ProductID.type'])
|
19
30
|
response = get_json_response(build_request_url('FindHalfProducts', params))
|
20
31
|
if response.response.has_key?('Products') && response.response['Products'].has_key?('Product')
|
21
32
|
response.results = response.response['Products']['Product']
|
22
33
|
end
|
23
34
|
return response
|
24
35
|
end
|
25
|
-
|
36
|
+
|
26
37
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetSingleItem.html
|
27
38
|
def get_single_item(params)
|
28
|
-
raise ArgumentError unless params[:
|
39
|
+
raise ArgumentError unless params[:ItemID]
|
29
40
|
response = get_json_response(build_request_url('GetSingleItem', params))
|
30
41
|
if response.response.has_key?('Item')
|
31
42
|
response.results = response.response['Item']
|
32
43
|
end
|
33
44
|
return response
|
34
45
|
end
|
35
|
-
|
46
|
+
|
36
47
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetItemStatus.html
|
37
48
|
def get_item_status(params)
|
38
|
-
raise ArgumentError unless params[:
|
49
|
+
raise ArgumentError unless params[:ItemID]
|
39
50
|
response = get_json_response(build_request_url('GetItemStatus', params))
|
40
51
|
if response.response.has_key?('Item')
|
41
52
|
response.results = response.response['Item']
|
42
53
|
end
|
43
54
|
return response
|
44
55
|
end
|
45
|
-
|
56
|
+
|
46
57
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetShippingCosts.html
|
47
58
|
def get_shipping_costs(params)
|
48
|
-
raise ArgumentError unless params[:
|
59
|
+
raise ArgumentError unless params[:ItemID]
|
49
60
|
response = get_json_response(build_request_url('GetShippingCosts', params))
|
50
61
|
return response
|
51
62
|
end
|
52
|
-
|
63
|
+
|
53
64
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetMultipleItems.html
|
54
65
|
def get_multiple_items(params)
|
55
|
-
raise ArgumentError unless params[:
|
66
|
+
raise ArgumentError unless params[:ItemID]
|
56
67
|
response = get_json_response(build_request_url('GetMultipleItems', params))
|
57
68
|
if response.response.has_key?('Item')
|
58
69
|
response.results = response.response['Item']
|
59
70
|
end
|
60
71
|
return response
|
61
72
|
end
|
62
|
-
|
73
|
+
|
63
74
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetUserProfile.html
|
64
75
|
def get_user_profile(params)
|
65
|
-
raise ArgumentError unless params[:
|
76
|
+
raise ArgumentError unless params[:UserID]
|
66
77
|
response = get_json_response(build_request_url('GetUserProfile', params))
|
67
78
|
if response.response.has_key?('User')
|
68
79
|
response.results = response.response['User']
|
69
80
|
end
|
70
81
|
return response
|
71
82
|
end
|
72
|
-
|
83
|
+
|
73
84
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindPopularSearches.html
|
74
85
|
def find_popular_searches(params)
|
75
|
-
raise ArgumentError unless params[:
|
86
|
+
raise ArgumentError unless params[:CategoryID]
|
76
87
|
response = get_json_response(build_request_url('FindPopularSearches', params))
|
77
88
|
if response.response.has_key?('PopularSearchResult')
|
78
89
|
response.results = response.response['PopularSearchResult']
|
79
90
|
end
|
80
91
|
return response
|
81
92
|
end
|
82
|
-
|
93
|
+
|
83
94
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindPopularItems.html
|
84
95
|
def find_popular_items(params={})
|
85
|
-
raise ArgumentError unless params[:
|
96
|
+
raise ArgumentError unless params[:CategoryID] or params[:QueryKeywords]
|
86
97
|
response = get_json_response(build_request_url('FindPopularItems', params))
|
87
98
|
if response.response.has_key?('ItemArray') && response.response['ItemArray'].has_key?('Item')
|
88
99
|
response.results = response.response['ItemArray']['Item']
|
89
100
|
end
|
90
101
|
return response
|
91
102
|
end
|
92
|
-
|
103
|
+
|
93
104
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindReviewsandGuides.html
|
94
105
|
def find_reviews_and_guides(params={})
|
95
106
|
response = get_json_response(build_request_url('FindReviewsAndGuides', params))
|
@@ -98,28 +109,28 @@ module Rebay
|
|
98
109
|
end
|
99
110
|
return response
|
100
111
|
end
|
101
|
-
|
112
|
+
|
102
113
|
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetCategoryInfo.html
|
103
114
|
def get_category_info(params)
|
104
|
-
raise ArgumentError unless params[:
|
115
|
+
raise ArgumentError unless params[:CategoryID]
|
105
116
|
response = get_json_response(build_request_url('GetCategoryInfo', params))
|
106
117
|
if response.response.has_key?('CategoryArray') && response.response['CategoryArray'].has_key?('Category')
|
107
118
|
response.results = response.response['CategoryArray']['Category']
|
108
119
|
end
|
109
120
|
return response
|
110
121
|
end
|
111
|
-
|
122
|
+
|
112
123
|
def get_category_info_with_children(params)
|
113
124
|
params[:IncludeSelector] = 'ChildCategories'
|
114
125
|
response = get_category_info(params)
|
115
126
|
return response
|
116
|
-
end
|
117
|
-
|
127
|
+
end
|
128
|
+
|
118
129
|
private
|
119
130
|
def build_request_url(service, params=nil)
|
120
|
-
url = "#{
|
121
|
-
url += build_rest_payload(params)
|
131
|
+
url = "#{self.class.base_url}?callname=#{service}&appid=#{Rebay::Api.app_id}&version=#{VERSION}&responseencoding=JSON"
|
132
|
+
url += build_rest_payload({siteid: Rebay::Api.default_site_id}.merge(params))
|
122
133
|
return url
|
123
134
|
end
|
124
135
|
end
|
125
|
-
end
|
136
|
+
end
|
data/rebay.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "rebay"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.2.0"
|
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 = "
|
12
|
+
s.date = "2013-01-03"
|
13
13
|
s.email = "chuck.collins@gmail.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
]
|
34
34
|
s.homepage = "http://github.com/ccollins/rebay"
|
35
35
|
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version = "1.8.
|
36
|
+
s.rubygems_version = "1.8.23"
|
37
37
|
s.summary = "Client for the RESTful JSON ebay finding and shopping api"
|
38
38
|
|
39
39
|
if s.respond_to? :specification_version then
|
@@ -41,19 +41,13 @@ Gem::Specification.new do |s|
|
|
41
41
|
|
42
42
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
43
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
44
|
-
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
45
|
-
s.add_development_dependency(%q<jeweler>, [">= 1.5.2"])
|
46
44
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
47
45
|
else
|
48
46
|
s.add_dependency(%q<rspec>, [">= 0"])
|
49
|
-
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
50
|
-
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
51
47
|
s.add_dependency(%q<json>, [">= 0"])
|
52
48
|
end
|
53
49
|
else
|
54
50
|
s.add_dependency(%q<rspec>, [">= 0"])
|
55
|
-
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
56
|
-
s.add_dependency(%q<jeweler>, [">= 1.5.2"])
|
57
51
|
s.add_dependency(%q<json>, [">= 0"])
|
58
52
|
end
|
59
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rebay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
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:
|
12
|
+
date: 2013-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,40 +21,28 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: bundler
|
27
|
-
requirement: &70147704517520 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
none: false
|
29
26
|
requirements:
|
30
27
|
- - ! '>='
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70147704517520
|
29
|
+
version: '0'
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement:
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
34
|
requirements:
|
41
35
|
- - ! '>='
|
42
36
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
type: :
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
45
39
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: json
|
49
|
-
requirement: &70147704510340 !ruby/object:Gem::Requirement
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
41
|
none: false
|
51
42
|
requirements:
|
52
43
|
- - ! '>='
|
53
44
|
- !ruby/object:Gem::Version
|
54
45
|
version: '0'
|
55
|
-
type: :runtime
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *70147704510340
|
58
46
|
description:
|
59
47
|
email: chuck.collins@gmail.com
|
60
48
|
executables: []
|
@@ -97,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
85
|
version: '0'
|
98
86
|
requirements: []
|
99
87
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.8.
|
88
|
+
rubygems_version: 1.8.23
|
101
89
|
signing_key:
|
102
90
|
specification_version: 3
|
103
91
|
summary: Client for the RESTful JSON ebay finding and shopping api
|