Class: ShippingEasy::Http::FaradayAdapter
- Inherits:
-
Object
- Object
- ShippingEasy::Http::FaradayAdapter
- Extended by:
- Forwardable
- Defined in:
- lib/shipping_easy/http/faraday_adapter.rb
Defined Under Namespace
Classes: CustomUserAgent
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #connect! ⇒ Object
- #connection ⇒ Object
- #get ⇒ Object
-
#initialize(request) ⇒ FaradayAdapter
constructor
A new instance of FaradayAdapter.
- #post ⇒ Object
Constructor Details
#initialize(request) ⇒ FaradayAdapter
Returns a new instance of FaradayAdapter.
10 11 12 |
# File 'lib/shipping_easy/http/faraday_adapter.rb', line 10 def initialize(request) @request = request end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
8 9 10 |
# File 'lib/shipping_easy/http/faraday_adapter.rb', line 8 def request @request end |
Instance Method Details
#connect! ⇒ Object
14 15 16 |
# File 'lib/shipping_easy/http/faraday_adapter.rb', line 14 def connect! send(http_method) end |
#connection ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/shipping_easy/http/faraday_adapter.rb', line 32 def connection @connection ||= Faraday.new(url: base_url) do |faraday| faraday.use FaradayMiddleware::FollowRedirects, limit: 3, standards_compliant: true faraday.use CustomUserAgent, "shipping_easy-ruby/#{ShippingEasy::VERSION}" faraday.adapter Faraday.default_adapter end end |
#get ⇒ Object
25 26 27 28 29 30 |
# File 'lib/shipping_easy/http/faraday_adapter.rb', line 25 def get connection.get do |req| req.url uri, params req.body = request.body end end |
#post ⇒ Object
18 19 20 21 22 23 |
# File 'lib/shipping_easy/http/faraday_adapter.rb', line 18 def post connection.post do |req| req.url uri, params req.body = request.body end end |