module Noteshred::API

Public Class Methods

get(rel,params = nil) click to toggle source
# File lib/noteshred/api.rb, line 10
def self.get(rel,params = nil)
  response = RestClient.get(Noteshred.url(rel), {:params => params, :authorization => "Token token=#{Noteshred.api_key}"}){|response, request, result| response }
  Noteshred::API.render(response)
end
post(rel,params = nil) click to toggle source
# File lib/noteshred/api.rb, line 15
def self.post(rel,params = nil)
  response = RestClient.post(Noteshred.url(rel), params, {:authorization => "Token token=#{Noteshred.api_key}", :content_type => :json, :accept => :json}){|response, request, result| response }
  Noteshred::API.render(response)
end
render(response) click to toggle source
# File lib/noteshred/api.rb, line 20
def self.render(response)
  JSON.parse(response)
rescue JSON::ParserError => err
  {:error => err.message}
rescue StandardError
  {:error => 'Error parsing response'}
end