rebay2 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/rebay2/api.rb +68 -0
- data/lib/rebay2/finding.rb +113 -0
- data/lib/rebay2/merchandising.rb +64 -0
- data/lib/rebay2/railtie.rb +8 -0
- data/lib/rebay2/response.rb +67 -0
- data/lib/rebay2/shopping.rb +136 -0
- data/lib/rebay2/version.rb +3 -0
- data/lib/rebay2.rb +9 -0
- data/rebay2.gemspec +35 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: adaf1d6919b1240e917b8fda231bbef8fd0729fb
|
4
|
+
data.tar.gz: dbfb00ee9c26f662abc216a7680762f6771636a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6cda9afc16b927e5567bdadf42acc4c1e043111c4dbde6debbefdfc11b3d5fd30cef2ac5a263b1456619842ff7d8678fe773c6250f13d8577f4c599fc71a42f3
|
7
|
+
data.tar.gz: dd5ad94cc91b09ef02f6e0e49b3efaff677f26fef652d9bf8aa96f049afd0eb478a92f0e805c8e5f03f0c2485d84c68b87f36709f76de48a9e51c08b71b94e19
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Kirk Jarvis
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Rebay2
|
2
|
+
|
3
|
+
This gem is based on Rebay is a very simple wrapper for the ebay finding and shopping APIs. Additonal calls were add to Finding class. Merchandising API was also added along with configuiring calls to the Ebay API to include affiliate information that can be added to the configuration file.
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'rebay2'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rebay2
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Configuration
|
22
|
+
-------------
|
23
|
+
Create and require a config.rb, or if using rails create an initializer (rebay.rb perhaps), and place the following code into it:
|
24
|
+
|
25
|
+
Rebay2::Api.configure do |rebay2|
|
26
|
+
rebay2.app_id = 'YOUR APPLICATION ID HERE'
|
27
|
+
rebay2.tracking_id = 'YOUR CAMPAIN ID HERE'
|
28
|
+
rebay2.network_id = 'tracking partner for affiliate commissions' # will default 9 if not specified
|
29
|
+
end
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
|
+
|
35
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rebay2. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
40
|
+
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
45
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rebay2"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/rebay2/api.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module Rebay2
|
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
|
9
|
+
EBAY_US = 0
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :customer_id, :network_id, :tracking_id, :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
|
31
|
+
|
32
|
+
def default_site_id
|
33
|
+
@default_site_id || EBAY_US
|
34
|
+
end
|
35
|
+
|
36
|
+
def network_id
|
37
|
+
@network_id ||= 9
|
38
|
+
end
|
39
|
+
|
40
|
+
def configure
|
41
|
+
yield self if block_given?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def get_json_response(url)
|
48
|
+
Rebay::Response.new(JSON.parse(Net::HTTP.get_response(URI.parse(url)).body))
|
49
|
+
end
|
50
|
+
|
51
|
+
def build_rest_payload(params)
|
52
|
+
payload = ''
|
53
|
+
unless params.empty?
|
54
|
+
params.keys.each do |key|
|
55
|
+
payload += URI.escape "&#{key}=#{params[key]}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
unless Rebay2::Api.tracking_id.nil?
|
60
|
+
Rebay2::Api.network_id ||= 9
|
61
|
+
payload += URI.escape "&affiliate.trackingId=#{Rebay2::Api.tracking_id}&affiliate.networkId=#{Rebay2::Api.network_id}"
|
62
|
+
payload += URI.escape "&affiliate.customId=#{Rebay2::Api.customer_id}" unless Rebay2::Api.customer_id.nil?
|
63
|
+
end
|
64
|
+
|
65
|
+
return payload
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module Rebay2
|
2
|
+
class Finding < Rebay2::Api
|
3
|
+
def self.base_url_suffix
|
4
|
+
"ebay.com/services/search/FindingService/v1"
|
5
|
+
end
|
6
|
+
|
7
|
+
VERSION = '1.0.0'
|
8
|
+
#http://developer.ebay.com/Devzone/finding/CallRef/findCompletedItems.html
|
9
|
+
def find_completed_items(params)
|
10
|
+
raise ArgumentError unless params[:keywords] or params[:categoryId]
|
11
|
+
response = get_json_response(build_request_url('findCompletedItems', params))
|
12
|
+
response.trim(:findCompletedItemsResponse)
|
13
|
+
|
14
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
15
|
+
response.results = response.response['searchResult']['item']
|
16
|
+
end
|
17
|
+
return response
|
18
|
+
end
|
19
|
+
|
20
|
+
#http://developer.ebay.com/DevZone/finding/CallRef/findItemsAdvanced.html
|
21
|
+
def find_items_advanced(params)
|
22
|
+
raise ArgumentError unless params[:keywords] or params[:categoryId]
|
23
|
+
response = get_json_response(build_request_url('findItemsAdvanced', params))
|
24
|
+
response.trim(:findItemsAdvancedResponse)
|
25
|
+
|
26
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
27
|
+
response.results = response.response['searchResult']['item']
|
28
|
+
end
|
29
|
+
return response
|
30
|
+
end
|
31
|
+
|
32
|
+
#http://developer.ebay.com/DevZone/finding/CallRef/findItemsByCategory.html
|
33
|
+
def find_items_by_category(params)
|
34
|
+
raise ArgumentError unless params[:categoryId]
|
35
|
+
response = get_json_response(build_request_url('findItemsByCategory', params))
|
36
|
+
response.trim(:findItemsByCategoryResponse)
|
37
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
38
|
+
response.results = response.response['searchResult']['item']
|
39
|
+
end
|
40
|
+
return response
|
41
|
+
end
|
42
|
+
|
43
|
+
#http://developer.ebay.com/DevZone/finding/CallRef/findItemsByKeywords.html
|
44
|
+
def find_items_by_keywords(params)
|
45
|
+
raise ArgumentError unless params[:keywords]
|
46
|
+
response = get_json_response(build_request_url('findItemsByKeywords', params))
|
47
|
+
response.trim(:findItemsByKeywordsResponse)
|
48
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
49
|
+
response.results = response.response['searchResult']['item']
|
50
|
+
end
|
51
|
+
return response
|
52
|
+
end
|
53
|
+
|
54
|
+
#http://developer.ebay.com/DevZone/finding/CallRef/findItemsByProduct.html
|
55
|
+
def find_items_by_product(params)
|
56
|
+
raise ArgumentError unless params[:productId]
|
57
|
+
params['productId.@type'] = 'ReferenceID'
|
58
|
+
response = get_json_response(build_request_url('findItemsByProduct', params))
|
59
|
+
response.trim(:findItemsByProductResponse)
|
60
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
61
|
+
response.results = response.response['searchResult']['item']
|
62
|
+
end
|
63
|
+
return response
|
64
|
+
end
|
65
|
+
|
66
|
+
#http://developer.ebay.com/DevZone/finding/CallRef/findItemsIneBayStores.html
|
67
|
+
def find_items_in_ebay_stores(params)
|
68
|
+
raise ArgumentError unless params[:keywords] or params[:storeName]
|
69
|
+
response = get_json_response(build_request_url('findItemsIneBayStores', params))
|
70
|
+
response.trim(:findItemsIneBayStoresResponse)
|
71
|
+
if response.response.has_key?('searchResult') && response.response['searchResult'].has_key?('item')
|
72
|
+
response.results = response.response['searchResult']['item']
|
73
|
+
end
|
74
|
+
return response
|
75
|
+
end
|
76
|
+
|
77
|
+
#http://developer.ebay.com/DevZone/finding/CallRef/getHistograms.html
|
78
|
+
def get_histograms(params)
|
79
|
+
raise ArgumentError unless params[:categoryId]
|
80
|
+
response = get_json_response(build_request_url('getHistograms', params))
|
81
|
+
response.trim(:getHistorgramsResponse)
|
82
|
+
return response
|
83
|
+
end
|
84
|
+
|
85
|
+
#http://developer.ebay.com/DevZone/finding/CallRef/getSearchKeywordsRecommendation.html
|
86
|
+
def get_search_keywords_recommendation(params)
|
87
|
+
raise ArgumentError unless params[:keywords]
|
88
|
+
response = get_json_response(build_request_url('getSearchKeywordsRecommendation', params))
|
89
|
+
response.trim(:getSearchKeywordsRecommendationResponse)
|
90
|
+
if response.response.has_key?('keywords')
|
91
|
+
response.results = response.response['keywords']
|
92
|
+
end
|
93
|
+
return response
|
94
|
+
end
|
95
|
+
|
96
|
+
#http://developer.ebay.com/DevZone/finding/CallRef/getVersion.html
|
97
|
+
def get_version(*params)
|
98
|
+
response = get_json_response(build_request_url('getVersion', params))
|
99
|
+
response.trim(:getVersionResponse)
|
100
|
+
if response.response.has_key?('version')
|
101
|
+
response.results = response.response['version']
|
102
|
+
end
|
103
|
+
return response
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
def build_request_url(service, params=nil)
|
108
|
+
url = "#{self.class.base_url}?OPERATION-NAME=#{service}&SERVICE-VERSION=#{VERSION}&SECURITY-APPNAME=#{Rebay2::Api.app_id}&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD"
|
109
|
+
url += build_rest_payload(params)
|
110
|
+
return url
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Rebay2
|
2
|
+
class Merchandising < Rebay2::Api
|
3
|
+
def self.base_url_suffix
|
4
|
+
"ebay.com/MerchandisingService"
|
5
|
+
end
|
6
|
+
VERSION = '1.5.0'
|
7
|
+
#http://developer.ebay.com/devzone/merchandising/docs/CallRef/getMostWatchedItems.html
|
8
|
+
def get_most_watched_items(params)
|
9
|
+
#raise ArgumentError unless params[:categoryId]
|
10
|
+
response = get_json_response(build_request_url('getMostWatchedItems', params))
|
11
|
+
response.trim(:getMostWatchedItemsResponse)
|
12
|
+
if response.response.has_key?('itemRecommendations') && response.response['itemRecommendations'].has_key?('item')
|
13
|
+
response.results = response.response['itemRecommendations']['item']
|
14
|
+
end
|
15
|
+
return response
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_related_category_items(params)
|
19
|
+
raise ArgumentError unless params[:categoryId] or params[:itemId]
|
20
|
+
response = get_json_response(build_request_url('getRelatedCategoryItems', params))
|
21
|
+
response.trim(:getRelatedCategoryItemsResponse)
|
22
|
+
if response.response.has_key?('itemRecommendations') && response.response['itemRecommendations'].has_key?('item')
|
23
|
+
response.results = response.response['itemRecommendations']['item']
|
24
|
+
end
|
25
|
+
return response
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_similar_items(params)
|
29
|
+
raise ArgumentError unless params[:itemId]
|
30
|
+
response = get_json_response(build_request_url('getSimilarItems', params))
|
31
|
+
response.trim(:getSimilarItemsResponse)
|
32
|
+
if response.response.has_key?('itemRecommendations') && response.response['itemRecommendations'].has_key?('item')
|
33
|
+
response.results = response.response['itemRecommendations']['item']
|
34
|
+
end
|
35
|
+
return response
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_top_selling_products(*params)
|
39
|
+
response = get_json_response(build_request_url('getTopSellingProducts', params||= nil))
|
40
|
+
response.trim(:getTopSellingProductsResponse)
|
41
|
+
if response.response.has_key?('productRecommendations') && response.response['productRecommendations'].has_key?('product')
|
42
|
+
response.results = response.response['productRecommendations']['product']
|
43
|
+
end
|
44
|
+
return response
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_version(*params)
|
48
|
+
response = get_json_response(build_request_url('getVersion', params))
|
49
|
+
response.trim(:getVersionResponse)
|
50
|
+
if response.response.has_key?('version')
|
51
|
+
response.results = response.response['version']
|
52
|
+
end
|
53
|
+
return response
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
private
|
58
|
+
def build_request_url(service, params=nil)
|
59
|
+
url = "#{self.class.base_url}?OPERATION-NAME=#{service}&SERVICE-NAME=MerchandisingService&SERVICE-VERSION=#{VERSION}&SECURITY-APPNAME=#{Rebay2::Api.app_id}&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD"
|
60
|
+
url += build_rest_payload(params)
|
61
|
+
return url
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Rebay2
|
2
|
+
class Response
|
3
|
+
attr_accessor :response
|
4
|
+
attr_accessor :results
|
5
|
+
|
6
|
+
def initialize(json_response)
|
7
|
+
@response = transform_json_response(json_response)
|
8
|
+
end
|
9
|
+
|
10
|
+
def success?
|
11
|
+
@response["Ack"] == 'Success' || @response['ack'] == 'Success'
|
12
|
+
end
|
13
|
+
|
14
|
+
def failure?
|
15
|
+
@response["Ack"] == 'Failure' || @response['ack'] == 'Failure'
|
16
|
+
end
|
17
|
+
|
18
|
+
def trim(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
|
31
|
+
end
|
32
|
+
end
|
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
|
+
|
44
|
+
protected
|
45
|
+
def transform_json_response(response)
|
46
|
+
if response.class == Hash
|
47
|
+
r = Hash.new
|
48
|
+
response.keys.each do |k|
|
49
|
+
r[k] = transform_json_response(response[k])
|
50
|
+
end
|
51
|
+
return r
|
52
|
+
elsif response.class == Array
|
53
|
+
if response.size == 1
|
54
|
+
return transform_json_response(response[0])
|
55
|
+
else
|
56
|
+
r = Array.new
|
57
|
+
response.each do |a|
|
58
|
+
r.push(transform_json_response(a))
|
59
|
+
end
|
60
|
+
return r
|
61
|
+
end
|
62
|
+
else
|
63
|
+
return response
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
module Rebay2
|
2
|
+
class Shopping < Rebay2::Api
|
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
|
14
|
+
|
15
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindProducts.html
|
16
|
+
def find_products(params)
|
17
|
+
raise ArgumentError unless params[:CategoryID] or params[:ProductID] or params[:QueryKeywords] or
|
18
|
+
(params[:'ProductID.Value'] && params[:'ProductID.type'])
|
19
|
+
response = get_json_response(build_request_url('FindProducts', params))
|
20
|
+
if response.response.has_key?('Product')
|
21
|
+
response.results = response.response['Product']
|
22
|
+
end
|
23
|
+
return response
|
24
|
+
end
|
25
|
+
|
26
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindHalfProducts.html
|
27
|
+
def find_half_products(params)
|
28
|
+
raise ArgumentError unless params[:ProductID] or params[:QueryKeywords] or
|
29
|
+
(params[:'ProductID.Value'] && params[:'ProductID.type'])
|
30
|
+
response = get_json_response(build_request_url('FindHalfProducts', params))
|
31
|
+
if response.response.has_key?('Products') && response.response['Products'].has_key?('Product')
|
32
|
+
response.results = response.response['Products']['Product']
|
33
|
+
end
|
34
|
+
return response
|
35
|
+
end
|
36
|
+
|
37
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetSingleItem.html
|
38
|
+
def get_single_item(params)
|
39
|
+
raise ArgumentError unless params[:ItemID]
|
40
|
+
response = get_json_response(build_request_url('GetSingleItem', params))
|
41
|
+
if response.response.has_key?('Item')
|
42
|
+
response.results = response.response['Item']
|
43
|
+
end
|
44
|
+
return response
|
45
|
+
end
|
46
|
+
|
47
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetItemStatus.html
|
48
|
+
def get_item_status(params)
|
49
|
+
raise ArgumentError unless params[:ItemID]
|
50
|
+
response = get_json_response(build_request_url('GetItemStatus', params))
|
51
|
+
if response.response.has_key?('Item')
|
52
|
+
response.results = response.response['Item']
|
53
|
+
end
|
54
|
+
return response
|
55
|
+
end
|
56
|
+
|
57
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetShippingCosts.html
|
58
|
+
def get_shipping_costs(params)
|
59
|
+
raise ArgumentError unless params[:ItemID]
|
60
|
+
response = get_json_response(build_request_url('GetShippingCosts', params))
|
61
|
+
return response
|
62
|
+
end
|
63
|
+
|
64
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetMultipleItems.html
|
65
|
+
def get_multiple_items(params)
|
66
|
+
raise ArgumentError unless params[:ItemID]
|
67
|
+
response = get_json_response(build_request_url('GetMultipleItems', params))
|
68
|
+
if response.response.has_key?('Item')
|
69
|
+
response.results = response.response['Item']
|
70
|
+
end
|
71
|
+
return response
|
72
|
+
end
|
73
|
+
|
74
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetUserProfile.html
|
75
|
+
def get_user_profile(params)
|
76
|
+
raise ArgumentError unless params[:UserID]
|
77
|
+
response = get_json_response(build_request_url('GetUserProfile', params))
|
78
|
+
if response.response.has_key?('User')
|
79
|
+
response.results = response.response['User']
|
80
|
+
end
|
81
|
+
return response
|
82
|
+
end
|
83
|
+
|
84
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindPopularSearches.html
|
85
|
+
def find_popular_searches(params)
|
86
|
+
raise ArgumentError unless params[:CategoryID]
|
87
|
+
response = get_json_response(build_request_url('FindPopularSearches', params))
|
88
|
+
if response.response.has_key?('PopularSearchResult')
|
89
|
+
response.results = response.response['PopularSearchResult']
|
90
|
+
end
|
91
|
+
return response
|
92
|
+
end
|
93
|
+
|
94
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindPopularItems.html
|
95
|
+
def find_popular_items(params={})
|
96
|
+
raise ArgumentError unless params[:CategoryID] or params[:QueryKeywords]
|
97
|
+
response = get_json_response(build_request_url('FindPopularItems', params))
|
98
|
+
if response.response.has_key?('ItemArray') && response.response['ItemArray'].has_key?('Item')
|
99
|
+
response.results = response.response['ItemArray']['Item']
|
100
|
+
end
|
101
|
+
return response
|
102
|
+
end
|
103
|
+
|
104
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/FindReviewsandGuides.html
|
105
|
+
def find_reviews_and_guides(params={})
|
106
|
+
response = get_json_response(build_request_url('FindReviewsAndGuides', params))
|
107
|
+
if response.response.has_key?('BuyingGuideDetails') && response.response['BuyingGuideDetails'].has_key?('BuyingGuide')
|
108
|
+
response.results = response.response['BuyingGuideDetails']['BuyingGuide']
|
109
|
+
end
|
110
|
+
return response
|
111
|
+
end
|
112
|
+
|
113
|
+
#http://developer.ebay.com/DevZone/shopping/docs/CallRef/GetCategoryInfo.html
|
114
|
+
def get_category_info(params)
|
115
|
+
raise ArgumentError unless params[:CategoryID]
|
116
|
+
response = get_json_response(build_request_url('GetCategoryInfo', params))
|
117
|
+
if response.response.has_key?('CategoryArray') && response.response['CategoryArray'].has_key?('Category')
|
118
|
+
response.results = response.response['CategoryArray']['Category']
|
119
|
+
end
|
120
|
+
return response
|
121
|
+
end
|
122
|
+
|
123
|
+
def get_category_info_with_children(params)
|
124
|
+
params[:IncludeSelector] = 'ChildCategories'
|
125
|
+
response = get_category_info(params)
|
126
|
+
return response
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
def build_request_url(service, params=nil)
|
131
|
+
url = "#{self.class.base_url}?callname=#{service}&appid=#{Rebay2::Api.app_id}&version=#{VERSION}&responseencoding=JSON"
|
132
|
+
url += build_rest_payload({siteid: Rebay2::Api.default_site_id}.merge(params))
|
133
|
+
return url
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
data/lib/rebay2.rb
ADDED
data/rebay2.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rebay2/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rebay2"
|
8
|
+
spec.version = Rebay2::VERSION
|
9
|
+
spec.authors = ["Kirk Jarvis"]
|
10
|
+
spec.email = ["zuuzlo@yahoo.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Simple ruby wrapper for the Ebay API}
|
13
|
+
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
|
+
#spec.homepage = "TODO: Put your gem's website or public repo URL here."
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec"
|
33
|
+
spec.add_development_dependency "pry"
|
34
|
+
spec.add_dependency "json"
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rebay2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kirk Jarvis
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- zuuzlo@yahoo.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- .travis.yml
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- lib/rebay2.rb
|
101
|
+
- lib/rebay2/api.rb
|
102
|
+
- lib/rebay2/finding.rb
|
103
|
+
- lib/rebay2/merchandising.rb
|
104
|
+
- lib/rebay2/railtie.rb
|
105
|
+
- lib/rebay2/response.rb
|
106
|
+
- lib/rebay2/shopping.rb
|
107
|
+
- lib/rebay2/version.rb
|
108
|
+
- rebay2.gemspec
|
109
|
+
homepage:
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata:
|
113
|
+
allowed_push_host: https://rubygems.org
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.4.8
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Simple ruby wrapper for the Ebay API
|
134
|
+
test_files: []
|