Class: WeShipClient::Client
- Inherits:
-
Object
- Object
- WeShipClient::Client
- Defined in:
- lib/we_ship_client/client.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_TIMEOUT =
90
Instance Attribute Summary collapse
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #base_url ⇒ Object
-
#initialize(http_client: LoogiHttp::Connection, logger: LoogiHttp.logger, timeout: nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(http_client: LoogiHttp::Connection, logger: LoogiHttp.logger, timeout: nil) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/we_ship_client/client.rb', line 15 def initialize(http_client: LoogiHttp::Connection, logger: LoogiHttp.logger, timeout: nil) timeout ||= DEFAULT_TIMEOUT @http_client = http_client.new( Faraday::Connection.new do |connection| connection.request :json connection.adapter Faraday.default_adapter connection.[:open_timeout] = timeout connection.[:timeout] = timeout end ) @logger = logger end |
Instance Attribute Details
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
10 11 12 |
# File 'lib/we_ship_client/client.rb', line 10 def http_client @http_client end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
10 11 12 |
# File 'lib/we_ship_client/client.rb', line 10 def logger @logger end |
Instance Method Details
#base_url ⇒ Object
29 30 31 |
# File 'lib/we_ship_client/client.rb', line 29 def base_url ENV['WE_SHIP_BASE_URL'] end |