class Crunchbase::Searches::Client
Send request for entities endpoints
API doc:
https://app.swaggerhub.com/apis-docs/Crunchbase/crunchbase-enterprise_api/1.0.1#/Search/post_searches_organizations
Notes
1. Only can filter `Searchable: Yes` fields 2. 'name', 'website' can not use
Constants
- LIMIT
- ROOT_LIST
Attributes
conditions[RW]
count[RW]
entities[RW]
entity_type[RW]
total_count[RW]
Public Class Methods
new(conditions, entity_type)
click to toggle source
# File lib/crunchbase/searches/client.rb, line 26 def initialize(conditions, entity_type) @conditions = conditions @entity_type = entity_type end
Public Instance Methods
searches()
click to toggle source
Will include all attribute from API document
# File lib/crunchbase/searches/client.rb, line 32 def searches wrapping!( search( root_uri, data_raw.to_s.gsub('=>', ':') ) ) end
Private Instance Methods
data_raw()
click to toggle source
# File lib/crunchbase/searches/client.rb, line 71 def data_raw { 'field_ids' => field_ids, 'order' => @conditions['order'], 'query' => @conditions['query'], 'limit' => limit } end
field_ids()
click to toggle source
Post request raw datas
# File lib/crunchbase/searches/client.rb, line 63 def field_ids @conditions['field_ids'] || cbobject.basis_fields end
limit()
click to toggle source
# File lib/crunchbase/searches/client.rb, line 67 def limit @conditions['limit'] || LIMIT end
root_uri()
click to toggle source
# File lib/crunchbase/searches/client.rb, line 58 def root_uri [ROOT_LIST, kclass_name::RESOURCE_LIST].compact.join('/') end
search_results(entities)
click to toggle source
# File lib/crunchbase/searches/client.rb, line 52 def search_results(entities) entities.each_with_object([]) do |entity, objects| objects << cbobject.parse_response(entity, field_ids) end end
wrapping!(response)
click to toggle source
# File lib/crunchbase/searches/client.rb, line 43 def wrapping!(response) query_results = search_results(response.dig('entities')) self.total_count = response['count'] self.entities = query_results self.count = query_results.size self end