Sha256: 40b8dcd63f2843fdc99576f25153ce6ff4cc3fd5979c2d93d579c2a79b90ebf7

Contents?: true

Size: 842 Bytes

Versions: 4

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

require 'loogi_http'
require 'loogi_http/connection'

module WeShipClient
  class Client
    DEFAULT_TIMEOUT = 90

    attr_reader :http_client, :logger

    # @param http_client [LoogiHttp::Connection]
    # @param logger [Logger]
    # @param timeout [Integer,nil] The request timeout
    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.options[:open_timeout] = timeout
          connection.options[:timeout] = timeout
        end
      )
      @logger = logger
    end

    def base_url
      ENV['WE_SHIP_BASE_URL']
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
we_ship_client-1.2.0 lib/we_ship_client/client.rb
we_ship_client-1.1.1 lib/we_ship_client/client.rb
we_ship_client-1.1.0 lib/we_ship_client/client.rb
we_ship_client-1.0.0 lib/we_ship_client/client.rb