Class: SplitIoClient::Api::Client
- Inherits:
-
Object
- Object
- SplitIoClient::Api::Client
show all
- Defined in:
- lib/splitclient-rb/engine/api/client.rb
Constant Summary
collapse
- RUBY_ENCODING =
'1.9'.respond_to?(:force_encoding)
Instance Method Summary
collapse
Instance Method Details
#get_api(url, config, api_key, params = {}) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/splitclient-rb/engine/api/client.rb', line 8
def get_api(url, config, api_key, params = {})
api_client.get(url, params) do |req|
req. = (api_key, config).merge('Accept-Encoding' => 'gzip')
req.options[:timeout] = config.read_timeout
req.options[:open_timeout] = config.connection_timeout
config.logger.debug("GET #{url} proxy: #{api_client.proxy}") if config.debug_enabled
end
rescue StandardError => e
config.logger.warn("#{e}\nURL:#{url}\nparams:#{params}")
false
end
|
#post_api(url, config, api_key, data, headers = {}, params = {}) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/splitclient-rb/engine/api/client.rb', line 23
def post_api(url, config, api_key, data, = {}, params = {})
api_client.post(url) do |req|
req. = (api_key, config)
.merge('Content-Type' => 'application/json')
.merge()
req.body = data.to_json
req.options[:timeout] = config.read_timeout
req.options[:open_timeout] = config.connection_timeout
if config.transport_debug_enabled
config.logger.debug("POST #{url} #{req.body}")
elsif config.debug_enabled
config.logger.debug("POST #{url}")
end
end
rescue StandardError => e
config.logger.warn("#{e}\nURL:#{url}\ndata:#{data}\nparams:#{params}")
false
end
|