Class: Crunchbase::Entities::Client
- Inherits:
-
Object
- Object
- Crunchbase::Entities::Client
- Includes:
- Utilities::CbModel, Utilities::Request
- Defined in:
- lib/crunchbase/entities/client.rb
Overview
using Crunchbase’s Entity Lookup API endpoints
Constant Summary collapse
- ROOT_LIST =
'entities'
Instance Attribute Summary
Attributes included from Utilities::CbModel
Instance Method Summary collapse
-
#cards(card_id, **args) ⇒ Object
Auto combine the card num field to request field_ids.
-
#fetch ⇒ Object
Will include all attribute from API document.
-
#fetch_cards(card_names = []) ⇒ Object
Only include a part basis fields of endpoint.
-
#initialize(entity_id, entity_type) ⇒ Client
constructor
A new instance of Client.
Methods included from Utilities::CbModel
cbobject, exact_kclass_object, kclass_name
Methods included from Utilities::Request
Constructor Details
#initialize(entity_id, entity_type) ⇒ Client
Returns a new instance of Client.
16 17 18 19 |
# File 'lib/crunchbase/entities/client.rb', line 16 def initialize(entity_id, entity_type) @entity_id = entity_id @entity_type = entity_type end |
Instance Method Details
#cards(card_id, **args) ⇒ Object
Auto combine the card num field to request field_ids
Example: if card_id is investors, will auto add num_investors
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# 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 ⇒ Object
Will include all attribute from API document
22 23 24 25 26 27 |
# 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 = []) ⇒ Object
Only include a part basis fields of endpoint
30 31 32 33 34 35 36 |
# 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 |