class Veezi::API::Base

Attributes

api_path[RW]
client[R]
parser[R]

Public Class Methods

new(client) click to toggle source
# File lib/veezi/api/base.rb, line 10
def initialize(client)
  @client = client
  @parser = Veezi::API::Parser.new(self.client.configuration.content_type)
end

Public Instance Methods

all() click to toggle source
# File lib/veezi/api/base.rb, line 15
def all
  response = request(:get, self.base_url)
  self.parser.parse(response)
end
find(id) click to toggle source
# File lib/veezi/api/base.rb, line 20
def find(id)
  response = request(:get, "#{self.base_url}/#{id}")
  self.parser.parse(response)
end

Protected Instance Methods

access_token_header() click to toggle source
# File lib/veezi/api/base.rb, line 38
def access_token_header
  { "VeeziAccessToken" => self.client.configuration.api_key }
end
base_url() click to toggle source
# File lib/veezi/api/base.rb, line 34
def base_url
  "#{self.client.configuration.endpoint_url}/#{self.client.configuration.api_version}#{self.api_path}"
end
configuration() click to toggle source
# File lib/veezi/api/base.rb, line 26
def configuration
  self.client.configuration
end
content_type() click to toggle source
# File lib/veezi/api/base.rb, line 30
def content_type
  self.client.configuration.content_type || :json
end
request(method, url, options = {}) click to toggle source
# File lib/veezi/api/base.rb, line 42
def request(method, url, options = {})
  RestClient.send(method, url, options.merge({ :accept => self.content_type }.merge(access_token_header)))
end