class TutumApi

Constants

API_VERSION
BASE_API_PATH

Attributes

headers[R]

Public Class Methods

new(headers) click to toggle source
# File lib/tutum_api.rb, line 9
def initialize(headers)
  @headers = headers
end

Public Instance Methods

http_delete(path) click to toggle source
# File lib/tutum_api.rb, line 35
def http_delete(path)
  response = RestClient.delete(url(path), headers)
  JSON.parse(response)
end
http_get(path, params={}) click to toggle source
# File lib/tutum_api.rb, line 17
def http_get(path, params={})
  query =  "?" + params.map { |k,v| "#{k}=#{v}"}.join("&")
  full_path = path
  full_path += query unless params.empty?
  response = RestClient.get(url(full_path), headers)
  JSON.parse(response)
end
http_patch(path, content={}) click to toggle source
# File lib/tutum_api.rb, line 30
def http_patch(path, content={})
  response = RestClient.patch(url(path), content.to_json, headers)
  JSON.parse(response)
end
http_post(path, content={}) click to toggle source
# File lib/tutum_api.rb, line 25
def http_post(path, content={})
  response = RestClient.post(url(path), content.to_json, headers)
  JSON.parse(response)
end
url(path) click to toggle source
# File lib/tutum_api.rb, line 13
def url(path)
  BASE_API_PATH + '/' + API_VERSION + path
end