Module: Rapidash::HTTPClient
- Defined in:
- lib/rapidash/http_client.rb
Instance Attribute Summary collapse
- #connection ⇒ Object
-
#login ⇒ Object
Returns the value of attribute login.
-
#password ⇒ Object
Returns the value of attribute password.
Instance Method Summary collapse
Instance Attribute Details
#connection ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rapidash/http_client.rb', line 16 def connection raise ConfigurationError.new "Site is required" unless site @connection ||= Faraday.new(site) do |builder| if login || password builder.use Faraday::Request::BasicAuthentication, login, password end connection_builder.call(builder) end end |
#login ⇒ Object
Returns the value of attribute login.
7 8 9 |
# File 'lib/rapidash/http_client.rb', line 7 def login @login end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/rapidash/http_client.rb', line 7 def password @password end |
Instance Method Details
#initialize(options = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/rapidash/http_client.rb', line 10 def initialize( = {}) [:login, :password].each do |key| self.send("#{key.to_s}=".to_sym, [key]) end end |
#request(verb, url, options = {}) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/rapidash/http_client.rb', line 28 def request(verb, url, = {}) url = connection.build_url(normalize_url(url), [:params]).to_s response = connection.run_request(verb, url, [:body], [:header]) response.body end |