Module: Ebay::Requestable
- Included in:
- Browse, Finding, Merchandising, Oauth::ClientCredentialsGrant, Shopping
- Defined in:
- lib/ebay/requestable.rb
Overview
Adds an HTTP client and ability to switch to the eBay Sandbox environment
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#market_id=(market_id) ⇒ Object
Sets the eBay Market.
-
#persistent(timeout: 5) ⇒ self
Flags request as persistent.
-
#sandbox ⇒ self
Switches to the eBay Sandbox environment.
-
#use(*features) ⇒ self
Turns on HTTP features.
-
#via(*proxy) ⇒ self
Makes a request through an HTTP proxy.
Instance Attribute Details
#endpoint ⇒ String (readonly)
41 42 43 |
# File 'lib/ebay/requestable.rb', line 41 def endpoint @endpoint ||= self.class.endpoint end |
#headers ⇒ Hash
23 24 25 |
# File 'lib/ebay/requestable.rb', line 23 def headers @headers end |
#http ⇒ HTTP::Client
35 36 37 |
# File 'lib/ebay/requestable.rb', line 35 def http @http ||= HTTP::Client.new end |
Instance Method Details
#market_id=(market_id) ⇒ Object
Sets the eBay Market
28 29 30 31 |
# 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) ⇒ self
Flags request as persistent
57 58 59 60 |
# File 'lib/ebay/requestable.rb', line 57 def persistent(timeout: 5) self.http = http.persistent(endpoint, timeout: timeout) self end |
#sandbox ⇒ self
Switches to the eBay Sandbox environment
48 49 50 51 |
# File 'lib/ebay/requestable.rb', line 48 def sandbox @endpoint = endpoint.sub('ebay', 'sandbox.ebay') self end |
#use(*features) ⇒ self
Turns on HTTP features
74 75 76 77 78 79 |
# File 'lib/ebay/requestable.rb', line 74 %i[timeout via through use].each do |method_name| define_method(method_name) do |*args, &block| self.http = http.send(method_name, *args, &block) self end end |
#via(*proxy) ⇒ self
Makes a request through an HTTP proxy
74 75 76 77 78 79 |
# File 'lib/ebay/requestable.rb', line 74 %i[timeout via through use].each do |method_name| define_method(method_name) do |*args, &block| self.http = http.send(method_name, *args, &block) self end end |