From 9f5b7c560835d39eebbaff1c74a79077181ca1af Mon Sep 17 00:00:00 2001 From: Encore Shao Date: Fri, 26 Jun 2020 15:09:07 +0800 Subject: [PATCH] MISC #6 - Add examples code to get the rounds found of the organization through paging --- CHANGELOG.md | 14 +++++++------- README.md | 18 ++++++++++++++---- lib/crunchbase.rb | 2 +- lib/crunchbase/models/concerns/entity.rb | 7 ++++++- lib/crunchbase/models/organization.rb | 9 +++++++++ spec/entities/client_spec.rb | 1 + 6 files changed, 38 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c8f5f8..a72c86e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,12 +9,12 @@ * After - Get organzation's fund: (`client.organization(entity_id, card_id: 'fund')`) - Method for uniformly obtaining deleted entities data and support more query condition - * Get deleted organzations - - Before: (`client.deleted_organzations`) + * Get deleted organizations + - Before: (`client.deleted_organizations`) - After : (`client.deleted_entities(collection_ids: 'organizations', limit: 20)`) - Method for uniformly obtaining autocompletes entities data and support more query condition - * Get autocompletes organzations - - Before: (`client.autocomplete_organzations`) + * Get autocompletes organizations + - Before: (`client.autocomplete_organizations`) - After : (`client.autocomplete('ekohe', collection_ids: 'organizations', limit: 3)`) ## [0.1.4] - 2020-06-12 @@ -38,11 +38,11 @@ ### Added - Implemented searches APIs to get the recent updates entities on Search - - organzations + - organizations - people - funding rounds - Implemented `autocompletes` API to allow user filter entities by keyword - - organzations + - organizations - people - funding rounds @@ -50,7 +50,7 @@ ### Added - Implemented APIs to get acquisition and investment of Entity -- Implemented APIs to search organzations and funding rounds of Search +- Implemented APIs to search organizations and funding rounds of Search ### Changed - Refactor the API client to support search API diff --git a/README.md b/README.md index 4daa038..9e1b47e 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ pry(main)> client = Crunchbase::Client.new - [Deleted Entities](https://github.com/ekohe/crunchbase4#deleted-entities) ```ruby - + response = client.organization('ekohe') ipos = client.organization('ekohe', card_id: 'ipos') fund = client.organization('ekohe', card_id: 'fund') @@ -67,15 +67,25 @@ jobs = client.organization('ekohe', card_id: 'jobs') headquarters_address = client.organization('ekohe', card_id: 'headquarters_address') top_2_press_references = client.organization('ekohe', card_id: 'press_references', limit: 2) + +response = client.organization( + 'facebook', card_id: 'participated_funding_rounds', + limit: 5, + order: 'announced_on:desc', + after_id: '3cdfcecd-5377-439b-acab-cefcf6fe21a5' +) + + + response = client.person('mark-zuckerberg') response = client.person('mark-zuckerberg', card_id: 'participated_investments') -response = client.funding_round('371c20af8aa94bcba8da0694d138f247') -response = client.funding_round('371c20af8aa94bcba8da0694d138f247', card_id: 'investors') +response = client.funding_round('3cdfcecd-5377-439b-acab-cefcf6fe21a5') +response = client.funding_round('3cdfcecd-5377-439b-acab-cefcf6fe21a5', card_id: 'investors') response = client.acquisition('7638eae9-07b7-4fc6-ad20-5d99de3ff928') response = client.fund('aeaac12b-df56-7039-40f9-f1992f88e20e') response = client.ownership('4506d9ce-85d3-4a8f-89cd-07a225359d55') - + response.as_json diff --git a/lib/crunchbase.rb b/lib/crunchbase.rb index d5828f9..78673af 100644 --- a/lib/crunchbase.rb +++ b/lib/crunchbase.rb @@ -17,7 +17,7 @@ module Crunchbase # Defined Veriables for the data Category or Types # # Crunchbase::Utils.constants => [ - # :OPERATING_STATUS, + # :OPERATING_STATUS, # :PROGRAM_TYPES, # :REVENUE_RANGES, # :COMPANY_TYPES, diff --git a/lib/crunchbase/models/concerns/entity.rb b/lib/crunchbase/models/concerns/entity.rb index 6f9741c..c8704d6 100644 --- a/lib/crunchbase/models/concerns/entity.rb +++ b/lib/crunchbase/models/concerns/entity.rb @@ -12,7 +12,7 @@ class Entity include Mappings def fields - field_ids.map(&:to_sym) + field_ids.concat(custom_fields).map(&:to_sym) end def parse_response(response, request_field_ids = [], cards = []) @@ -43,6 +43,11 @@ def setup_relationships(object, request_card_ids, response_cards) def as_json fields.each_with_object({}) { |item, hash| hash[item] = send(item) } end + + private + def custom_fields + [] + end end end end diff --git a/lib/crunchbase/models/organization.rb b/lib/crunchbase/models/organization.rb index e896d66..7fd51b5 100644 --- a/lib/crunchbase/models/organization.rb +++ b/lib/crunchbase/models/organization.rb @@ -134,6 +134,15 @@ def full_cards headquarters_address ] end + + def employees_range + Crunchbase::Utils::NUM_EMPLOYEES_ENUM[num_employees_enum] + end + + private + def custom_fields + %w[employees_range] + end end end end diff --git a/spec/entities/client_spec.rb b/spec/entities/client_spec.rb index 18597b9..e7c20b6 100644 --- a/spec/entities/client_spec.rb +++ b/spec/entities/client_spec.rb @@ -39,6 +39,7 @@ expect(org.num_founders).to eq(1) expect(org.num_event_appearances).to eq(1) expect(org.num_employees_enum).to eq('c_00011_00050') + expect(org.employees_range).to eq('11-50') expect(org.num_current_positions).to eq(1) expect(org.name).to eq('Ekohe') expect(org.identifier).to eq(%w[9fe491b2-b6a1-5c87-0f4d-226dd0cc97a9 Ekohe ekohe])