Skip to content

Commit

Permalink
MISC #6 - Add examples code to get the rounds found of the organizati…
Browse files Browse the repository at this point in the history
…on through paging
  • Loading branch information
encoreshao committed Jun 26, 2020
1 parent d60c13c commit 9f5b7c5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,19 +38,19 @@

### 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

## [0.1.1] - 2020-06-06

### 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
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pry(main)> client = Crunchbase::Client.new
- [Deleted Entities](https://github.com/ekohe/crunchbase4#deleted-entities)

```ruby
<!-- Entity and Single Card -->
<!-- Examples of organization and single card -->
response = client.organization('ekohe')
ipos = client.organization('ekohe', card_id: 'ipos')
fund = client.organization('ekohe', card_id: 'fund')
Expand All @@ -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)

<!-- Examples to get the funding rounds of the organization through paging -->
response = client.organization(
'facebook', card_id: 'participated_funding_rounds',
limit: 5,
order: 'announced_on:desc',
after_id: '3cdfcecd-5377-439b-acab-cefcf6fe21a5'
)

<!-- Examples of person and single card -->

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')

<!-- Get the JSON response of Entity -->
<!-- Get the JSON response of entity -->

response.as_json

Expand Down
2 changes: 1 addition & 1 deletion lib/crunchbase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion lib/crunchbase/models/concerns/entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [])
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions lib/crunchbase/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions spec/entities/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 9f5b7c5

Please sign in to comment.