class KOSapiClient::HTTPClient
Public Class Methods
new(http_adapter, preprocessor = ResponsePreprocessor.new, converter = ResponseConverter.new(self))
click to toggle source
# File lib/kosapi_client/http_client.rb, line 4 def initialize(http_adapter, preprocessor = ResponsePreprocessor.new, converter = ResponseConverter.new(self)) @http_adapter = http_adapter @preprocessor = preprocessor @converter = converter end
Public Instance Methods
get_absolute_url(url)
click to toggle source
# File lib/kosapi_client/http_client.rb, line 22 def get_absolute_url(url) if is_absolute(url) url else "#{@http_adapter.base_url}/#{url}" end end
process_response(result)
click to toggle source
# File lib/kosapi_client/http_client.rb, line 16 def process_response(result) preprocessed = @preprocessor.preprocess(result) response = KOSapiClient::KOSapiResponse.new(preprocessed) @converter.convert(response) end
send_request(verb, url, options = {})
click to toggle source
# File lib/kosapi_client/http_client.rb, line 10 def send_request(verb, url, options = {}) absolute_url = get_absolute_url(url) result = @http_adapter.send_request(verb, absolute_url, options) process_response(result) end
Private Instance Methods
is_absolute(url)
click to toggle source
# File lib/kosapi_client/http_client.rb, line 31 def is_absolute(url) url.start_with?('http') end