Class: Ant::Client::Session::Base

Inherits:
Object
  • Object
show all
Includes:
BasicAuth, HTTParty
Defined in:
lib/ant/client/session/base.rb

Instance Method Summary collapse

Methods included from BasicAuth

#basic_auth

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_caObject



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_certificateObject



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