class Crunchbase::Entities::Client
using Crunchbase's Entity Lookup API endpoints
Constants
- ROOT_LIST
Public Class Methods
new(entity_id, entity_type)
click to toggle source
# File lib/crunchbase/entities/client.rb, line 16 def initialize(entity_id, entity_type) @entity_id = entity_id @entity_type = entity_type end
Public Instance Methods
cards(card_id, **args)
click to toggle source
Auto combine the card num field to request field_ids
Example: if card_id is investors, will auto add num_investors
# File lib/crunchbase/entities/client.rb, line 41 def cards(card_id, **args) raise Crunchbase::Error, 'Invalid card_id' unless cbobject.full_cards.include?(card_id) field_ids = cbobject.basis_fields.concat(cbobject.card_num_field(card_id)) request_args = args.merge( field_ids: field_ids.join(','), card_field_ids: cbobject.model_mappings[card_id].new.field_ids.join(',') ) cbobject.parse_response(entity( entity_request_uri(name: __method__, card_id: card_id), request_args ), field_ids, [card_id]) end
fetch()
click to toggle source
Will include all attribute from API document
# File lib/crunchbase/entities/client.rb, line 22 def fetch cbobject.parse_response(entity( entity_request_uri, field_ids: cbobject.field_ids.join(',') )) end
fetch_cards(card_names = [])
click to toggle source
Only include a part basis fields of endpoint
# File lib/crunchbase/entities/client.rb, line 30 def fetch_cards(card_names = []) cbobject.parse_response(entity( entity_request_uri, field_ids: cbobject.basis_fields.join(','), cards: (cbobject.full_cards & card_names).join(',') ), cbobject.basis_fields, card_names) end
Private Instance Methods
entity_request_uri(**args)
click to toggle source
# File lib/crunchbase/entities/client.rb, line 58 def entity_request_uri(**args) [ ROOT_LIST, kclass_name::RESOURCE_LIST, @entity_id, args[:name], args[:card_id] ].compact.join('/') end