Module: Ebayr
- Extended by:
- Ebayr
- Defined in:
- lib/ebayr.rb,
lib/ebayr/user.rb,
lib/ebayr/record.rb,
lib/ebayr/request.rb,
lib/ebayr/response.rb,
lib/ebayr/test_helper.rb
Overview
:nodoc:
Defined Under Namespace
Modules: TestHelper, User Classes: Record, Request, Response
Class Method Summary collapse
Instance Method Summary collapse
-
#authorization_uri(session_id, ru_params = {}) ⇒ Object
Gets the URI for eBay authorization/login.
-
#call(command, arguments = {}) ⇒ Object
Perform an eBay call (symbol or string).
- #sandbox? ⇒ Boolean
-
#uri(*args) ⇒ Object
Gets the URI used for API calls (as a URI object).
-
#uri_prefix(service = "api") ⇒ Object
Gets either ebay.com/ws or sandbox.ebay.com/ws, as appropriate, with “service” prepended.
Class Method Details
.included(mod) ⇒ Object
133 134 135 |
# File 'lib/ebayr.rb', line 133 def self.included(mod) mod.extend(self) end |
.normalize_responses? ⇒ Boolean
34 35 36 |
# File 'lib/ebayr.rb', line 34 def self.normalize_responses? !!normalize_responses end |
Instance Method Details
#authorization_uri(session_id, ru_params = {}) ⇒ Object
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).
97 98 99 100 |
# File 'lib/ebayr.rb', line 97 def (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 = {}) ⇒ Object
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
128 129 130 |
# File 'lib/ebayr.rb', line 128 def call(command, arguments = {}) Request.new(command, arguments).send end |
#sandbox? ⇒ Boolean
38 39 40 |
# File 'lib/ebayr.rb', line 38 def sandbox? !!sandbox end |
#uri(*args) ⇒ Object
Gets the URI used for API calls (as a URI object)
89 90 91 |
# File 'lib/ebayr.rb', line 89 def uri(*args) URI::parse("#{uri_prefix(*args)}/api.dll") end |
#uri_prefix(service = "api") ⇒ Object
84 85 86 |
# File 'lib/ebayr.rb', line 84 def uri_prefix(service = "api") "https://#{service}#{sandbox ? ".sandbox" : ""}.ebay.com/ws" end |