Method: Idoklad::ApiRequest.post

Defined in:
lib/idoklad/api_request.rb

.post(path, object) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/idoklad/api_request.rb', line 14

def self.post(path, object)
  @token ||= Idoklad::Auth.get_token

  uri = URI.parse("#{Idoklad::API_URL}#{path}")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.post(uri.request_uri, JSON.generate(object), {'Authorization' => "Bearer #{@token}", 'Content-type' => 'application/json'})
end