Module: Idoklad::ApiRequest
- Defined in:
- lib/idoklad/api_request.rb
Class Method Summary collapse
Class Method Details
.get(path) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/idoklad/api_request.rb', line 5 def self.get(path) @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.get(uri.request_uri, {'Authorization' => "Bearer #{@token}"}) end |
.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 |