class Crunchbase::Model::BatchSearch
Attributes
items[R]
results[R]
Public Class Methods
batch_search(requests)
click to toggle source
# File lib/crunchbase/model/batch_search.rb, line 29 def self.batch_search(requests) raise ConfigurationException, 'Invalid argument. Please pass in an array as an argument' unless requests.is_a?(Array) raise InvalidRequestException, "Too many requests(#{requests.length}) in batch, max allowed 10" if requests.length > 10 raise MissingParamsException, 'Missing :type or :uuid parameter in some requests' if requests.any? { |request| !request.key?(:type) || !request.key?(:uuid) } return [] if requests.empty? BatchSearch.new API.batch_search(requests) end
new(json)
click to toggle source
# File lib/crunchbase/model/batch_search.rb, line 12 def initialize(json) @results = [] populate_results(json) end
Public Instance Methods
populate_results(json)
click to toggle source
# File lib/crunchbase/model/batch_search.rb, line 18 def populate_results(json) @results = [] @results = json['items'].map do |r| next Error.new(r['error']) if r.key?('error') kclass = kclass_name(r['type']) kclass.new(r) end end
Private Instance Methods
kclass_name(model_name)
click to toggle source
# File lib/crunchbase/model/batch_search.rb, line 40 def kclass_name(model_name) self.class.kclass_name(model_name.downcase) end