Class: Ant::Client::Session::Base
- Inherits:
-
Object
- Object
- Ant::Client::Session::Base
- Includes:
- BasicAuth, HTTParty
- Defined in:
- lib/ant/client/session/base.rb
Instance Method Summary collapse
- #configure_request(request) ⇒ Object
-
#initialize(config) ⇒ Base
constructor
A new instance of Base.
- #perform_request(method, endpoint, data) ⇒ Object
- #register_ca ⇒ Object
- #register_certificate ⇒ Object
Methods included from BasicAuth
Constructor Details
#initialize(config) ⇒ Base
Returns a new instance of Base.
15 16 17 18 19 |
# File 'lib/ant/client/session/base.rb', line 15 def initialize(config) @config = config register_certificate register_ca end |
Instance Method Details
#configure_request(request) ⇒ Object
33 34 35 36 |
# File 'lib/ant/client/session/base.rb', line 33 def configure_request(request) basic_auth(request, @config[:basic_auth]) if @config[:basic_auth] request[:verify] = @config[:verify] if @config.key?(:verify) end |
#perform_request(method, endpoint, data) ⇒ Object
38 39 40 41 |
# File 'lib/ant/client/session/base.rb', line 38 def perform_request(method, endpoint, data) configure_request(data) self.class.send(method, endpoint, data) end |
#register_ca ⇒ Object
27 28 29 30 31 |
# File 'lib/ant/client/session/base.rb', line 27 def register_ca return unless @config[:ca_validate] puts @config[:ca_validate] self.class.ssl_ca_file(@config[:ca_validate]) end |
#register_certificate ⇒ Object
21 22 23 24 25 |
# File 'lib/ant/client/session/base.rb', line 21 def register_certificate return unless @config[:client_certificate] cert = File.read(@config[:client_certificate]) self.class.pkcs12(cert, @config[:client_certificate_pass]) end |