crunchbase4 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb7a01707e086f0d73d6a92807f4d0a9e2dfab44e73647254781103792817373
4
- data.tar.gz: b61240087a0344caf96bb065fa9c309f83e19d2357d805f74278cf2bda9381cc
3
+ metadata.gz: 305bc09f8a83e2c4413f2e1dd7081b371b118e6e40727c9770e9c816f50d7e5b
4
+ data.tar.gz: e8c2c700770b5e08be5a69e613c6381877b9d1a5b551fe96114185eae2b8ce26
5
5
  SHA512:
6
- metadata.gz: b08389e81858a042b5204787ef8c25a78f712f23688cfb40e81a428298205748158d2e5380a9a24551b896c103212dab8b10b183e4d5ef8d357fb0b0c02f3515
7
- data.tar.gz: cc99c470c8838170978d862a738283ca2481bbf75deeeb9e4760b46902321ddd3469e31e6e01183917cea54794a20187c0b1648ba2962ce675a1bf6ccac3bea1
6
+ metadata.gz: f6423c5de66af723a227aac874dafb6815921cd7e3ee4efe1015adaf551b46ff55eac7335b496caae71909e0507e210139579507f516d2f2090fdd8cc4d0fb1d
7
+ data.tar.gz: 7601a5f4c815c59c12c855694d7a7e497456eed498c1a1c15d396fec9197bf7c6c3fc0d276d3dbcf7d8acb2a2f0cf85cb63874c0c68cdedc8c49b6b07d0e1c5b
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.1.3] - 2020-06-09
6
+
7
+ ### Added
8
+ - Implemented `deleted_entities` API to allow user get deleted entities by collection_ids
9
+ - Implemented `fetch(entity_id, card_id)` API, allow user get the entity with card_id data
10
+
5
11
  ## [0.1.2] - 2020-06-07
6
12
 
7
13
  ### Added
@@ -9,7 +15,7 @@ All notable changes to this project will be documented in this file.
9
15
  - organzations
10
16
  - people
11
17
  - funding rounds
12
- - Implemented autocomplete API to allow user filter entities by keyword
18
+ - Implemented `autocompletes` API to allow user filter entities by keyword
13
19
  - organzations
14
20
  - people
15
21
  - funding rounds
@@ -31,4 +37,4 @@ All notable changes to this project will be documented in this file.
31
37
 
32
38
  ## [0.0.0] - 2020-06-01
33
39
 
34
- - Learning the Crunchbase V4 document and ready to create the new Gem
40
+ - Learning the Crunchbase V4 API changes then creating the Gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crunchbase4 (0.1.2)
4
+ crunchbase4 (0.1.3)
5
5
  faraday
6
6
  faraday_curl
7
7
  faraday_middleware
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Crunchbase
2
2
 
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)
3
+ Crunchbase is a ruby wrapper based 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)
@@ -23,34 +23,97 @@ Or install it yourself as:
23
23
 
24
24
  ## Getting Started
25
25
 
26
- ### Configure your API certificate
26
+ #### Configure your certificate for API
27
27
 
28
- ```
28
+ ```ruby
29
29
  require 'crunchbase4'
30
30
 
31
31
  CB_CONFIG = YAML.load(File.read('crunchbase.yml'))
32
- Crunchbase.config do |c|
33
- c.user_key = CB_CONFIG['user_key']
34
- end
35
-
36
- OR
37
-
38
32
  Crunchbase.config.user_key = CB_CONFIG['user_key']
39
33
  ```
40
34
 
41
35
  ## Usage
42
36
 
43
- ### The first step is to build an API client
37
+ #### Class: `Client` for API
44
38
 
45
39
  ```
46
40
  pry(main)> client = Crunchbase::Client.new
47
41
  ```
48
42
 
43
+ #### API request for endpoint we completed
44
+
45
+ - [Entity](https://github.com/ekohe/crunchbase4#entity)
46
+ - organizations
47
+ - people
48
+ - funding_rounds
49
+ - [Searches](https://github.com/ekohe/crunchbase4#search)
50
+ - [Autocompletes](https://github.com/ekohe/crunchbase4#autocompletes)
51
+ - [Deleted Entities](https://github.com/ekohe/crunchbase4#deleted-entities)
52
+
53
+ ```ruby
54
+ <!-- Entity -->
55
+ response = client.organization('ekohe')
56
+ response = client.organization('ekohe', 'ipos')
57
+ response = client.person('mark-zuckerberg')
58
+ response = client.person('mark-zuckerberg', 'participated_investments')
59
+ response = client.funding_round('371c20af8aa94bcba8da0694d138f247')
60
+ response = client.funding_round('371c20af8aa94bcba8da0694d138f247', 'investments')
61
+ response = client.acquisition('7638eae9-07b7-4fc6-ad20-5d99de3ff928')
62
+
63
+ <!-- Search -->
64
+ client.search_organizations(query_data)
65
+ client.search_people(query_data)
66
+ client.search_funding_rounds(query_data)
67
+ client.recent_updates({
68
+ scope_name: 'organization',
69
+ field_ids: %w[name website permalink],
70
+ date: '2020-05-05',
71
+ limit: 100
72
+ })
73
+
74
+ <!-- Autocompletes -->
75
+ response = client.autocomplete_organizations('ekohe')
76
+ response = client.autocomplete_people('encore')
77
+ response = client.autocomplete_funding_rounds('facebook')
78
+
79
+ <!-- Deleted Entities -->
80
+ response = client.deledeted_organizations
81
+ response = client.deledeted_people
82
+ response = client.deledeted_funding_rounds
83
+ ```
84
+
85
+ #### Module: Utils
86
+
87
+ * We return all the original data from CrunchBase without any conversion. So you want to use the converted data, you can use this tool to convert.
88
+
89
+ ```ruby
90
+ pry(main)> Crunchbase::Utils.constants
91
+ => [:QUERY_OPERATORS,
92
+ :COMPANY_TYPES,
93
+ :FACET_IDS,
94
+ :IPO_STATUS,
95
+ :FUNDING_STAGES,
96
+ :FUNDING_TYPES,
97
+ :CURRENCY_ENUM,
98
+ :DATE_PRECISIONS,
99
+ :LAYOUT_IDS,
100
+ :NUM_EMPLOYEES_ENUM,
101
+ :OPERATING_STATUS,
102
+ :PROGRAM_TYPES,
103
+ :REVENUE_RANGES,
104
+ :SCHOOL_METHODS,
105
+ :SCHOOL_TYPES,
106
+ :STATUS,
107
+ :STOCK_EXCHANGE_SYMBOLS]
108
+ pry(main)> Crunchbase::Utils::COMPANY_TYPES
109
+ => {"for_profit"=>"For Profit", "non_profit"=>"Non-profit"}
110
+ ```
111
+
49
112
  ### Entity
50
113
 
51
114
  #### Get the organization data
52
115
 
53
- ```
116
+ ```ruby
54
117
  pry(main)> response = client.organization('ekohe')
55
118
  => #<Crunchbase::Models::Organization:0x00007fbc5cfdf2f8
56
119
  @categories=["Apps", "Artificial Intelligence", "Big Data", "E-Commerce", "Enterprise Software", "FinTech", "iOS", "Retail", "UX Design"],
@@ -68,9 +131,9 @@ pry(main)> response.permalink
68
131
 
69
132
  Or, if you want to use json data, please call `response.as_json` in your project.
70
133
 
71
- #### Get the person data
134
+ ##### Get the person data
72
135
 
73
- ```
136
+ ```ruby
74
137
  pry(main)> response = client.person('mark-zuckerberg')
75
138
  => #<Crunchbase::Models::Person:0x00007ffbf201d178
76
139
  @aliases=["Zuck"],
@@ -89,9 +152,9 @@ pry(main)> response.permalink
89
152
  => "mark-zuckerberg"
90
153
  ```
91
154
 
92
- #### Get the funding round data
155
+ ##### Get the funding round data
93
156
 
94
- ```
157
+ ```ruby
95
158
  => #<Crunchbase::Client:0x00007f8806824c28>
96
159
  pry(main)> response = client.funding_round('371c20af-8aa9-4bcb-a8da-0694d138f247')
97
160
  => #<Crunchbase::Models::FundingRound:0x00007f8806b55ca8
@@ -113,9 +176,9 @@ pry(main)> response.uuid
113
176
  => "371c20af-8aa9-4bcb-a8da-0694d138f247"
114
177
  ```
115
178
 
116
- #### Get the acquisition data
179
+ ##### Get the acquisition data
117
180
 
118
- ```
181
+ ```ruby
119
182
  pry(main)> response = client.acquisition('7638eae9-07b7-4fc6-ad20-5d99de3ff928')
120
183
  => #<Crunchbase::Models::Acquisition:0x00007fa01134da60
121
184
  @acquiree_categories=["Communities", "Internet", "Photo Sharing", "Publishing", "Search Engine", "Social Media"],
@@ -130,9 +193,9 @@ pry(main)> response.acquiree_funding_total
130
193
  => 150949998
131
194
  ```
132
195
 
133
- #### Get the press reference data
196
+ ##### Get the press reference data
134
197
 
135
- ```
198
+ ```ruby
136
199
  pry(main)> response = client.press_reference('0171b30e-9cf8-4ad5-8288-2993e4308e0f')
137
200
  => #<Crunchbase::Models::PressReference:0x00007fce2d33dbc0
138
201
  @activity_entities=["Facebook", "General Atlantic", "KKR", "Reliance Industries", "Vista Equity Partners"],
@@ -149,9 +212,9 @@ pry(main)> response = client.press_reference('0171b30e-9cf8-4ad5-8288-2993e4308e
149
212
  @uuid="0171b30e-9cf8-4ad5-8288-2993e4308e0f">
150
213
  ```
151
214
 
152
- #### Get the investment data
215
+ ##### Get the investment data
153
216
 
154
- ```
217
+ ```ruby
155
218
  pry(main)> response = client.investment('1368da0c-07b0-46ef-9a86-b518367e60d6')
156
219
  => #<Crunchbase::Models::Investment:0x00007f8c15105830
157
220
  @announced_on="2013-06-30",
@@ -177,7 +240,7 @@ pry(main)> response = client.investment('1368da0c-07b0-46ef-9a86-b518367e60d6')
177
240
 
178
241
  * Search query parameters for each endpoint
179
242
 
180
- ```
243
+ ```ruby
181
244
  {
182
245
  "field_ids": [],
183
246
  "query": [],
@@ -186,13 +249,13 @@ pry(main)> response = client.investment('1368da0c-07b0-46ef-9a86-b518367e60d6')
186
249
  }
187
250
  ```
188
251
 
189
- #### Get the latest updated entities
252
+ ##### Get the latest updated entities
190
253
 
191
254
  Allow user using the method `recent_updates(args)` to get recent updates for each endpoint on searches
192
255
 
193
- # Example to get recent updated organizations
256
+ * Example to get recent updated organizations
194
257
 
195
- ```
258
+ ```ruby
196
259
  args = {
197
260
  scope_name: 'organization', # must
198
261
  date: '2020-05-05', # must
@@ -205,11 +268,11 @@ args = {
205
268
  response = client.recent_updates(args)
206
269
  ```
207
270
 
208
- #### Search organizations by query conditions and order
271
+ ##### Search organizations by query conditions and order
209
272
 
210
- * Step1: Needs to build the query conditions
273
+ * building the query conditions
211
274
 
212
- ```
275
+ ```ruby
213
276
  query_data = {
214
277
  'field_ids' => %w[
215
278
  name
@@ -253,7 +316,7 @@ query_data = {
253
316
 
254
317
  * Use `client` to send a request and parse response
255
318
 
256
- ```
319
+ ```ruby
257
320
  pry(main)> response = client.search_organizations(query_data)
258
321
  => #<Crunchbase::Searches::Client:0x00007fdfc1ad6eb8
259
322
  @conditions=
@@ -294,15 +357,15 @@ pry(main)> response = client.search_organizations(query_data)
294
357
  @total_count=44871>
295
358
  ```
296
359
 
297
- - Get all entities: `response.entities`
298
- - Get total count: `response.total_count`
299
- - Get entities count: `response.count`
360
+ - Get entities: response.entities
361
+ - Get total count: response.total_count
362
+ - Get entities count: response.count
300
363
 
301
- #### Search people by query conditions and order
364
+ ##### Search people by query conditions and order
302
365
 
303
- * Step1: Needs to build the query conditions
366
+ * building the query conditions
304
367
 
305
- ```
368
+ ```ruby
306
369
  query_data = {
307
370
  'field_ids' => %w[
308
371
  first_name
@@ -342,7 +405,7 @@ query_data = {
342
405
 
343
406
  * Use `client` to send a request and parse response
344
407
 
345
- ```
408
+ ```ruby
346
409
  pry(main)> response = client.search_people(query_data)
347
410
  => #<Crunchbase::Searches::Client:0x00007f9acca12d18
348
411
  @conditions=
@@ -362,15 +425,15 @@ pry(main)> response.total_count
362
425
  => 1
363
426
  ```
364
427
 
365
- ## Autocompletes
428
+ ### Autocompletes
366
429
 
367
- ### Allow users to filter by keyword from these endpoints
430
+ ##### Allow users to filter by keyword from these endpoints
368
431
 
369
432
  Search by keyword has been supported in "Organization", "People" and "Fund Round"
370
433
 
371
- 1. Example: Search in an organization by keyword
434
+ * Search in an organization by keyword
372
435
 
373
- ```
436
+ ```ruby
374
437
  pry(main)> response = client.autocomplete_organizations('ekohe')
375
438
  => #<Crunchbase::Autocompletes::Client:0x00007fecb34ce1e8
376
439
  @conditions={:query=>"ekohe", :collection_ids=>"organizations"},
@@ -400,9 +463,9 @@ pry(main)> response.count
400
463
  pry(main)> response.total_count
401
464
  ```
402
465
 
403
- 2. Example: Search in an people by keyword
466
+ * Search in an people by keyword
404
467
 
405
- ```
468
+ ```ruby
406
469
  pry(main)> response = client.autocomplete_people('maxime')
407
470
  => #<Crunchbase::Autocompletes::Client:0x00007fecb474f9c0
408
471
  @conditions={:query=>"maxime", :collection_ids=>"people"},
@@ -431,10 +494,11 @@ pry(main)> response.entities
431
494
  pry(main)> response.count
432
495
  pry(main)> response.total_count
433
496
  ```
434
- 2. Example: Search in an funding rounds by keyword
435
497
 
436
- ```
437
- pry(main)> pry(main)> response = client.autocomplete_funding_rounds('facebook')
498
+ * Search in an funding rounds by keyword
499
+
500
+ ```ruby
501
+ pry(main)> response = client.autocomplete_funding_rounds('facebook')
438
502
  => #<Crunchbase::Autocompletes::Client:0x00007fecb4dd66b8
439
503
  @conditions={:query=>"facebook", :collection_ids=>"funding_rounds"},
440
504
  @count=25,
@@ -463,38 +527,42 @@ pry(main)> response.count
463
527
  pry(main)> response.total_count
464
528
  ```
465
529
 
466
- ## Development
530
+ ### Deleted Entities
467
531
 
468
- 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.
532
+ * Get deleted entities by collection_ids
469
533
 
470
- ### Examples of API requests for each endpoint
534
+ ```ruby
535
+ pry(main)> response = client.deleted_organizations
536
+ => #<Crunchbase::DeletedEntities::Client:0x00007fa9196b6498
537
+ @conditions={:collection_ids=>"organizations"},
538
+ @count=1000,
539
+ @entities=
540
+ [#<Crunchbase::Models::DeletedEntity:0x00007fa9197f9df0 @deleted_at="2020-06-06T11:51:34Z", @entity_def_id="organization", @identifier=[], @uuid="31e5d1dd-3a7d-4c8c-b7dc-4780d391bbc3">,
541
+ #<Crunchbase::Models::DeletedEntity:0x00007fa9197f8fb8 @deleted_at="2020-06-06T10:43:10Z", @entity_def_id="organization", @identifier=[], @uuid="31d2ba51-ef94-4039-a6fc-22e5c1f0ed80">,
542
+ #<Crunchbase::Models::DeletedEntity:0x00007fa9197f86a8 @deleted_at="2020-06-05T18:32:20Z", @entity_def_id="organization", @identifier=[], @uuid="3f105ec3-606c-4779-85c8-29ec78d67d2d">,
543
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91981fd48 @deleted_at="2020-06-05T15:01:59Z", @entity_def_id="organization", @identifier=[], @uuid="e66d053a-86fa-4f5f-9c98-1d4b3ed0778d">,
544
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91981f438 @deleted_at="2020-06-05T13:17:39Z", @entity_def_id="organization", @identifier=[], @uuid="014de711-a0b0-4e29-a8ce-5f8c2696d9af">,
545
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91981eb28 @deleted_at="2020-06-05T13:09:11Z", @entity_def_id="organization", @identifier=[], @uuid="8b3102a2-04cc-4fb2-85cb-b2aa55662291">,
546
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91981e218 @deleted_at="2020-06-05T11:47:50Z", @entity_def_id="organization", @identifier=[], @uuid="62ae4ffc-a999-4c09-8c42-eef26be606aa">,
547
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91981d908 @deleted_at="2020-06-05T11:47:34Z", @entity_def_id="organization", @identifier=[], @uuid="7aa08989-f6ef-427c-96ac-7e1482a7eec1">,
548
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91981cff8 @deleted_at="2020-06-05T11:46:13Z", @entity_def_id="organization", @identifier=[], @uuid="7a6a5e41-d396-437a-9dfb-8539ef554268">,
549
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91981c6e8 @deleted_at="2020-06-05T11:45:21Z", @entity_def_id="organization", @identifier=[], @uuid="10db5120-a638-40eb-b636-e7cca20708e0">,
550
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91982fd88 @deleted_at="2020-06-05T11:45:01Z", @entity_def_id="organization", @identifier=[], @uuid="86c09840-b344-4687-a5ee-e5ea851b0b94">,
551
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91982f478 @deleted_at="2020-06-05T11:44:07Z", @entity_def_id="organization", @identifier=[], @uuid="2ac345e0-f6a0-4352-b66b-3254d4616c87">,
552
+ #<Crunchbase::Models::DeletedEntity:0x00007fa91982eb68 @deleted_at="2020-06-05T11:43:23Z", @entity_def_id="organization", @identifier=[], @uuid="9fa9c806-bc1b-49e6-81f4-719cbfd7928e">,
553
+ ....]
554
+ pry(main)> response.entities
555
+ pry(main)> response.count
556
+ pry(main)> response.total_count
471
557
 
558
+ # Get deleted people and funding rounds
559
+ pry(main)> response = client.deleted_people
560
+ pry(main)> response = client.deleted_funding_rounds
472
561
  ```
473
- Crunchbase.config.user_key = 'user_key'
474
- client = Crunchbase::Client.new
475
-
476
- <!-- Entity -->
477
- response = client.organization('ekohe')
478
- response = client.person('mark-zuckerberg')
479
- response = client.funding_round('371c20af8aa94bcba8da0694d138f247')
480
- response = client.acquisition('7638eae9-07b7-4fc6-ad20-5d99de3ff928')
481
562
 
482
- <!-- Search -->
483
- client.search_organizations(query_data)
484
- client.search_people(query_data)
485
- client.search_funding_rounds(query_data)
486
- client.recent_updates({
487
- scope_name: 'organization',
488
- field_ids: %w[name website permalink],
489
- date: '2020-05-05',
490
- limit: 100
491
- })
563
+ ## Development
492
564
 
493
- <!-- Autocompletes -->
494
- response = client.autocomplete_organizations('ekohe')
495
- response = client.autocomplete_people('encore')
496
- response = client.autocomplete_funding_rounds('facebook')
497
- ```
565
+ 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.
498
566
 
499
567
  ## Changelog
500
568
 
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ['encore@ekohe.com']
10
10
 
11
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. '
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
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')
@@ -26,7 +26,7 @@ module Crunchbase
26
26
 
27
27
  # Will include all attribute from API document
28
28
  def autocompletes
29
- wrapping!(
29
+ wrapping_autocomplete_entities!(
30
30
  get(
31
31
  ROOT_LIST,
32
32
  autocompletes_parameters
@@ -36,7 +36,7 @@ module Crunchbase
36
36
 
37
37
  private
38
38
 
39
- def wrapping!(response)
39
+ def wrapping_autocomplete_entities!(response)
40
40
  query_results = search_results(response.dig('entities'))
41
41
 
42
42
  self.total_count = response['count']
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../utilities/request'
4
+ require_relative '../utilities/cb_model'
5
+
6
+ module Crunchbase
7
+ # Retrieve deleted entities
8
+ module DeletedEntities
9
+ # Send request for deleted_entities endpoint
10
+ class Client
11
+ include ::Crunchbase::Utilities::Request
12
+ include ::Crunchbase::Utilities::CbModel
13
+
14
+ attr_accessor :total_count, :count, :entities, :conditions, :entity_type
15
+
16
+ ROOT_LIST = 'deleted_entities'
17
+ LIMIT = 1000
18
+
19
+ def initialize(raw_data)
20
+ @conditions = raw_data
21
+ @entity_type = 'deleted_entity'
22
+ end
23
+
24
+ # Will include all attribute from API document
25
+ def deleted_entities
26
+ wrapping_deleted_entities!(
27
+ deleted(
28
+ ROOT_LIST,
29
+ deleted_entities_parameters
30
+ )
31
+ )
32
+ end
33
+
34
+ private
35
+
36
+ def wrapping_deleted_entities!(response)
37
+ query_results = search_results(response)
38
+
39
+ self.total_count = response.size
40
+ self.entities = query_results
41
+ self.count = query_results.size
42
+ self
43
+ end
44
+
45
+ # One item of organization
46
+ #
47
+ # {
48
+ # "identifier"=>
49
+ # {
50
+ # "uuid"=>"9fe491b2-b6a1-5c87-0f4d-226dd0cc97a9",
51
+ # "value"=>"Ekohe",
52
+ # "image_id"=>"v1500646625/zhionn8nlgbkz4lj7ilz.png",
53
+ # "permalink"=>"ekohe",
54
+ # "entity_def_id"=>"organization"
55
+ # },
56
+ # "deleted_at"=> string($date-time)
57
+ # }
58
+ def search_results(entities)
59
+ entities.each_with_object([]) do |entity, objects|
60
+ objects << cbobject.parse_response(entity)
61
+ end
62
+ end
63
+
64
+ def deleted_entities_parameters
65
+ @conditions.merge(limit: @conditions[:limit] || LIMIT)
66
+ end
67
+ end
68
+ end
69
+ end
@@ -28,17 +28,21 @@ module Crunchbase
28
28
 
29
29
  # Only include a part basis fields of endpoint
30
30
  def fetch_cards(card_names = [])
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
- ))
31
+ cbobject.parse_response(entity(
32
+ root_uri,
33
+ field_ids: cbobject.basis_fields.join(','),
34
+ cards: (cbobject.full_cards & card_names).join(',')
35
+ ), cbobject.basis_fields, card_names)
36
36
  end
37
37
 
38
38
  def cards(card_id)
39
+ raise Crunchbase::Error, 'Invalid card_id' unless cbobject.full_cards.include?(card_id)
40
+
39
41
  cbobject.parse_response(entity(
40
- root_uri(name: __method__, id: card_id)
41
- ))
42
+ root_uri(name: __method__, id: card_id),
43
+ field_ids: cbobject.basis_fields.join(','),
44
+ card_field_ids: cbobject.card_model_mappings[card_id].new.field_ids.join(',')
45
+ ), cbobject.basis_fields, [card_id])
42
46
  end
43
47
 
44
48
  private
@@ -5,6 +5,7 @@ module Crunchbase
5
5
  module Models
6
6
  autoload :Entity, 'crunchbase/models/entity'
7
7
  autoload :AutocompleteEntity, 'crunchbase/models/autocomplete_entity'
8
+ autoload :DeletedEntity, 'crunchbase/models/deleted_entity'
8
9
  autoload :Organization, 'crunchbase/models/organization'
9
10
  autoload :Person, 'crunchbase/models/person'
10
11
  autoload :FundingRound, 'crunchbase/models/funding_round'
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crunchbase
4
+ # Get the Entities data from API
5
+ module Models
6
+ # For AutocompleteEntity
7
+ class DeletedEntity < Entity
8
+ def field_ids
9
+ basis_fields
10
+ end
11
+
12
+ def basis_fields
13
+ %w[
14
+ uuid
15
+ entity_def_id
16
+ deleted_at
17
+ identifier
18
+ ]
19
+ end
20
+
21
+ def parse_response(response)
22
+ dynamic_attributes(self, field_ids, response)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -13,20 +13,60 @@ module Crunchbase
13
13
  field_ids.map(&:to_sym)
14
14
  end
15
15
 
16
- def parse_response(response, request_field_ids = [])
16
+ def parse_response(response, request_field_ids = [], cards = [])
17
17
  extract_fields = (request_field_ids.empty? ? field_ids : request_field_ids)
18
18
 
19
19
  dynamic_attributes(self, extract_fields, response.dig('properties'))
20
+ setup_relationships(self, cards, response.dig('cards'))
21
+ self
20
22
  end
21
23
 
22
- def parse_cards_response(response)
23
- parse_response(response, response.dig('properties'))
24
- # response.dig('cards')
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
25
41
  end
26
42
 
27
43
  def as_json
28
44
  fields.each_with_object({}) { |item, hash| hash[item] = send(item) }
29
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
30
70
  end
31
71
  end
32
72
  end
@@ -34,19 +34,19 @@ module Crunchbase
34
34
  # collection_ids: 'organizations'
35
35
  # }
36
36
  def autocomplete_organizations(keyword)
37
- autocompletes(wrapper_query_data(keyword, 'organizations'))
37
+ autocompletes(wrapper_autocompletes_data(keyword, 'organizations'))
38
38
  end
39
39
 
40
40
  def autocomplete_people(keyword)
41
- autocompletes(wrapper_query_data(keyword, 'people'))
41
+ autocompletes(wrapper_autocompletes_data(keyword, 'people'))
42
42
  end
43
43
 
44
44
  def autocomplete_funding_rounds(keyword)
45
- autocompletes(wrapper_query_data(keyword, 'funding_rounds'))
45
+ autocompletes(wrapper_autocompletes_data(keyword, 'funding_rounds'))
46
46
  end
47
47
 
48
48
  def autocomplete_press_references(keyword)
49
- autocompletes(wrapper_query_data(keyword, 'press_references'))
49
+ autocompletes(wrapper_autocompletes_data(keyword, 'press_references'))
50
50
  end
51
51
 
52
52
  private
@@ -55,7 +55,7 @@ module Crunchbase
55
55
  Crunchbase::Autocompletes::Client.new(raw_data).autocompletes
56
56
  end
57
57
 
58
- def wrapper_query_data(keyword, collection_ids)
58
+ def wrapper_autocompletes_data(keyword, collection_ids)
59
59
  {
60
60
  query: keyword,
61
61
  collection_ids: collection_ids
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../deleted_entities/client'
4
+
3
5
  module Crunchbase
4
6
  # Utilities
5
7
  module Utilities
@@ -9,7 +11,53 @@ module Crunchbase
9
11
  #
10
12
  # Retrieve deleted entities
11
13
  # Retrieve deleted entities for a collection id
12
- def deleted_entities(collection_id: nil); end
14
+ #
15
+ # API doc:
16
+ # https://app.swaggerhub.com/apis-docs/Crunchbase/crunchbase-enterprise_api/1.0.1#/Deleted%20Entities/get_deleted_entities
17
+ #
18
+ # Parameters:
19
+ # collection_ids: string
20
+ # Filter by collection id(s). Comma separated list of collection ids.
21
+ # E.g.
22
+ # organizations, people, funding_rounds, acquisitions, investments,
23
+ # events, press_references, funds, event_appearances, ipos, ownerships,
24
+ # categories, category_groups, locations, jobs
25
+ # before_id: string
26
+ # Used to paginate search results to the previous page. before_id should be the uuid of the first item in the current page.
27
+ # May not be provided simultaneously with after_id.
28
+ # after_id: string
29
+ # Used to paginate search results to the next page. after_id should be the uuid of the last item in the current page.
30
+ # May not be provided simultaneously with before_id.
31
+ # limit: integer
32
+ # Number of rows to return. Default is 100, min is 1, max is 1000.
33
+ # deleted_at_order: string
34
+ # Direction of sorting by deleted_at property
35
+ # Available values : asc, desc
36
+ def deleted_organizations(args = {})
37
+ deleted_entities(wrapper_deleted_entities_data(args, 'organizations'))
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'))
50
+ end
51
+
52
+ private
53
+
54
+ def deleted_entities(raw_data)
55
+ Crunchbase::DeletedEntities::Client.new(raw_data).deleted_entities
56
+ end
57
+
58
+ def wrapper_deleted_entities_data(args, collection_ids = nil)
59
+ args.merge!(collection_ids: collection_ids)
60
+ end
13
61
  end
14
62
  end
15
63
  end
@@ -30,8 +30,8 @@ module Crunchbase
30
30
  end
31
31
 
32
32
  # Lookup Person's all cards
33
- def person_cards(entity_id)
34
- entities('person', entity_id).fetch_cards
33
+ def person_cards(entity_id, cards: [])
34
+ entities('person', entity_id).fetch_cards(cards)
35
35
  end
36
36
 
37
37
  # Lookup a Funding Round or single card
@@ -40,8 +40,8 @@ module Crunchbase
40
40
  end
41
41
 
42
42
  # Lookup Funding Round's all cards
43
- def funding_round_cards(entity_id)
44
- entities('funding_round', entity_id).fetch_cards
43
+ def funding_round_cards(entity_id, cards: [])
44
+ entities('funding_round', entity_id).fetch_cards(cards)
45
45
  end
46
46
 
47
47
  # Lookup an Acquisition or Single card
@@ -50,8 +50,8 @@ module Crunchbase
50
50
  end
51
51
 
52
52
  # Lookup Acquisition's all card
53
- def acquisition_cards(entity_id)
54
- entities('acquisition', entity_id).fetch_cards
53
+ def acquisition_cards(entity_id, cards: [])
54
+ entities('acquisition', entity_id).fetch_cards(cards)
55
55
  end
56
56
 
57
57
  # Lookup an Investment or Single card
@@ -60,8 +60,8 @@ module Crunchbase
60
60
  end
61
61
 
62
62
  # Lookup Investment's all card
63
- def investment_cards(entity_id)
64
- entities('investment', entity_id).fetch_cards
63
+ def investment_cards(entity_id, cards: [])
64
+ entities('investment', entity_id).fetch_cards(cards)
65
65
  end
66
66
 
67
67
  # Lookup an PressReference or Single card
@@ -70,8 +70,8 @@ module Crunchbase
70
70
  end
71
71
 
72
72
  # Lookup PressReference's all card
73
- def press_reference_cards(entity_id)
74
- entities('press_reference', entity_id).fetch_cards
73
+ def press_reference_cards(entity_id, cards: [])
74
+ entities('press_reference', entity_id).fetch_cards(cards)
75
75
  end
76
76
 
77
77
  # Lookup an Ipo or Single card
@@ -80,8 +80,8 @@ module Crunchbase
80
80
  end
81
81
 
82
82
  # Lookup Ipo's all card
83
- def ipo_cards(entity_id)
84
- entities('ipo', entity_id).fetch_cards
83
+ def ipo_cards(entity_id, cards: [])
84
+ entities('ipo', entity_id).fetch_cards(cards)
85
85
  end
86
86
 
87
87
  private
@@ -18,6 +18,10 @@ module Crunchbase
18
18
  fetch_request(uri, *args)
19
19
  end
20
20
 
21
+ def deleted(uri, *args)
22
+ fetch_request(uri, *args)
23
+ end
24
+
21
25
  # Entity endpoints
22
26
  #
23
27
  # https://app.swaggerhub.com/apis-docs/Crunchbase/crunchbase-enterprise_api/1.0.1#/Entity/get_entities_organizations__entity_id_
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crunchbase
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
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.2
4
+ version: 0.1.3
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-07 00:00:00.000000000 Z
11
+ date: 2020-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -108,7 +108,7 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: 'Crunchbase is a ruby wrapper base on Crunchbase V4 API. It provides
111
+ description: 'Crunchbase is a ruby wrapper base on Crunchbase V4 API. it provides
112
112
  easy to get the API data by each endpoint. '
113
113
  email:
114
114
  - encore@ekohe.com
@@ -135,6 +135,7 @@ files:
135
135
  - lib/crunchbase/autocompletes/client.rb
136
136
  - lib/crunchbase/client.rb
137
137
  - lib/crunchbase/config.rb
138
+ - lib/crunchbase/deleted_entities/client.rb
138
139
  - lib/crunchbase/entities.rb
139
140
  - lib/crunchbase/entities/client.rb
140
141
  - lib/crunchbase/errors.rb
@@ -143,6 +144,7 @@ files:
143
144
  - lib/crunchbase/models/autocomplete_entity.rb
144
145
  - lib/crunchbase/models/category.rb
145
146
  - lib/crunchbase/models/category_group.rb
147
+ - lib/crunchbase/models/deleted_entity.rb
146
148
  - lib/crunchbase/models/entity.rb
147
149
  - lib/crunchbase/models/funding_round.rb
148
150
  - lib/crunchbase/models/investment.rb