Sha256: 72b8294fb93b1ed2ce9661da411a2fa9b6957f16c645df029b3eaace37cc983f

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

require 'faraday'
require 'json'
require 'hashie'

module Crunchbase
  class IPO

    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.find(uuid)
      response = Faraday.get("#{Crunchbase.config.host}/#{Crunchbase.config.api_version_prefix}/ipo/#{uuid}", 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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
crunchbase-wrapper-0.0.2 lib/crunchbase/i_p_o.rb
crunchbase-wrapper-0.0.1 lib/crunchbase/i_p_o.rb