Class: TestDots::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/test_dots/api.rb

Instance Method Summary collapse

Instance Method Details

#post(payload) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/test_dots/api.rb', line 5

def post(payload)
  http = Net::HTTP.new(TestDots.configuration.host, TestDots.configuration.port)
  if TestDots.configuration.use_ssl
    http.use_ssl = true
    http.ca_file = TestDots.configuration.cacert_path
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER
  else
    http.use_ssl = false
  end
  request = Net::HTTP::Post.new(TestDots.configuration.endpoint, 'Content-Type' => 'application/json')
  request.basic_auth(TestDots.configuration.api_key, "")
  request.body = payload
  http.request(request)
end