5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/luo/http_client.rb', line 5
def self.init_client(options={})
Module.new do
define_method :client do
@client ||= Faraday.new(self.class.config.host, options) { |conn|
conn.request :authorization, 'Bearer', self.class.config.access_token if self.class.config.respond_to?(:access_token) && !self.class.config.access_token.nil?
conn.request :retry, max: (self.class.config.retries || 3), interval: 0.05,
interval_randomness: 0.5, backoff_factor: 2,
exceptions: [Faraday::TimeoutError, Faraday::ConnectionFailed]
conn.request :json
conn.response :json
}
end
end
end
|