Module: Scalarium::Api
Defined Under Namespace
Classes: TokenNotFound
Instance Method Summary collapse
Instance Method Details
#get(resource) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/scalarium/api.rb', line 6 def get(resource) raise TokenNotFound unless @token $stderr.puts "Getting #{resource}" if $DEBUG url = "https://manage.scalarium.com/api/#{resource}" headers = { 'X-Scalarium-Token' => @token, 'Accept' => 'application/vnd.scalarium-v1+json' } response = RestClient.get(url, headers) JSON.parse(response) end |
#post(resource, data) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/scalarium/api.rb', line 18 def post(resource, data) raise TokenNotFound unless @token $stderr.puts "Posting #{data.inspect} to #{resource}" if $DEBUG url = "https://manage.scalarium.com/api/#{resource}" headers = { 'X-Scalarium-Token' => @token, 'Accept' => 'application/vnd.scalarium-v1+json' } response = RestClient.post(url, JSON.dump(data), headers) JSON.parse(response) end |