module Ebayr

A library to assist in using the eBay Trading API.

Public Class Methods

included(mod) click to toggle source
# File lib/ebayr.rb, line 135
def self.included(mod)
  mod.extend(self)
end
normalize_responses?() click to toggle source
# File lib/ebayr.rb, line 33
def self.normalize_responses?
  !!normalize_responses
end

Public Instance Methods

authorization_uri(session_id, ru_params = {}) click to toggle source

Gets the URI for eBay authorization/login. The session_id should be obtained via an API call to GetSessionID (be sure to use the right ru_name), and the ru_params can contain anything (they will be passed back to your app in the redirect from eBay upon successful login and authorization).

# File lib/ebayr.rb, line 99
def authorization_uri(session_id, ru_params = {})
  ruparams = CGI::escape(ru_params.map { |k, v| "#{k}=#{v}" }.join("&"))
  URI::parse("#{uri_prefix("signin")}/eBayISAPI.dll?SignIn&RuName=#{ru_name}&SessId=#{session_id}&ruparams=#{ruparams}")
end
call(command, arguments = {}) click to toggle source

Perform an eBay call (symbol or string). You can pass in these arguments:

auth_token

to use a user's token instead of the general token

site_id

to use a specific eBay site (default is 0, which is US ebay.com)

compatability_level

declare another eBay Trading API compatability_level

All other arguments are passed into the API call, and may be nested.

response = call(:GeteBayOfficialTime)
response = call(:get_ebay_official_time)

See Ebayr::Request for details.

The response is a special Hash of the response, deserialized from the XML

   response.timestamp     # => 2010-10-10 10:00:00 UTC
   response[:timestamp]   # => 2010-10-10 10:00:00 UTC
   response['Timestamp']  # => "2012-10-10T10:00:00.000Z"
   response[:Timestamp]   # => "2012-10-10T10:00:00.000Z"
   response.ack           # "Success"
   response.success?      # true

See Ebayr::Response for details.

To see a list of available calls, check out
http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/index.html
# File lib/ebayr.rb, line 130
def call(command, arguments = {})
  Request.new(command, arguments).send
end
sandbox?() click to toggle source
# File lib/ebayr.rb, line 37
def sandbox?
  !!sandbox
end
uri(*args) click to toggle source

Gets the URI used for API calls (as a URI object)

# File lib/ebayr.rb, line 91
def uri(*args)
  URI::parse("#{uri_prefix(*args)}/api.dll")
end
uri_prefix(service = "api") click to toggle source

Gets either ebay.com/ws or sandbox.ebay.com/ws, as appropriate, with “service” prepended. E.g.

Ebayr.uri_prefix("blah")  # => https://blah.ebay.com/ws
Ebayr.uri_prefix          # => https://api.ebay.com/ws
# File lib/ebayr.rb, line 86
def uri_prefix(service = "api")
  "https://#{service}#{sandbox ? ".sandbox" : ""}.ebay.com/ws"
end