Class: App::Ebay
- Inherits:
-
Object
- Object
- App::Ebay
- Defined in:
- lib/core/ebay.rb
Constant Summary collapse
- SANDBOX =
'sandbox'
- SANDBOX_URL =
'https://api.sandbox.ebay.com/ws/api.dll'
- PRODUCTION =
'production'
- PRODUCTION_URL =
'https://api.ebay.com/ws/api.dll'
Instance Method Summary collapse
-
#find(search_term = nil) ⇒ Object
findItemsByKeywordsRequest.
-
#initialize(app_key, dev_key, cert_key, runame, api_url, api_token) ⇒ Ebay
constructor
A new instance of Ebay.
Constructor Details
#initialize(app_key, dev_key, cert_key, runame, api_url, api_token) ⇒ Ebay
Returns a new instance of Ebay.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/core/ebay.rb', line 11 def initialize(app_key, dev_key, cert_key, runame, api_url, api_token) @app_key = app_key @dev_key = dev_key @cert_key = cert_key @runame = runame @api_url = api_url @api_token = api_token end |
Instance Method Details
#find(search_term = nil) ⇒ Object
findItemsByKeywordsRequest
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/core/ebay.rb', line 23 def find(search_term = nil) if search_term.nil? raise RuntimeError, 'Search term cannot be nil.' end payload = "<?xml version=\"1.0\" encoding=\"utf-8\"?><findItemsByKeywordsRequest xmlns=\"http://www.ebay.com/marketplace/search/v1/services\"><keywords>#{search_term}</keywords></findItemsByKeywordsRequest>" headers = { 'X-EBAY-SOA-SERVICE-NAME' => 'FindingService', 'X-EBAY-SOA-OPERATION-NAME' => 'findItemsByKeywords', 'X-EBAY-SOA-SERVICE-VERSION' => '1.13.0', 'X-EBAY-SOA-GLOBAL-ID' => 'EBAY-GB', 'X-EBAY-SOA-SECURITY-APPNAME' => @app_key, 'X-EBAY-SOA-REQUEST-DATA-FORMAT' => 'XML' } response = RestClient.post(@api_url, payload, headers) puts response.inspect end |