class Crunchbase::Organization

Attributes

metadata[RW]

Public Class Methods

all(options = {}) click to toggle source
# File lib/crunchbase/organization.rb, line 27
def self.all(options = {})
  opts = options.merge({user_key: Crunchbase.config.user_key})
  response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/organizations", opts)

  raise "Error" if response.status != 200

  # ignore paging
  raw = Hashie::Mash.new(JSON.parse(response.body))
  collection = raw.data.items
  collection.map { |item| new(item, raw.metadata) }
rescue => e
  []
end
find(permalink) click to toggle source
# File lib/crunchbase/organization.rb, line 41
def self.find(permalink)
  response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/organization/#{permalink}", user_key: Crunchbase.config.user_key)

  raise "Error" if response.status != 200

  raw = Hashie::Mash.new(JSON.parse(response.body))

  new(raw.data, raw.metadata)
rescue
  nil
end
new(data, meta) click to toggle source
# File lib/crunchbase/organization.rb, line 10
def initialize(data, meta)
  @mash = data
  self.metadata = meta
end

Public Instance Methods

load_details() click to toggle source
# File lib/crunchbase/organization.rb, line 19
def load_details
  if properties
    return self
  else
    Organization.find(path.sub("organization/", ''))
  end
end
method_missing(method_sym, *arguments, &block) click to toggle source
# File lib/crunchbase/organization.rb, line 15
def method_missing(method_sym, *arguments, &block)
  @mash.send(method_sym, *arguments)
end