Class: DangerBoss::Driver::Http
- Inherits:
-
Object
- Object
- DangerBoss::Driver::Http
- Includes:
- Base
- Defined in:
- lib/danger_boss/driver/http.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #get(path:, params: {}) ⇒ Object
-
#initialize(base_url:, username: nil, password: nil) ⇒ Http
constructor
A new instance of Http.
Constructor Details
#initialize(base_url:, username: nil, password: nil) ⇒ Http
Returns a new instance of Http.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/danger_boss/driver/http.rb', line 16 def initialize(base_url:, username: nil, password: nil) @base_url = base_url @username = username @password = password @raw = Faraday.new(url: base_url) do |faraday| if username && password faraday.basic_auth(username, password) end faraday.headers.merge!( { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'User-Agent' => "danger_boss/#{VERSION} (https://github.com/ess/danger_boss)", } ) faraday.request :url_encoded faraday.adapter Faraday.default_adapter end end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
14 15 16 |
# File 'lib/danger_boss/driver/http.rb', line 14 def raw @raw end |
Instance Method Details
#get(path:, params: {}) ⇒ Object
38 39 40 41 |
# File 'lib/danger_boss/driver/http.rb', line 38 def get(path:, params: {}) Try() {raw.get(path, params)}. bind {|response| process_response(response)} end |