module Ebay::Requestable

Adds an HTTP client and ability to switch to the eBay Sandbox environment

Attributes

headers[RW]

@!attribute [r] headers @return [Hash]

http[W]

@return [HTTP::Client]

Private Class Methods

included(base) click to toggle source
# File lib/ebay/requestable.rb, line 11
def included(base)
  class << base
    attr_accessor :endpoint
  end
end

Public Instance Methods

endpoint() click to toggle source

@!attribute [r] endpoint @return [String]

# File lib/ebay/requestable.rb, line 41
def endpoint
  @endpoint ||= self.class.endpoint
end
http() click to toggle source

@!attribute [r] http @return [HTTP::Client]

# File lib/ebay/requestable.rb, line 35
def http
  @http ||= HTTP::Client.new
end
market_id=(market_id) click to toggle source

Sets the eBay Market

@param [String]

# File lib/ebay/requestable.rb, line 28
def market_id=(market_id)
  @headers ||= {}
  @headers['X-EBAY-SOA-GLOBAL-ID'] = market_id
end
persistent(timeout: 5) click to toggle source

Flags request as persistent

@param [Integer] timeout @return [self]

# File lib/ebay/requestable.rb, line 57
def persistent(timeout: 5)
  self.http = http.persistent(endpoint, timeout: timeout)
  self
end
sandbox() click to toggle source

Switches to the eBay Sandbox environment

@return [self]

# File lib/ebay/requestable.rb, line 48
def sandbox
  @endpoint = endpoint.sub('ebay', 'sandbox.ebay')
  self
end