Class: Crunchbase::API

Inherits:
Object
  • Object
show all
Defined in:
lib/crunchbase/api.rb

Overview

Handles the actual calls to the Crunchbase API through a series of class methods, each referring to a CB entity type. Each method returns the raw JSON returned from the API. You should probably be using the factory methods provided on each entity class instead of calling these directly.

Constant Summary collapse

CB_URL =
'http://api.crunchbase.com/v/1/'
SUPPORTED_ENTITIES =
['person', 'company', 'financial-organization', 'product', 'service-provider']

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.keyObject

Returns the value of attribute key.



23
24
25
# File 'lib/crunchbase/api.rb', line 23

def key
  @key
end

.redirect_limitObject

Returns the value of attribute redirect_limit.



23
24
25
# File 'lib/crunchbase/api.rb', line 23

def redirect_limit
  @redirect_limit
end

.timeout_limitObject

Returns the value of attribute timeout_limit.



23
24
25
# File 'lib/crunchbase/api.rb', line 23

def timeout_limit
  @timeout_limit
end

Class Method Details

.all(entity) ⇒ Object



30
31
32
33
# File 'lib/crunchbase/api.rb', line 30

def self.all(entity)
  uri = CB_URL + entity + ".js"
  get_json_response(uri)
end

.single_entity(permalink, entity_name) ⇒ Object

Raises:



25
26
27
28
# File 'lib/crunchbase/api.rb', line 25

def self.single_entity(permalink, entity_name)
  raise CrunchException, "Unsupported Entity Type" unless SUPPORTED_ENTITIES.include?(entity_name)
  fetch(permalink, entity_name)
end