Sha256: f6504dd1dbaaa99fb7317b2d53952684d7cfc33b93d9b84d86ef13f6c91f982a
Contents?: true
Size: 775 Bytes
Versions: 2
Compression:
Stored size: 775 Bytes
Contents
require 'faraday' require 'json' require 'hashie' module Crunchbase class Category attr_accessor :metadata def initialize(data, meta) @mash = data self.metadata = meta end def method_missing(method_sym, *arguments, &block) @mash.send(method_sym, *arguments) end def self.all(options = {}) opts = options.merge({user_key: Crunchbase.config.user_key}) response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/categories", 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 [] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
crunchbase-wrapper-0.0.2 | lib/crunchbase/category.rb |
crunchbase-wrapper-0.0.1 | lib/crunchbase/category.rb |