crunchbase4 0.1.3 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +42 -4
- data/Gemfile.lock +1 -1
- data/README.md +177 -26
- data/crunchbase4.gemspec +1 -1
- data/lib/crunchbase.rb +1 -1
- data/lib/crunchbase/entities/client.rb +18 -10
- data/lib/crunchbase/models.rb +7 -1
- data/lib/crunchbase/models/address.rb +36 -0
- data/lib/crunchbase/models/concerns/entity.rb +54 -0
- data/lib/crunchbase/models/concerns/mappings.rb +37 -0
- data/lib/crunchbase/models/event_appearance.rb +39 -0
- data/lib/crunchbase/models/fund.rb +43 -0
- data/lib/crunchbase/models/funding_round.rb +1 -0
- data/lib/crunchbase/models/job.rb +42 -0
- data/lib/crunchbase/models/organization.rb +10 -0
- data/lib/crunchbase/models/ownership.rb +39 -0
- data/lib/crunchbase/models/principal.rb +112 -0
- data/lib/crunchbase/utilities/autocomplete.rb +5 -20
- data/lib/crunchbase/utilities/deleted_entities.rb +4 -20
- data/lib/crunchbase/utilities/entity_endpoints.rb +40 -16
- data/lib/crunchbase/utilities/request.rb +6 -2
- data/lib/crunchbase/utilities/response.rb +23 -1
- data/lib/crunchbase/utilities/veriables.rb +1 -1
- data/lib/crunchbase/version.rb +1 -1
- metadata +14 -7
- data/lib/crunchbase/models/entity.rb +0 -72
@@ -33,33 +33,18 @@ module Crunchbase
|
|
33
33
|
# query: keyword,
|
34
34
|
# collection_ids: 'organizations'
|
35
35
|
# }
|
36
|
-
def
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def autocomplete_people(keyword)
|
41
|
-
autocompletes(wrapper_autocompletes_data(keyword, 'people'))
|
42
|
-
end
|
43
|
-
|
44
|
-
def autocomplete_funding_rounds(keyword)
|
45
|
-
autocompletes(wrapper_autocompletes_data(keyword, 'funding_rounds'))
|
46
|
-
end
|
47
|
-
|
48
|
-
def autocomplete_press_references(keyword)
|
49
|
-
autocompletes(wrapper_autocompletes_data(keyword, 'press_references'))
|
36
|
+
def autocomplete(keyword, **args)
|
37
|
+
crunchbase_autocompletes(wrapper_autocompletes_data(keyword, args))
|
50
38
|
end
|
51
39
|
|
52
40
|
private
|
53
41
|
|
54
|
-
def
|
42
|
+
def crunchbase_autocompletes(raw_data)
|
55
43
|
Crunchbase::Autocompletes::Client.new(raw_data).autocompletes
|
56
44
|
end
|
57
45
|
|
58
|
-
def wrapper_autocompletes_data(keyword,
|
59
|
-
{
|
60
|
-
query: keyword,
|
61
|
-
collection_ids: collection_ids
|
62
|
-
}
|
46
|
+
def wrapper_autocompletes_data(keyword, **args)
|
47
|
+
{ query: keyword }.merge(args)
|
63
48
|
end
|
64
49
|
end
|
65
50
|
end
|
@@ -33,30 +33,14 @@ module Crunchbase
|
|
33
33
|
# deleted_at_order: string
|
34
34
|
# Direction of sorting by deleted_at property
|
35
35
|
# Available values : asc, desc
|
36
|
-
def
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def deleted_people(args = {})
|
41
|
-
deleted_entities(wrapper_deleted_entities_data(args, 'people'))
|
42
|
-
end
|
43
|
-
|
44
|
-
def deleted_funding_rounds(args = {})
|
45
|
-
deleted_entities(wrapper_deleted_entities_data(args, 'funding_rounds'))
|
46
|
-
end
|
47
|
-
|
48
|
-
def deleted_press_references(args = {})
|
49
|
-
deleted_entities(wrapper_deleted_entities_data(args, 'press_references'))
|
36
|
+
def deleted_entities(**args)
|
37
|
+
crunchbase_deleted_entities(args)
|
50
38
|
end
|
51
39
|
|
52
40
|
private
|
53
41
|
|
54
|
-
def
|
55
|
-
Crunchbase::DeletedEntities::Client.new(
|
56
|
-
end
|
57
|
-
|
58
|
-
def wrapper_deleted_entities_data(args, collection_ids = nil)
|
59
|
-
args.merge!(collection_ids: collection_ids)
|
42
|
+
def crunchbase_deleted_entities(args)
|
43
|
+
Crunchbase::DeletedEntities::Client.new(args).deleted_entities
|
60
44
|
end
|
61
45
|
end
|
62
46
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../errors'
|
4
|
+
|
3
5
|
module Crunchbase
|
4
6
|
# Utilities
|
5
7
|
module Utilities
|
@@ -15,8 +17,8 @@ module Crunchbase
|
|
15
17
|
# limit: Number of rows to return. Default is 100, min is 1, max is 100.
|
16
18
|
|
17
19
|
# Lookup an Organization or single card
|
18
|
-
def organization(entity_id,
|
19
|
-
lookup_for('organization', entity_id,
|
20
|
+
def organization(entity_id, **card_args)
|
21
|
+
lookup_for('organization', entity_id, card_args)
|
20
22
|
end
|
21
23
|
|
22
24
|
# Lookup Organization's all cards
|
@@ -25,8 +27,8 @@ module Crunchbase
|
|
25
27
|
end
|
26
28
|
|
27
29
|
# Lookup a Person or single card
|
28
|
-
def person(entity_id,
|
29
|
-
lookup_for('person', entity_id,
|
30
|
+
def person(entity_id, **card_args)
|
31
|
+
lookup_for('person', entity_id, card_args)
|
30
32
|
end
|
31
33
|
|
32
34
|
# Lookup Person's all cards
|
@@ -35,8 +37,8 @@ module Crunchbase
|
|
35
37
|
end
|
36
38
|
|
37
39
|
# Lookup a Funding Round or single card
|
38
|
-
def funding_round(entity_id,
|
39
|
-
lookup_for('funding_round', entity_id,
|
40
|
+
def funding_round(entity_id, **card_args)
|
41
|
+
lookup_for('funding_round', entity_id, card_args)
|
40
42
|
end
|
41
43
|
|
42
44
|
# Lookup Funding Round's all cards
|
@@ -45,8 +47,8 @@ module Crunchbase
|
|
45
47
|
end
|
46
48
|
|
47
49
|
# Lookup an Acquisition or Single card
|
48
|
-
def acquisition(entity_id,
|
49
|
-
lookup_for('acquisition', entity_id,
|
50
|
+
def acquisition(entity_id, **card_args)
|
51
|
+
lookup_for('acquisition', entity_id, card_args)
|
50
52
|
end
|
51
53
|
|
52
54
|
# Lookup Acquisition's all card
|
@@ -55,8 +57,8 @@ module Crunchbase
|
|
55
57
|
end
|
56
58
|
|
57
59
|
# Lookup an Investment or Single card
|
58
|
-
def investment(entity_id,
|
59
|
-
lookup_for('investment', entity_id,
|
60
|
+
def investment(entity_id, **card_args)
|
61
|
+
lookup_for('investment', entity_id, card_args)
|
60
62
|
end
|
61
63
|
|
62
64
|
# Lookup Investment's all card
|
@@ -65,8 +67,8 @@ module Crunchbase
|
|
65
67
|
end
|
66
68
|
|
67
69
|
# Lookup an PressReference or Single card
|
68
|
-
def press_reference(entity_id,
|
69
|
-
lookup_for('press_reference', entity_id,
|
70
|
+
def press_reference(entity_id, **card_args)
|
71
|
+
lookup_for('press_reference', entity_id, card_args)
|
70
72
|
end
|
71
73
|
|
72
74
|
# Lookup PressReference's all card
|
@@ -75,8 +77,8 @@ module Crunchbase
|
|
75
77
|
end
|
76
78
|
|
77
79
|
# Lookup an Ipo or Single card
|
78
|
-
def ipo(entity_id,
|
79
|
-
lookup_for('ipo', entity_id,
|
80
|
+
def ipo(entity_id, **card_args)
|
81
|
+
lookup_for('ipo', entity_id, card_args)
|
80
82
|
end
|
81
83
|
|
82
84
|
# Lookup Ipo's all card
|
@@ -84,17 +86,39 @@ module Crunchbase
|
|
84
86
|
entities('ipo', entity_id).fetch_cards(cards)
|
85
87
|
end
|
86
88
|
|
89
|
+
# Lookup an fund or Single card
|
90
|
+
def fund(entity_id, **card_args)
|
91
|
+
lookup_for('fund', entity_id, card_args)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Lookup fund's all card
|
95
|
+
def fund_cards(entity_id, cards: [])
|
96
|
+
entities('fund', entity_id).fetch_cards(cards)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Lookup an fund or Single card
|
100
|
+
def ownership(entity_id, **card_args)
|
101
|
+
lookup_for('ownership', entity_id, card_args)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Lookup fund's all card
|
105
|
+
def ownership_cards(entity_id, cards: [])
|
106
|
+
entities('ownership', entity_id).fetch_cards(cards)
|
107
|
+
end
|
108
|
+
|
87
109
|
private
|
88
110
|
|
89
111
|
def entities(entity_type, entity_id)
|
90
112
|
Crunchbase::Entities::Client.new(entity_id, entity_type)
|
91
113
|
end
|
92
114
|
|
93
|
-
def lookup_for(entity_type, entity_id,
|
115
|
+
def lookup_for(entity_type, entity_id, **card_args)
|
94
116
|
kobject = entities(entity_type, entity_id)
|
117
|
+
|
118
|
+
card_id = card_args&.delete(:card_id)
|
95
119
|
return kobject.fetch if card_id.nil?
|
96
120
|
|
97
|
-
kobject.cards(card_id)
|
121
|
+
kobject.cards(card_id, card_args)
|
98
122
|
end
|
99
123
|
end
|
100
124
|
end
|
@@ -9,7 +9,11 @@ require_relative '../errors'
|
|
9
9
|
module Crunchbase
|
10
10
|
# Utilities
|
11
11
|
module Utilities
|
12
|
-
#
|
12
|
+
# Key Reminder
|
13
|
+
#
|
14
|
+
# entity_id must be provided in the request
|
15
|
+
# entity_id can be the uuid or the permalink of the entity
|
16
|
+
# you can pass your API key in the request's header if you do not want to pass the API key in the URL
|
13
17
|
module Request
|
14
18
|
module_function
|
15
19
|
|
@@ -56,7 +60,7 @@ module Crunchbase
|
|
56
60
|
|
57
61
|
return response.body if response.status == 200
|
58
62
|
|
59
|
-
raise Error, response.body['error']
|
63
|
+
raise Error, response.status == 400 ? response.body[0]['message'] : response.body['error']
|
60
64
|
end
|
61
65
|
|
62
66
|
def debug_mode?
|
@@ -52,15 +52,37 @@ module Crunchbase
|
|
52
52
|
%w[identifier]
|
53
53
|
end
|
54
54
|
|
55
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
55
56
|
def field_value(name, data)
|
56
57
|
value = data.dig(name)
|
57
58
|
|
58
59
|
return value if value.nil? || value.is_a?(String)
|
59
|
-
return value
|
60
|
+
return parse_items(value, name) if value.is_a?(Array) && value[0].is_a?(Hash) && value[0].keys.include?('value')
|
61
|
+
return value.dig('value_usd') if value.is_a?(Hash) && value.keys.include?('value_usd')
|
60
62
|
return value.dig('value') if value.is_a?(Hash) && value.keys.include?('value')
|
61
63
|
|
62
64
|
value
|
63
65
|
end
|
66
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
67
|
+
|
68
|
+
def parse_items(items, field_name)
|
69
|
+
return items.collect { |e| e.dig('value') } unless field_name == 'activity_entities'
|
70
|
+
|
71
|
+
# Sepcial case for activity_entities
|
72
|
+
items.each_with_object([]) do |item, objects|
|
73
|
+
card_model = case item['entity_def_id']
|
74
|
+
when 'person' then ::Crunchbase::Models::Person
|
75
|
+
when 'organization' then ::Crunchbase::Models::Organization
|
76
|
+
end
|
77
|
+
# Alias: value is name
|
78
|
+
item['name'] ||= item['value']
|
79
|
+
|
80
|
+
next if card_model.nil?
|
81
|
+
|
82
|
+
new_card_instance = card_model.new
|
83
|
+
objects << dynamic_attributes(new_card_instance, new_card_instance.basis_fields, item)
|
84
|
+
end
|
85
|
+
end
|
64
86
|
end
|
65
87
|
end
|
66
88
|
end
|
@@ -142,7 +142,7 @@ module Crunchbase
|
|
142
142
|
'online_and_on_campus' => 'Online and On Campus'
|
143
143
|
}.freeze
|
144
144
|
|
145
|
-
|
145
|
+
SCHOOL_PROGRAMS = {
|
146
146
|
'bootcamp' => 'Bootcamp',
|
147
147
|
'community_college' => 'Community College',
|
148
148
|
'four_year_university' => 'Four Year University',
|
data/lib/crunchbase/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crunchbase4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Encore Shao
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -141,17 +141,24 @@ files:
|
|
141
141
|
- lib/crunchbase/errors.rb
|
142
142
|
- lib/crunchbase/models.rb
|
143
143
|
- lib/crunchbase/models/acquisition.rb
|
144
|
+
- lib/crunchbase/models/address.rb
|
144
145
|
- lib/crunchbase/models/autocomplete_entity.rb
|
145
146
|
- lib/crunchbase/models/category.rb
|
146
147
|
- lib/crunchbase/models/category_group.rb
|
148
|
+
- lib/crunchbase/models/concerns/entity.rb
|
149
|
+
- lib/crunchbase/models/concerns/mappings.rb
|
147
150
|
- lib/crunchbase/models/deleted_entity.rb
|
148
|
-
- lib/crunchbase/models/
|
151
|
+
- lib/crunchbase/models/event_appearance.rb
|
152
|
+
- lib/crunchbase/models/fund.rb
|
149
153
|
- lib/crunchbase/models/funding_round.rb
|
150
154
|
- lib/crunchbase/models/investment.rb
|
151
155
|
- lib/crunchbase/models/ipo.rb
|
156
|
+
- lib/crunchbase/models/job.rb
|
152
157
|
- lib/crunchbase/models/organization.rb
|
158
|
+
- lib/crunchbase/models/ownership.rb
|
153
159
|
- lib/crunchbase/models/person.rb
|
154
160
|
- lib/crunchbase/models/press_reference.rb
|
161
|
+
- lib/crunchbase/models/principal.rb
|
155
162
|
- lib/crunchbase/searches.rb
|
156
163
|
- lib/crunchbase/searches/client.rb
|
157
164
|
- lib/crunchbase/utilities.rb
|
@@ -172,7 +179,7 @@ metadata:
|
|
172
179
|
allowed_push_host: https://rubygems.org
|
173
180
|
homepage_uri: https://github.com/ekohe/crunchbase4
|
174
181
|
source_code_uri: https://github.com/ekohe/crunchbase4
|
175
|
-
changelog_uri: https://github.com/ekohe/crunchbase4/CHANGELOG.md
|
182
|
+
changelog_uri: https://github.com/ekohe/crunchbase4/blob/master/CHANGELOG.md
|
176
183
|
post_install_message: Thanks for installing!
|
177
184
|
rdoc_options: []
|
178
185
|
require_paths:
|
@@ -188,8 +195,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
195
|
- !ruby/object:Gem::Version
|
189
196
|
version: '0'
|
190
197
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
-
signing_key:
|
198
|
+
rubygems_version: 3.1.2
|
199
|
+
signing_key:
|
193
200
|
specification_version: 4
|
194
201
|
summary: Crunchbase is a ruby wrapper base on Crunchbase V4 API
|
195
202
|
test_files: []
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../utilities/response'
|
4
|
-
|
5
|
-
module Crunchbase
|
6
|
-
# Get the Organization data from API
|
7
|
-
module Models
|
8
|
-
# Root
|
9
|
-
class Entity
|
10
|
-
include ::Crunchbase::Utilities::Response
|
11
|
-
|
12
|
-
def fields
|
13
|
-
field_ids.map(&:to_sym)
|
14
|
-
end
|
15
|
-
|
16
|
-
def parse_response(response, request_field_ids = [], cards = [])
|
17
|
-
extract_fields = (request_field_ids.empty? ? field_ids : request_field_ids)
|
18
|
-
|
19
|
-
dynamic_attributes(self, extract_fields, response.dig('properties'))
|
20
|
-
setup_relationships(self, cards, response.dig('cards'))
|
21
|
-
self
|
22
|
-
end
|
23
|
-
|
24
|
-
def setup_relationships(object, request_card_ids, response_cards)
|
25
|
-
request_card_ids.each do |card_id|
|
26
|
-
card_data = response_cards.dig(card_id)
|
27
|
-
next if card_data.nil? || card_data.empty?
|
28
|
-
|
29
|
-
card_model = card_model_mappings[card_id]
|
30
|
-
card_objects = if card_data.is_a?(Array)
|
31
|
-
card_data.each_with_object([]) do |data, objects|
|
32
|
-
new_card_instance = card_model.new
|
33
|
-
objects << dynamic_attributes(new_card_instance, new_card_instance.basis_fields, data)
|
34
|
-
end
|
35
|
-
else
|
36
|
-
dynamic_attributes(card_model.new, extract_fields, data)
|
37
|
-
end
|
38
|
-
|
39
|
-
dynamic_define_method(object, card_id, card_objects)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def as_json
|
44
|
-
fields.each_with_object({}) { |item, hash| hash[item] = send(item) }
|
45
|
-
end
|
46
|
-
|
47
|
-
def card_model_mappings
|
48
|
-
{
|
49
|
-
'investments' => Crunchbase::Models::Investment,
|
50
|
-
'raised_investments' => Crunchbase::Models::Investment,
|
51
|
-
# 'participated_funds' => Crunchbase::Models::Fund,
|
52
|
-
'child_organizations' => Crunchbase::Models::Organization,
|
53
|
-
'participated_investments' => Crunchbase::Models::Investment,
|
54
|
-
# 'investors' => Crunchbase::Models::Investor,
|
55
|
-
'parent_organization' => Crunchbase::Models::Organization,
|
56
|
-
'raised_funding_rounds' => Crunchbase::Models::FundingRound,
|
57
|
-
'ipos' => Crunchbase::Models::Ipo,
|
58
|
-
# 'event_appearances' => Crunchbase::Models::EventAppearance,
|
59
|
-
# 'raised_funds' => Crunchbase::Models::Fund,
|
60
|
-
'acquiree_acquisitions' => Crunchbase::Models::Acquisition,
|
61
|
-
# 'parent_ownership' => Crunchbase::Models::Ownership,
|
62
|
-
# 'jobs' => Crunchbase::Models::Job,
|
63
|
-
# 'founders' => Crunchbase::Models::Founder,
|
64
|
-
# 'child_ownerships' => Crunchbase::Models::Ownership,
|
65
|
-
'participated_funding_rounds' => Crunchbase::Models::FundingRound,
|
66
|
-
'press_references' => Crunchbase::Models::PressReference
|
67
|
-
# 'headquarters_address' => Crunchbase::Models::Address,
|
68
|
-
}
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|