module Idoklad::ApiRequest
Public Class Methods
get(path)
click to toggle source
# 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)
click to toggle source
# 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