lib/crunchbase/api.rb in crunchbase_v2-0.0.9 vs lib/crunchbase/api.rb in crunchbase_v2-1.0.0
- old
+ new
@@ -11,11 +11,11 @@
require 'timeout'
module Crunchbase
class API
- SUPPORTED_ENTITIES = ['organizations', 'organization', 'people', 'person', 'products', 'product', 'funding_rounds', 'funding-round', 'acquisition', 'ipo', 'fund-raise', 'locations', 'categories', 'offices', 'customers']
+ SUPPORTED_ENTITIES = ['organizations', 'organization', 'people', 'person', 'products', 'product', 'funding_rounds', 'funding-round', 'acquisition', 'ipo', 'fund-raise', 'locations', 'categories', 'offices', 'customers', 'degrees', 'experience', 'primary_affiliation', 'videos', 'founded_companies', 'primary_location', 'advisor_at']
@timeout_limit = 60
@redirect_limit = 2
@version = '2'
@base_url = 'https://api.crunchbase.com'
@@ -95,16 +95,30 @@
options.map{|k,v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
end
# Searches for a permalink in a particular category.
- # Demo: http://api.crunchbase.com/v/2/organization/facebook/offices?user_key=key
+ # Demo: https://api.crunchbase.com/v/2/organization/#{organization-permalink}/offices?user_key=key
def self.lists_for_permalink(permalink, category, options)
+ lists_for_category('organization', permalink, category, options)
+ end
+
+ # Demo: https://api.crunchbase.com/v/2/person/#{person-permalink}/offices?user_key=key
+ def self.lists_for_person_permalink(permalink, category, options)
+ lists_for_category('person', permalink, category, options)
+ end
+
+ class << self
+ alias_method :category_lists_by_organization, :lists_for_permalink
+ alias_method :category_lists_by_person, :lists_for_person_permalink
+ end
+
+ def self.lists_for_category(classify_name, permalink, category, options)
options[:page] = 1 if options[:page].nil?
options[:order] = ORDER_CREATED_AT_ASC if options[:order].nil?
model_name = options.delete(:model_name)
- uri = api_url + "organization/#{permalink}/#{category}?#{collect_parameters(options)}"
+ uri = api_url + "#{classify_name}/#{permalink}/#{category}?#{collect_parameters(options)}"
Search.new options, get_json_response(uri), model_name
end
# Gets specified URI, then parses the returned JSON. Raises Timeout error