crunchbase4 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +6 -1
- data/Gemfile.lock +3 -0
- data/README.md +222 -54
- data/crunchbase4.gemspec +7 -6
- data/lib/crunchbase.rb +0 -2
- data/lib/crunchbase/client.rb +5 -40
- data/lib/crunchbase/config.rb +1 -1
- data/lib/crunchbase/entities/client.rb +19 -17
- data/lib/crunchbase/models.rb +1 -0
- data/lib/crunchbase/models/acquisition.rb +61 -0
- data/lib/crunchbase/models/entity.rb +6 -2
- data/lib/crunchbase/models/funding_round.rb +1 -1
- data/lib/crunchbase/searches/client.rb +57 -6
- data/lib/crunchbase/utilities/cb_model.rb +32 -0
- data/lib/crunchbase/utilities/entity_endpoints.rb +91 -0
- data/lib/crunchbase/utilities/request.rb +23 -1
- data/lib/crunchbase/utilities/response.rb +33 -12
- data/lib/crunchbase/utilities/search_endpoints.rb +24 -0
- data/lib/crunchbase/version.rb +1 -1
- metadata +28 -11
- data/lib/crunchbase/searches/organization.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 116da8bf7036e9d4dba37ed63c85c7fa7cf44fa11c16f291045db209f4ab81b2
|
4
|
+
data.tar.gz: cb9d52123e679160e5055c6aeefbcf30be6924499f050105fa723c9412988587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9cb04ffe4ed809a86743d76f2c815616b1d19ee132bf44fe04dc0fcd0d69265871cd4a827083a591630a9514c2f9d07c441a5bc9461ab14c4b3b31f021fc6bf
|
7
|
+
data.tar.gz: 66a0327303a29efc601bac09788f8cd363bde4aedb0245f56d85d6c39eae02f531e1cbae6bd21db3c01e140e27a5c0f70c6bee069b761364902b69b2d3d194b9
|
data/.rubocop_todo.yml
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
# Offense count: 2
|
10
10
|
# Configuration parameters: IgnoredMethods.
|
11
11
|
Metrics/AbcSize:
|
12
|
-
Max:
|
12
|
+
Max: 30
|
13
13
|
|
14
14
|
# Offense count: 1
|
15
15
|
# Configuration parameters: CountComments.
|
@@ -33,3 +33,8 @@ Metrics/PerceivedComplexity:
|
|
33
33
|
|
34
34
|
Metrics/BlockLength:
|
35
35
|
Max: 200
|
36
|
+
Exclude:
|
37
|
+
- spec/entities/client_spec.rb
|
38
|
+
|
39
|
+
Layout/LineLength:
|
40
|
+
Max: 200
|
data/Gemfile.lock
CHANGED
@@ -3,6 +3,7 @@ PATH
|
|
3
3
|
specs:
|
4
4
|
crunchbase4 (0.1.0)
|
5
5
|
faraday
|
6
|
+
faraday_curl
|
6
7
|
faraday_middleware
|
7
8
|
|
8
9
|
GEM
|
@@ -17,6 +18,8 @@ GEM
|
|
17
18
|
diff-lcs (1.3)
|
18
19
|
faraday (1.0.1)
|
19
20
|
multipart-post (>= 1.2, < 3)
|
21
|
+
faraday_curl (0.0.2)
|
22
|
+
faraday (>= 0.9.0)
|
20
23
|
faraday_middleware (1.0.0)
|
21
24
|
faraday (~> 1.0)
|
22
25
|
hashdiff (1.0.1)
|
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# Crunchbase
|
2
2
|
|
3
|
-
|
3
|
+
Crunchbase is a ruby wrapper base on Crunchbase V4 API. It provides easy to get the API data by each endpoint. [CB-v4 doc](https://app.swaggerhub.com/apis/Crunchbase/crunchbase-enterprise_api/1.0.1)
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/crunchbase4.svg)](https://badge.fury.io/rb/crunchbase4)
|
6
6
|
[![Build Status](https://travis-ci.org/encoreshao/crunchbase4.svg?branch=master)](https://travis-ci.org/encoreshao/crunchbase4)
|
7
|
-
[![Coverage Status](https://coveralls.io/repos/github/encoreshao/crunchbase4/badge.svg)](https://coveralls.io/github/encoreshao/crunchbase4)
|
8
7
|
|
9
8
|
## Installation
|
10
9
|
|
@@ -18,9 +17,13 @@ And then execute:
|
|
18
17
|
|
19
18
|
$ bundle install
|
20
19
|
|
21
|
-
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install crunchbase4
|
22
23
|
|
23
|
-
##
|
24
|
+
## Getting Started
|
25
|
+
|
26
|
+
### Configure your API certificate
|
24
27
|
|
25
28
|
```
|
26
29
|
require 'crunchbase4'
|
@@ -35,23 +38,27 @@ OR
|
|
35
38
|
Crunchbase.config.user_key = CB_CONFIG['user_key']
|
36
39
|
```
|
37
40
|
|
38
|
-
##
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
### The first step is to build an API client
|
39
44
|
|
40
45
|
```
|
41
46
|
pry(main)> client = Crunchbase::Client.new
|
47
|
+
```
|
48
|
+
|
49
|
+
### Entity
|
50
|
+
|
51
|
+
#### Get the organization data
|
52
|
+
|
53
|
+
```
|
42
54
|
pry(main)> response = client.organization('ekohe')
|
43
|
-
=> #<Crunchbase::
|
44
|
-
@acquirer_identifier=nil,
|
45
|
-
@aliases=nil,
|
55
|
+
=> #<Crunchbase::Models::Organization:0x00007fbc5cfdf2f8
|
46
56
|
@categories=["Apps", "Artificial Intelligence", "Big Data", "E-Commerce", "Enterprise Software", "FinTech", "iOS", "Retail", "UX Design"],
|
47
57
|
@category_groups=["Apps", "Artificial Intelligence", "Commerce and Shopping", "Data and Analytics", "Design", "Financial Services", "Mobile", "Platforms", "Science and Engineering", "Software"],
|
48
|
-
@closed_on=nil,
|
49
58
|
@company_type="for_profit",
|
50
59
|
@contact_email="info@ekohe.com",
|
51
60
|
@created_at="2013-05-14T14:28:38Z",
|
52
|
-
|
53
|
-
@demo_days=nil,
|
54
|
-
@description=
|
61
|
+
...
|
55
62
|
...>
|
56
63
|
pry(main)> response.name
|
57
64
|
=> "Ekohe"
|
@@ -59,28 +66,22 @@ pry(main)> response.permalink
|
|
59
66
|
=> "ekohe"
|
60
67
|
```
|
61
68
|
|
62
|
-
|
63
|
-
|
69
|
+
Or, if you want to use json data, please call `response.as_json` in your project.
|
64
70
|
|
65
|
-
|
71
|
+
#### Get the person data
|
66
72
|
|
67
73
|
```
|
68
|
-
pry(main)> client = Crunchbase::Client.new
|
69
74
|
pry(main)> response = client.person('mark-zuckerberg')
|
70
|
-
=> #<Crunchbase::
|
75
|
+
=> #<Crunchbase::Models::Person:0x00007ffbf201d178
|
71
76
|
@aliases=["Zuck"],
|
72
77
|
@born_on="1984-05-14",
|
73
78
|
@created_at="2007-05-26T04:51:46Z",
|
74
|
-
@description=
|
75
|
-
"Mark Zuckerberg is the founder and CEO of Facebook, which he started in his college dorm room in 2004 with roomates Dustin Moskovitz and Chris Hughes and from New York.\r\n\r\nZuckerberg is responsible for setting the overall direction and product strategy for the company. He leads the design of Facebook's service and development of its core technology and infrastructure. Mark studied computer science at Harvard University before moving the company to Palo Alto, California.\r\n\r\nEarlier in life, Zuckerberg developed a music recommendation system called Synapse and a peer-to-peer client called Wirehog. However, he abandoned both to pursue new projects.\r\n\r\nZuckerberg attended Harvard University and studied computer science before founding Facebook.\r\n\r\nWhile at Harvard, Zuckerberg created Facemash, a website that compared students' dorm photos side-by-side in a fashion similar to HOT or NOT. Harvard administration was not amused, and Zuckerberg faced subsequent disciplinary action. Less than three months later, he launched Facebook.\r\n\r\nIn September 2010, Zuckerberg donated $100 million to the Newark Public School System to help renovate and revamp the system.\r\n\r\nZuckerberg won the 2007 Crunchie Award for 'Best Startup CEO.' He was the Time Magazine 2010 Person Of The Year. He also won the 2012 Crunchie Award for CEO of the year.",
|
76
|
-
@died_on=nil,
|
77
79
|
@entity_def_id="person",
|
78
80
|
@entity_id="mark-zuckerberg",
|
79
81
|
@facebook="https://www.facebook.com/zuck",
|
80
82
|
@facet_ids=["investor", "rank"],
|
81
83
|
@first_name="Mark",
|
82
84
|
@gender="male",
|
83
|
-
@identifier="Mark Zuckerberg",
|
84
85
|
...>
|
85
86
|
pry(main)> response.name
|
86
87
|
=> "Mark Zuckerberg"
|
@@ -88,52 +89,219 @@ pry(main)> response.permalink
|
|
88
89
|
=> "mark-zuckerberg"
|
89
90
|
```
|
90
91
|
|
91
|
-
|
92
|
-
|
93
|
-
```
|
94
|
-
|
95
|
-
|
96
|
-
:
|
97
|
-
|
98
|
-
|
99
|
-
:
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
:last_name=>"Zuckerberg",
|
109
|
-
:layout_id=>"investor",
|
110
|
-
:linkedin=>nil,
|
111
|
-
:location_group_identifiers=>["San Francisco Bay Area", "Silicon Valley", "West Coast", "Western US"],
|
112
|
-
:location_identifiers=>["Palo Alto", "California", "United States", "North America"],
|
113
|
-
:middle_name=>nil,
|
114
|
-
:num_articles=>31046,
|
115
|
-
:num_current_advisor_jobs=>4,
|
116
|
-
:num_current_jobs=>7,
|
117
|
-
:num_event_appearances=>6,
|
118
|
-
:num_exits=>nil,
|
92
|
+
#### Get the funding round data
|
93
|
+
|
94
|
+
```
|
95
|
+
=> #<Crunchbase::Client:0x00007f8806824c28>
|
96
|
+
pry(main)> response = client.funding_round('371c20af-8aa9-4bcb-a8da-0694d138f247')
|
97
|
+
=> #<Crunchbase::Models::FundingRound:0x00007f8806b55ca8
|
98
|
+
@announced_on="2013-06-30",
|
99
|
+
@closed_on=nil,
|
100
|
+
@created_at="2020-04-02T12:17:59Z",
|
101
|
+
@entity_def_id="funding_round",
|
102
|
+
@funded_organization_categories=nil,
|
103
|
+
@funded_organization_description="Facebook is an online social networking service that enables its users to connect with friends and family.",
|
104
|
+
@funded_organization_funding_stage="ipo",
|
105
|
+
@funded_organization_funding_total=2335700000,
|
106
|
+
@funded_organization_identifier="Facebook",
|
107
|
+
@funded_organization_location=["Menlo Park", "California", "United States", "North America"],
|
108
|
+
@funded_organization_revenue_range="r_10000000",
|
119
109
|
....>
|
110
|
+
pry(main)> response.name
|
111
|
+
=> "Secondary Market - Facebook"
|
112
|
+
pry(main)> response.uuid
|
113
|
+
=> "371c20af-8aa9-4bcb-a8da-0694d138f247"
|
114
|
+
```
|
115
|
+
|
116
|
+
#### Get the acquisition data
|
117
|
+
|
118
|
+
```
|
119
|
+
pry(main)> response = client.acquisition('7638eae9-07b7-4fc6-ad20-5d99de3ff928')
|
120
|
+
=> #<Crunchbase::Models::Acquisition:0x00007fa01134da60
|
121
|
+
@acquiree_categories=["Communities", "Internet", "Photo Sharing", "Publishing", "Search Engine", "Social Media"],
|
122
|
+
@acquiree_funding_total=150949998,
|
123
|
+
@acquiree_identifier="Giphy",
|
124
|
+
@acquiree_last_funding_type="series_d",
|
125
|
+
@acquiree_locations=["New York", "New York", "United States", "North America"],
|
126
|
+
...>
|
127
|
+
pry(main)> response.uuid
|
128
|
+
=> "7638eae9-07b7-4fc6-ad20-5d99de3ff928"
|
129
|
+
pry(main)> response.acquiree_funding_total
|
130
|
+
=> 150949998
|
120
131
|
```
|
121
132
|
|
133
|
+
#### Get the press reference data
|
134
|
+
|
135
|
+
```
|
136
|
+
pry(main)> response = client.press_reference('0171b30e-9cf8-4ad5-8288-2993e4308e0f')
|
137
|
+
=> #<Crunchbase::Models::PressReference:0x00007fce2d33dbc0
|
138
|
+
@activity_entities=["Facebook", "General Atlantic", "KKR", "Reliance Industries", "Vista Equity Partners"],
|
139
|
+
@author=nil,
|
140
|
+
@created_at="2020-06-05T17:41:10Z",
|
141
|
+
@entity_def_id="press_reference",
|
142
|
+
@identifier="Jio Platforms to receive $1.2b from Abu Dhabi’s sovereign investment firm",
|
143
|
+
@posted_on="2020-06-05",
|
144
|
+
@publisher="Tech in Asia",
|
145
|
+
@thumbnail_url="https://cdn.techinasia.com/wp-content/uploads/2016/07/Flickr_-_World_Economic_Forum_-_Ambani.jpg",
|
146
|
+
@title="Jio Platforms to receive $1.2b from Abu Dhabi’s sovereign investment firm",
|
147
|
+
@updated_at="2020-06-05T17:41:10Z",
|
148
|
+
@url="https://ift.tt/3cByFh1",
|
149
|
+
@uuid="0171b30e-9cf8-4ad5-8288-2993e4308e0f">
|
150
|
+
```
|
151
|
+
|
152
|
+
#### Get the investment data
|
153
|
+
|
154
|
+
```
|
155
|
+
pry(main)> response = client.investment('1368da0c-07b0-46ef-9a86-b518367e60d6')
|
156
|
+
=> #<Crunchbase::Models::Investment:0x00007f8c15105830
|
157
|
+
@announced_on="2013-06-30",
|
158
|
+
@created_at="2020-04-02T12:17:59Z",
|
159
|
+
@entity_def_id="investment",
|
160
|
+
@funding_round_identifier="Secondary Market - Facebook",
|
161
|
+
@funding_round_money_raised=nil,
|
162
|
+
@identifier="Jean-Brice Abrial investment in Secondary Market - Facebook",
|
163
|
+
@investor_identifier="Jean-Brice Abrial",
|
164
|
+
@investor_stage=["early_stage_venture", "seed"],
|
165
|
+
@investor_type=["angel"],
|
166
|
+
@is_lead_investor=nil,
|
167
|
+
@money_invested=1500000.0,
|
168
|
+
@name="Jean-Brice Abrial investment in Secondary Market - Facebook",
|
169
|
+
@organization_identifier="Facebook",
|
170
|
+
@partner_identifiers=nil,
|
171
|
+
@permalink="jean-brice-abrial-invested-in-facebook-secondary-market--371c20af--1368da0c",
|
172
|
+
@updated_at="2020-04-02T12:17:59Z",
|
173
|
+
@uuid="1368da0c-07b0-46ef-9a86-b518367e60d6">
|
174
|
+
```
|
175
|
+
|
176
|
+
### Search
|
177
|
+
|
178
|
+
* Search query parameters for each endpoint
|
179
|
+
|
180
|
+
```
|
181
|
+
{
|
182
|
+
"field_ids": [],
|
183
|
+
"query": [],
|
184
|
+
"order": [],
|
185
|
+
"limit": 0
|
186
|
+
}
|
187
|
+
```
|
188
|
+
|
189
|
+
#### Search organizations by query conditions and order
|
190
|
+
|
191
|
+
* Step1: Needs to build the query conditions
|
192
|
+
|
193
|
+
```
|
194
|
+
query_data = {
|
195
|
+
'field_ids' => %w[
|
196
|
+
name
|
197
|
+
website
|
198
|
+
uuid
|
199
|
+
short_description
|
200
|
+
company_type
|
201
|
+
],
|
202
|
+
'order' => [
|
203
|
+
{
|
204
|
+
'field_id' => 'company_type',
|
205
|
+
'sort' => 'asc'
|
206
|
+
}
|
207
|
+
],
|
208
|
+
'query' => [
|
209
|
+
{
|
210
|
+
'type' => 'predicate',
|
211
|
+
'field_id' => 'funding_total',
|
212
|
+
'operator_id' => 'between',
|
213
|
+
'values' => [
|
214
|
+
{
|
215
|
+
'value' => 1_000_000,
|
216
|
+
'currency' => 'usd'
|
217
|
+
},
|
218
|
+
{
|
219
|
+
'value' => 10_000_000,
|
220
|
+
'currency' => 'usd'
|
221
|
+
}
|
222
|
+
]
|
223
|
+
},
|
224
|
+
{
|
225
|
+
'type' => 'predicate',
|
226
|
+
'field_id' => 'facet_ids',
|
227
|
+
'operator_id' => 'includes',
|
228
|
+
'values' => %w[company investor]
|
229
|
+
}
|
230
|
+
],
|
231
|
+
'limit' => 4
|
232
|
+
}
|
233
|
+
```
|
234
|
+
|
235
|
+
* Use `client` to send a request and parse response
|
236
|
+
|
237
|
+
```
|
238
|
+
pry(main)> response = client.search_organizations(query_data)
|
239
|
+
=> #<Crunchbase::Searches::Client:0x00007fdfc1ad6eb8
|
240
|
+
@conditions=
|
241
|
+
{"field_ids"=>["name", "website", "uuid", "short_description", "company_type"],
|
242
|
+
"order"=>[{"field_id"=>"company_type", "sort"=>"asc"}],
|
243
|
+
"query"=>
|
244
|
+
[{"type"=>"predicate", "field_id"=>"funding_total", "operator_id"=>"between", "values"=>[{"value"=>1000000, "currency"=>"usd"}, {"value"=>10000000, "currency"=>"usd"}]},
|
245
|
+
{"type"=>"predicate", "field_id"=>"facet_ids", "operator_id"=>"includes", "values"=>["company", "investor"]}],
|
246
|
+
"limit"=>4},
|
247
|
+
@count=4,
|
248
|
+
@entities=
|
249
|
+
[#<Crunchbase::Models::Organization:0x00007fdfc1b06460
|
250
|
+
@company_type="for_profit",
|
251
|
+
@name="360VUZ",
|
252
|
+
@short_description="360VUZ is an immersive virtual video mobile app that enables users to teleport from their smartphone in 360°",
|
253
|
+
@uuid="cb32a4d7-2bd0-1727-a055-63aa6a545380",
|
254
|
+
@website="http://www.360VUZ.com">,
|
255
|
+
#<Crunchbase::Models::Organization:0x00007fdfc1b05b78
|
256
|
+
@company_type="for_profit",
|
257
|
+
@name="HATCHER+",
|
258
|
+
@short_description="Hatcher+ is a data-driven venture investment platform.",
|
259
|
+
@uuid="a0ed41b8-8031-adad-dbb3-2e8f8e1e6848",
|
260
|
+
@website="https://h2.hatcher.com">,
|
261
|
+
#<Crunchbase::Models::Organization:0x00007fdfc1b05290
|
262
|
+
@company_type="for_profit",
|
263
|
+
@name="Merck",
|
264
|
+
@short_description="Merck is a biopharmaceutical company that offers medicines and vaccines for various diseases.",
|
265
|
+
@uuid="2f9b212a-d3aa-a8c2-6317-516127c8ba88",
|
266
|
+
@website="http://www.merck.com">,
|
267
|
+
#<Crunchbase::Models::Organization:0x00007fdfc1b049a8
|
268
|
+
@company_type="for_profit",
|
269
|
+
@name="Archistar.ai",
|
270
|
+
@short_description="World-first artificial intelligence helping professionals find development sites, assess for feasibility and generate architectural designs",
|
271
|
+
@uuid="3be8b43a-1143-4e26-8ecb-660a5a78edc5",
|
272
|
+
@website="https://archistar.ai/">],
|
273
|
+
@entity_type="organization",
|
274
|
+
@kclass_name=Crunchbase::Models::Organization,
|
275
|
+
@total_count=44871>
|
276
|
+
```
|
277
|
+
|
278
|
+
- Get all entities: `response.entities`
|
279
|
+
- Get total count: `response.total_count`
|
280
|
+
- Get entities count: `response.count`
|
281
|
+
|
122
282
|
## Development
|
123
283
|
|
124
284
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
125
285
|
|
126
|
-
|
286
|
+
### Examples of API requests
|
127
287
|
|
128
|
-
|
288
|
+
```
|
289
|
+
Crunchbase.config.user_key = 'user_key'
|
290
|
+
client = Crunchbase::Client.new
|
291
|
+
response = client.organization('ekohe')
|
292
|
+
response = client.person('mark-zuckerberg')
|
293
|
+
response = client.funding_round('371c20af8aa94bcba8da0694d138f247')
|
294
|
+
response = client.acquisition('7638eae9-07b7-4fc6-ad20-5d99de3ff928')
|
295
|
+
```
|
129
296
|
|
130
|
-
|
297
|
+
## Contributing
|
131
298
|
|
299
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ekohe/crunchbase4. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/ekohe/crunchbase4/blob/master/CODE_OF_CONDUCT.md).
|
132
300
|
|
133
301
|
## License
|
134
302
|
|
135
|
-
|
303
|
+
Crunchbase is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
136
304
|
|
137
305
|
## Code of Conduct
|
138
306
|
|
139
|
-
Everyone interacting in the Crunchbase project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
307
|
+
Everyone interacting in the Crunchbase project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ekohe/crunchbase4/blob/master/CODE_OF_CONDUCT.md).
|
data/crunchbase4.gemspec
CHANGED
@@ -6,11 +6,11 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'crunchbase4'
|
7
7
|
spec.version = Crunchbase::VERSION
|
8
8
|
spec.authors = ['Encore Shao']
|
9
|
-
spec.email = ['encore
|
9
|
+
spec.email = ['encore@ekohe.com']
|
10
10
|
|
11
|
-
spec.summary = '
|
12
|
-
spec.description = '
|
13
|
-
spec.homepage = 'https://github.com/
|
11
|
+
spec.summary = 'Crunchbase is a ruby wrapper base on Crunchbase V4 API'
|
12
|
+
spec.description = 'Crunchbase is a ruby wrapper base on Crunchbase V4 API. It provides easy to get the API data by each endpoint. '
|
13
|
+
spec.homepage = 'https://github.com/ekohe/crunchbase4'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
16
16
|
spec.post_install_message = 'Thanks for installing!'
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
19
19
|
|
20
20
|
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
-
spec.metadata['source_code_uri'] = 'https://github.com/
|
22
|
-
spec.metadata['changelog_uri'] = 'https://github.com/
|
21
|
+
spec.metadata['source_code_uri'] = 'https://github.com/ekohe/crunchbase4'
|
22
|
+
spec.metadata['changelog_uri'] = 'https://github.com/ekohe/crunchbase4/CHANGELOG.md'
|
23
23
|
|
24
24
|
# Specify which files should be added to the gem when it is released.
|
25
25
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.require_paths = ['lib']
|
33
33
|
|
34
34
|
spec.add_dependency 'faraday'
|
35
|
+
spec.add_dependency 'faraday_curl'
|
35
36
|
spec.add_dependency 'faraday_middleware'
|
36
37
|
|
37
38
|
# VCR for testing APIs
|
data/lib/crunchbase.rb
CHANGED
@@ -3,12 +3,10 @@
|
|
3
3
|
require 'crunchbase/version'
|
4
4
|
|
5
5
|
require 'crunchbase/config'
|
6
|
-
require 'crunchbase/utilities'
|
7
6
|
require 'crunchbase/client'
|
8
7
|
require 'crunchbase/entities'
|
9
8
|
require 'crunchbase/searches'
|
10
9
|
require 'crunchbase/models'
|
11
|
-
require 'crunchbase/errors'
|
12
10
|
|
13
11
|
module Crunchbase
|
14
12
|
API_VERSION = 'v4'
|
data/lib/crunchbase/client.rb
CHANGED
@@ -1,47 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'utilities/entity_endpoints'
|
4
|
+
require_relative 'utilities/search_endpoints'
|
5
|
+
|
3
6
|
module Crunchbase
|
4
7
|
# API Request
|
5
8
|
class Client
|
6
|
-
|
7
|
-
|
8
|
-
# entity_id: UUID or permalink of desired entity
|
9
|
-
# card_id: A card to include on the resulting entity
|
10
|
-
# order: Field name with order direction (asc/desc)
|
11
|
-
# limit: Number of rows to return. Default is 100, min is 1, max is 100.
|
12
|
-
def organization(entity_id, card_id: nil)
|
13
|
-
kobject = entities('Organization', entity_id)
|
14
|
-
return kobject.fetch if card_id.nil?
|
15
|
-
|
16
|
-
kobject.cards(card_id)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Fetching all cards of organization
|
20
|
-
def organization_cards(entity_id, cards: [])
|
21
|
-
entities('Organization', entity_id).fetch_cards(cards)
|
22
|
-
end
|
23
|
-
|
24
|
-
def person(entity_id, card_id: nil)
|
25
|
-
kobject = entities('Person', entity_id)
|
26
|
-
return kobject.fetch if card_id.nil?
|
27
|
-
|
28
|
-
kobject.cards(card_id)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Fetching all cards of people
|
32
|
-
def person_cards(entity_id)
|
33
|
-
entities('Person', entity_id).fetch_cards
|
34
|
-
end
|
35
|
-
|
36
|
-
def searches(keyword, _scope: nil)
|
37
|
-
Crunchbase::Searches::Organization.new('name', keyword)
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def entities(kclass_name, entity_id)
|
43
|
-
model_name = Kernel.const_get("Crunchbase::Models::#{kclass_name}")
|
44
|
-
Crunchbase::Entities::Client.new(entity_id, model_name)
|
45
|
-
end
|
9
|
+
include Utilities::EntityEndpoints
|
10
|
+
include Utilities::SearchEndpoints
|
46
11
|
end
|
47
12
|
end
|
data/lib/crunchbase/config.rb
CHANGED
@@ -1,49 +1,51 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../utilities/request'
|
4
|
+
require_relative '../utilities/cb_model'
|
5
|
+
|
3
6
|
module Crunchbase
|
4
7
|
# Whole entities endpoints
|
5
8
|
module Entities
|
6
9
|
# Send request for entities endpoints
|
7
10
|
class Client
|
8
11
|
include ::Crunchbase::Utilities::Request
|
9
|
-
|
10
|
-
attr_reader :object
|
12
|
+
include ::Crunchbase::Utilities::CbModel
|
11
13
|
|
12
14
|
ROOT_LIST = 'entities'
|
13
15
|
|
14
|
-
def initialize(entity_id,
|
16
|
+
def initialize(entity_id, entity_type)
|
15
17
|
@entity_id = entity_id
|
16
|
-
@
|
18
|
+
@entity_type = entity_type
|
17
19
|
end
|
18
20
|
|
19
21
|
# Will include all attribute from API document
|
20
22
|
def fetch
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
cbobject.parse_response(entity(
|
24
|
+
root_uri,
|
25
|
+
field_ids: cbobject.field_ids.join(',')
|
26
|
+
))
|
25
27
|
end
|
26
28
|
|
27
29
|
# Only include a part basis fields of endpoint
|
28
30
|
def fetch_cards(card_names = [])
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
cbobject.parse_cards_response(entity(
|
32
|
+
root_uri,
|
33
|
+
field_ids: cbobject.basis_fields.join(','),
|
34
|
+
cards: (cbobject.full_cards & card_names).join(',')
|
35
|
+
))
|
34
36
|
end
|
35
37
|
|
36
38
|
def cards(card_id)
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
cbobject.parse_response(entity(
|
40
|
+
root_uri(name: __method__, id: card_id)
|
41
|
+
))
|
40
42
|
end
|
41
43
|
|
42
44
|
private
|
43
45
|
|
44
46
|
def root_uri(args = {})
|
45
47
|
[
|
46
|
-
ROOT_LIST,
|
48
|
+
ROOT_LIST, kclass_name::RESOURCE_LIST,
|
47
49
|
@entity_id, args[:name], args[:id]
|
48
50
|
].compact.join('/')
|
49
51
|
end
|
data/lib/crunchbase/models.rb
CHANGED
@@ -7,6 +7,7 @@ module Crunchbase
|
|
7
7
|
autoload :Organization, 'crunchbase/models/organization'
|
8
8
|
autoload :Person, 'crunchbase/models/person'
|
9
9
|
autoload :FundingRound, 'crunchbase/models/funding_round'
|
10
|
+
autoload :Acquisition, 'crunchbase/models/acquisition'
|
10
11
|
autoload :Investment, 'crunchbase/models/investment'
|
11
12
|
autoload :PressReference, 'crunchbase/models/press_reference'
|
12
13
|
autoload :CategoryGroup, 'crunchbase/models/category_group'
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
# Get the Entities data from API
|
5
|
+
module Models
|
6
|
+
# Get the person data from API
|
7
|
+
class Acquisition < Entity
|
8
|
+
RESOURCE_LIST = 'acquisitions'
|
9
|
+
|
10
|
+
def field_ids
|
11
|
+
%w[
|
12
|
+
acquiree_categories
|
13
|
+
acquiree_last_funding_type
|
14
|
+
acquiree_locations
|
15
|
+
acquiree_num_funding_rounds
|
16
|
+
acquiree_revenue_range
|
17
|
+
acquiree_short_description
|
18
|
+
acquirer_categories
|
19
|
+
acquirer_funding_total
|
20
|
+
acquirer_identifier
|
21
|
+
acquirer_locations
|
22
|
+
acquirer_num_funding_rounds
|
23
|
+
acquirer_short_description
|
24
|
+
created_at
|
25
|
+
disposition_of_acquired
|
26
|
+
entity_def_id
|
27
|
+
num_relationships
|
28
|
+
rank
|
29
|
+
rank_acquisition
|
30
|
+
status
|
31
|
+
terms
|
32
|
+
updated_at
|
33
|
+
] + basis_fields
|
34
|
+
end
|
35
|
+
|
36
|
+
def basis_fields
|
37
|
+
%w[
|
38
|
+
uuid
|
39
|
+
permalink
|
40
|
+
identifier
|
41
|
+
announced_on
|
42
|
+
completed_on
|
43
|
+
acquisition_type
|
44
|
+
price
|
45
|
+
short_description
|
46
|
+
acquiree_funding_total
|
47
|
+
acquiree_identifier
|
48
|
+
acquirer_revenue_range
|
49
|
+
]
|
50
|
+
end
|
51
|
+
|
52
|
+
def full_cards
|
53
|
+
%w[
|
54
|
+
acquiree_organization
|
55
|
+
acquirer_organization
|
56
|
+
press_references
|
57
|
+
]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../utilities/response'
|
4
|
+
|
3
5
|
module Crunchbase
|
4
6
|
# Get the Organization data from API
|
5
7
|
module Models
|
@@ -11,8 +13,10 @@ module Crunchbase
|
|
11
13
|
field_ids.map(&:to_sym)
|
12
14
|
end
|
13
15
|
|
14
|
-
def parse_response(response)
|
15
|
-
|
16
|
+
def parse_response(response, request_field_ids = [])
|
17
|
+
extract_fields = (request_field_ids.empty? ? field_ids : request_field_ids)
|
18
|
+
|
19
|
+
dynamic_attributes(self, extract_fields, response.dig('properties'))
|
16
20
|
end
|
17
21
|
|
18
22
|
def parse_cards_response(response)
|
@@ -25,7 +25,6 @@ module Crunchbase
|
|
25
25
|
lead_investor_identifiers
|
26
26
|
num_partners
|
27
27
|
num_relationships
|
28
|
-
permalink
|
29
28
|
pre_money_valuation
|
30
29
|
rank
|
31
30
|
rank_funding_round
|
@@ -37,6 +36,7 @@ module Crunchbase
|
|
37
36
|
%w[
|
38
37
|
uuid
|
39
38
|
name
|
39
|
+
permalink
|
40
40
|
announced_on
|
41
41
|
closed_on
|
42
42
|
investment_stage
|
@@ -1,29 +1,80 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../utilities/request'
|
4
|
+
require_relative '../utilities/cb_model'
|
5
|
+
|
3
6
|
module Crunchbase
|
4
7
|
# Whole Searches endpoints
|
5
8
|
module Searches
|
6
9
|
# Send request for entities endpoints
|
10
|
+
#
|
11
|
+
# API doc:
|
12
|
+
# https://app.swaggerhub.com/apis-docs/Crunchbase/crunchbase-enterprise_api/1.0.1#/Search/post_searches_organizations
|
13
|
+
#
|
14
|
+
# Notes
|
15
|
+
# 1. Only can filter `Searchable: Yes` fields
|
16
|
+
# 2. 'name', 'website' can not use
|
7
17
|
class Client
|
8
18
|
include ::Crunchbase::Utilities::Request
|
19
|
+
include ::Crunchbase::Utilities::CbModel
|
20
|
+
|
21
|
+
attr_accessor :total_count, :count, :entities, :entity_type, :conditions
|
9
22
|
|
10
23
|
ROOT_LIST = 'searches'
|
11
24
|
LIMIT = 100
|
12
25
|
|
13
|
-
def initialize(
|
14
|
-
@
|
15
|
-
@
|
26
|
+
def initialize(conditions, entity_type)
|
27
|
+
@conditions = conditions
|
28
|
+
@entity_type = entity_type
|
16
29
|
end
|
17
30
|
|
18
31
|
# Will include all attribute from API document
|
19
|
-
def
|
20
|
-
|
32
|
+
def searches
|
33
|
+
wrapping!(
|
34
|
+
search(
|
35
|
+
root_uri,
|
36
|
+
data_raw.to_s.gsub('=>', ':')
|
37
|
+
)
|
38
|
+
)
|
21
39
|
end
|
22
40
|
|
23
41
|
private
|
24
42
|
|
43
|
+
def wrapping!(response)
|
44
|
+
query_results = search_results(response.dig('entities'))
|
45
|
+
|
46
|
+
self.total_count = response['count']
|
47
|
+
self.entities = query_results
|
48
|
+
self.count = query_results.size
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
def search_results(entities)
|
53
|
+
entities.each_with_object([]) do |entity, objects|
|
54
|
+
objects << cbobject.parse_response(entity, field_ids)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
25
58
|
def root_uri
|
26
|
-
[ROOT_LIST,
|
59
|
+
[ROOT_LIST, kclass_name::RESOURCE_LIST].compact.join('/')
|
60
|
+
end
|
61
|
+
|
62
|
+
# Post request raw datas
|
63
|
+
def field_ids
|
64
|
+
@conditions['field_ids'] || cbobject.basis_fields
|
65
|
+
end
|
66
|
+
|
67
|
+
def limit
|
68
|
+
@conditions['limit'] || LIMIT
|
69
|
+
end
|
70
|
+
|
71
|
+
def data_raw
|
72
|
+
{
|
73
|
+
'field_ids' => field_ids,
|
74
|
+
'order' => @conditions['order'],
|
75
|
+
'query' => @conditions['query'],
|
76
|
+
'limit' => limit
|
77
|
+
}
|
27
78
|
end
|
28
79
|
end
|
29
80
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
# Utilities
|
5
|
+
module Utilities
|
6
|
+
# API Request
|
7
|
+
module CbModel
|
8
|
+
attr_accessor :entity_type
|
9
|
+
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def cbobject
|
13
|
+
kclass_name.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def kclass_name
|
17
|
+
@kclass_name ||= exact_kclass_object
|
18
|
+
end
|
19
|
+
|
20
|
+
def exact_kclass_object
|
21
|
+
return entity_type if entity_type.is_a?(Class)
|
22
|
+
|
23
|
+
cb_type = [
|
24
|
+
'Crunchbase',
|
25
|
+
'Models',
|
26
|
+
entity_type.split('_').map(&:capitalize).join
|
27
|
+
].join('::')
|
28
|
+
Kernel.const_get("::#{cb_type}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
# Utilities
|
5
|
+
module Utilities
|
6
|
+
# All Entity API endpoints
|
7
|
+
module EntityEndpoints
|
8
|
+
# For Entity
|
9
|
+
#
|
10
|
+
# API Parameters
|
11
|
+
#
|
12
|
+
# entity_id: UUID or permalink of desired entity
|
13
|
+
# card_id: A card to include on the resulting entity
|
14
|
+
# order: Field name with order direction (asc/desc)
|
15
|
+
# limit: Number of rows to return. Default is 100, min is 1, max is 100.
|
16
|
+
|
17
|
+
# Lookup an Organization or single card
|
18
|
+
def organization(entity_id, card_id: nil)
|
19
|
+
lookup_for('organization', entity_id, card_id)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Lookup Organization's all cards
|
23
|
+
def organization_cards(entity_id, cards: [])
|
24
|
+
entities('organization', entity_id).fetch_cards(cards)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Lookup a Person or single card
|
28
|
+
def person(entity_id, card_id: nil)
|
29
|
+
lookup_for('person', entity_id, card_id)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Lookup Person's all cards
|
33
|
+
def person_cards(entity_id)
|
34
|
+
entities('person', entity_id).fetch_cards
|
35
|
+
end
|
36
|
+
|
37
|
+
# Lookup a Funding Round or single card
|
38
|
+
def funding_round(entity_id, card_id: nil)
|
39
|
+
lookup_for('funding_round', entity_id, card_id)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Lookup Funding Round's all cards
|
43
|
+
def funding_round_cards(entity_id)
|
44
|
+
entities('funding_round', entity_id).fetch_cards
|
45
|
+
end
|
46
|
+
|
47
|
+
# Lookup an Acquisition or Single card
|
48
|
+
def acquisition(entity_id, card_id: nil)
|
49
|
+
lookup_for('acquisition', entity_id, card_id)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Lookup Acquisition's all card
|
53
|
+
def acquisition_cards(entity_id)
|
54
|
+
entities('acquisition', entity_id).fetch_cards
|
55
|
+
end
|
56
|
+
|
57
|
+
# Lookup an Investment or Single card
|
58
|
+
def investment(entity_id, card_id: nil)
|
59
|
+
lookup_for('investment', entity_id, card_id)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Lookup Investment's all card
|
63
|
+
def investment_cards(entity_id)
|
64
|
+
entities('investment', entity_id).fetch_cards
|
65
|
+
end
|
66
|
+
|
67
|
+
# Lookup an PressReference or Single card
|
68
|
+
def press_reference(entity_id, card_id: nil)
|
69
|
+
lookup_for('press_reference', entity_id, card_id)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Lookup PressReference's all card
|
73
|
+
def press_reference_cards(entity_id)
|
74
|
+
entities('press_reference', entity_id).fetch_cards
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def entities(entity_type, entity_id)
|
80
|
+
Crunchbase::Entities::Client.new(entity_id, entity_type)
|
81
|
+
end
|
82
|
+
|
83
|
+
def lookup_for(entity_type, entity_id, card_id)
|
84
|
+
kobject = entities(entity_type, entity_id)
|
85
|
+
return kobject.fetch if card_id.nil?
|
86
|
+
|
87
|
+
kobject.cards(card_id)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'faraday'
|
4
4
|
require 'faraday_middleware'
|
5
|
+
require 'faraday_curl'
|
6
|
+
require 'logger'
|
7
|
+
require_relative '../errors'
|
5
8
|
|
6
9
|
module Crunchbase
|
7
10
|
# Utilities
|
@@ -10,10 +13,14 @@ module Crunchbase
|
|
10
13
|
module Request
|
11
14
|
module_function
|
12
15
|
|
16
|
+
# Entity endpoints
|
17
|
+
#
|
18
|
+
# https://app.swaggerhub.com/apis-docs/Crunchbase/crunchbase-enterprise_api/1.0.1#/Entity/get_entities_organizations__entity_id_
|
13
19
|
def entity(uri, *args)
|
14
20
|
response = Faraday.new(url: BASE_URI, headers: headers) do |faraday|
|
15
21
|
faraday.adapter Faraday.default_adapter
|
16
22
|
faraday.response :json
|
23
|
+
faraday.response :logger, ::Logger.new(STDOUT), bodies: true if debug_mode?
|
17
24
|
end.get(uri, *args)
|
18
25
|
|
19
26
|
return response.body if response.status == 200
|
@@ -21,10 +28,15 @@ module Crunchbase
|
|
21
28
|
raise Error, response.reason_phrase
|
22
29
|
end
|
23
30
|
|
31
|
+
# Search endpoints
|
32
|
+
#
|
33
|
+
# https://app.swaggerhub.com/apis-docs/Crunchbase/crunchbase-enterprise_api/1.0.1#/Search/post_searches_organizations
|
24
34
|
def search(uri, args)
|
25
|
-
response = Faraday.new(url: BASE_URI, headers:
|
35
|
+
response = Faraday.new(url: BASE_URI, headers: post_headers) do |faraday|
|
26
36
|
faraday.adapter Faraday.default_adapter
|
27
37
|
faraday.response :json
|
38
|
+
faraday.request :curl, ::Logger.new(STDOUT), :warn if debug_mode?
|
39
|
+
faraday.response :logger, ::Logger.new(STDOUT), bodies: true if debug_mode?
|
28
40
|
end.post(uri, args)
|
29
41
|
|
30
42
|
return response.body if response.status == 200
|
@@ -34,6 +46,16 @@ module Crunchbase
|
|
34
46
|
|
35
47
|
private
|
36
48
|
|
49
|
+
def debug_mode?
|
50
|
+
Crunchbase.config.debug || false
|
51
|
+
end
|
52
|
+
|
53
|
+
def post_headers
|
54
|
+
headers.merge(
|
55
|
+
'Content-Type' => 'application/json'
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
37
59
|
def headers
|
38
60
|
{
|
39
61
|
'X-cb-user-key' => Crunchbase.config.user_key
|
@@ -10,18 +10,20 @@ module Crunchbase
|
|
10
10
|
def dynamic_attributes(object, attribute_names, response)
|
11
11
|
attribute_names.each do |attribute_name|
|
12
12
|
attribute_value = field_value(attribute_name, response)
|
13
|
+
dynamic_define_method(object, attribute_name, attribute_value)
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
instance_variable_set('@' + attribute_name, value)
|
18
|
-
end
|
16
|
+
[attribute_names & special_attributes].flatten.each do |attribute_name|
|
17
|
+
attribute_names.delete(attribute_name)
|
18
|
+
hash_datas = response&.dig(attribute_name)
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
values = hash_datas&.map { |k, v| v if %w[uuid permalink].include?(k) }&.compact || []
|
21
|
+
dynamic_define_method(object, attribute_name, values)
|
22
|
+
hash_datas&.keys&.each do |key|
|
23
|
+
next unless %w[uuid permalink].include?(key)
|
23
24
|
|
24
|
-
|
25
|
+
dynamic_define_method(object, key, hash_datas&.dig(key))
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
object
|
@@ -29,13 +31,32 @@ module Crunchbase
|
|
29
31
|
|
30
32
|
private
|
31
33
|
|
34
|
+
def dynamic_define_method(object, attribute_name, attribute_value)
|
35
|
+
# Manually creates methods for both getter and setter and then
|
36
|
+
# sends a message to the new setter with the attribute_value
|
37
|
+
object.class.send(:define_method, "#{attribute_name}=".to_sym) do |value|
|
38
|
+
instance_variable_set('@' + attribute_name, value)
|
39
|
+
end
|
40
|
+
|
41
|
+
object.class.send(:define_method, attribute_name.to_sym) do
|
42
|
+
instance_variable_get('@' + attribute_name.to_s)
|
43
|
+
end
|
44
|
+
|
45
|
+
object.send("#{attribute_name}=".to_sym, attribute_value)
|
46
|
+
end
|
47
|
+
|
48
|
+
# This is hash attributes
|
49
|
+
#
|
50
|
+
# 1. identifier
|
51
|
+
def special_attributes
|
52
|
+
%w[identifier]
|
53
|
+
end
|
54
|
+
|
32
55
|
def field_value(name, data)
|
33
56
|
value = data.dig(name)
|
34
57
|
|
35
58
|
return value if value.nil? || value.is_a?(String)
|
36
|
-
if value.is_a?(Array) && value[0].is_a?(Hash) && value[0].keys.include?('value')
|
37
|
-
return value.collect { |e| e.dig('value') }
|
38
|
-
end
|
59
|
+
return value.collect { |e| e.dig('value') } if value.is_a?(Array) && value[0].is_a?(Hash) && value[0].keys.include?('value')
|
39
60
|
return value.dig('value') if value.is_a?(Hash) && value.keys.include?('value')
|
40
61
|
|
41
62
|
value
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
# Utilities
|
5
|
+
module Utilities
|
6
|
+
# All Searches API endpoint
|
7
|
+
module SearchEndpoints
|
8
|
+
# For Searches
|
9
|
+
def search_organizations(raw_data)
|
10
|
+
searches(raw_data, 'organization').searches
|
11
|
+
end
|
12
|
+
|
13
|
+
def search_funding_rounds(raw_data)
|
14
|
+
searches(raw_data, 'funding_round').searches
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def searches(raw_data, scope_name)
|
20
|
+
Crunchbase::Searches::Client.new(raw_data, scope_name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Encore Shao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_curl
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: faraday_middleware
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,10 +108,10 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
|
-
description:
|
98
|
-
|
111
|
+
description: 'Crunchbase is a ruby wrapper base on Crunchbase V4 API. It provides
|
112
|
+
easy to get the API data by each endpoint. '
|
99
113
|
email:
|
100
|
-
- encore
|
114
|
+
- encore@ekohe.com
|
101
115
|
executables: []
|
102
116
|
extensions: []
|
103
117
|
extra_rdoc_files: []
|
@@ -124,6 +138,7 @@ files:
|
|
124
138
|
- lib/crunchbase/entities/client.rb
|
125
139
|
- lib/crunchbase/errors.rb
|
126
140
|
- lib/crunchbase/models.rb
|
141
|
+
- lib/crunchbase/models/acquisition.rb
|
127
142
|
- lib/crunchbase/models/category.rb
|
128
143
|
- lib/crunchbase/models/category_group.rb
|
129
144
|
- lib/crunchbase/models/entity.rb
|
@@ -134,19 +149,21 @@ files:
|
|
134
149
|
- lib/crunchbase/models/press_reference.rb
|
135
150
|
- lib/crunchbase/searches.rb
|
136
151
|
- lib/crunchbase/searches/client.rb
|
137
|
-
- lib/crunchbase/searches/organization.rb
|
138
152
|
- lib/crunchbase/utilities.rb
|
153
|
+
- lib/crunchbase/utilities/cb_model.rb
|
154
|
+
- lib/crunchbase/utilities/entity_endpoints.rb
|
139
155
|
- lib/crunchbase/utilities/request.rb
|
140
156
|
- lib/crunchbase/utilities/response.rb
|
157
|
+
- lib/crunchbase/utilities/search_endpoints.rb
|
141
158
|
- lib/crunchbase/version.rb
|
142
|
-
homepage: https://github.com/
|
159
|
+
homepage: https://github.com/ekohe/crunchbase4
|
143
160
|
licenses:
|
144
161
|
- MIT
|
145
162
|
metadata:
|
146
163
|
allowed_push_host: https://rubygems.org
|
147
|
-
homepage_uri: https://github.com/
|
148
|
-
source_code_uri: https://github.com/
|
149
|
-
changelog_uri: https://github.com/
|
164
|
+
homepage_uri: https://github.com/ekohe/crunchbase4
|
165
|
+
source_code_uri: https://github.com/ekohe/crunchbase4
|
166
|
+
changelog_uri: https://github.com/ekohe/crunchbase4/CHANGELOG.md
|
150
167
|
post_install_message: Thanks for installing!
|
151
168
|
rdoc_options: []
|
152
169
|
require_paths:
|
@@ -165,5 +182,5 @@ requirements: []
|
|
165
182
|
rubygems_version: 3.0.3
|
166
183
|
signing_key:
|
167
184
|
specification_version: 4
|
168
|
-
summary:
|
185
|
+
summary: Crunchbase is a ruby wrapper base on Crunchbase V4 API
|
169
186
|
test_files: []
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Crunchbase
|
4
|
-
# Whole Searches endpoints
|
5
|
-
module Searches
|
6
|
-
# Send request for entities endpoints
|
7
|
-
class Organization < Client
|
8
|
-
include ::Crunchbase::Utilities::Request
|
9
|
-
|
10
|
-
def endpoint
|
11
|
-
::Crunchbase::Models::Organization::RESOURCE_LIST
|
12
|
-
end
|
13
|
-
|
14
|
-
def query_conditions
|
15
|
-
{
|
16
|
-
"field_ids": field_ids,
|
17
|
-
"order": orders,
|
18
|
-
"query": conditions,
|
19
|
-
"limit": LIMIT
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def field_ids
|
26
|
-
::Crunchbase::Models::Organization.new.basis_fields
|
27
|
-
end
|
28
|
-
|
29
|
-
def orders
|
30
|
-
[
|
31
|
-
{
|
32
|
-
"field_id": 'name',
|
33
|
-
"sort": 'asc'
|
34
|
-
}
|
35
|
-
]
|
36
|
-
end
|
37
|
-
|
38
|
-
def conditions
|
39
|
-
[
|
40
|
-
{
|
41
|
-
"type": 'predicate',
|
42
|
-
"field_id": @field,
|
43
|
-
"operator_id": 'includes',
|
44
|
-
"values": [
|
45
|
-
@value
|
46
|
-
]
|
47
|
-
}
|
48
|
-
]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|