crunchbase4 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +35 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +0 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +139 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/crunchbase4.gemspec +44 -0
- data/lib/crunchbase.rb +16 -0
- data/lib/crunchbase/client.rb +47 -0
- data/lib/crunchbase/config.rb +18 -0
- data/lib/crunchbase/entities.rb +8 -0
- data/lib/crunchbase/entities/client.rb +52 -0
- data/lib/crunchbase/errors.rb +5 -0
- data/lib/crunchbase/models.rb +15 -0
- data/lib/crunchbase/models/category.rb +26 -0
- data/lib/crunchbase/models/category_group.rb +33 -0
- data/lib/crunchbase/models/entity.rb +28 -0
- data/lib/crunchbase/models/funding_round.rb +63 -0
- data/lib/crunchbase/models/investment.rb +47 -0
- data/lib/crunchbase/models/organization.rb +139 -0
- data/lib/crunchbase/models/person.rb +95 -0
- data/lib/crunchbase/models/press_reference.rb +37 -0
- data/lib/crunchbase/searches.rb +9 -0
- data/lib/crunchbase/searches/client.rb +30 -0
- data/lib/crunchbase/searches/organization.rb +52 -0
- data/lib/crunchbase/utilities.rb +9 -0
- data/lib/crunchbase/utilities/request.rb +44 -0
- data/lib/crunchbase/utilities/response.rb +45 -0
- data/lib/crunchbase/version.rb +5 -0
- metadata +169 -0
@@ -0,0 +1,95 @@
|
|
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 Person < Entity
|
8
|
+
RESOURCE_LIST = 'people'
|
9
|
+
|
10
|
+
def field_ids
|
11
|
+
%w[
|
12
|
+
born_on
|
13
|
+
created_at
|
14
|
+
died_on
|
15
|
+
entity_def_id
|
16
|
+
facebook
|
17
|
+
facet_ids
|
18
|
+
first_name
|
19
|
+
gender
|
20
|
+
identifier
|
21
|
+
image_id
|
22
|
+
image_url
|
23
|
+
investor_stage
|
24
|
+
investor_type
|
25
|
+
last_name
|
26
|
+
layout_id
|
27
|
+
linkedin
|
28
|
+
location_group_identifiers
|
29
|
+
location_identifiers
|
30
|
+
middle_name
|
31
|
+
num_articles
|
32
|
+
num_current_advisor_jobs
|
33
|
+
num_current_jobs
|
34
|
+
num_event_appearances
|
35
|
+
num_exits
|
36
|
+
num_exits_ipo
|
37
|
+
num_founded_organizations
|
38
|
+
num_investments
|
39
|
+
num_investments_funding_rounds
|
40
|
+
num_jobs
|
41
|
+
num_lead_investments
|
42
|
+
num_partner_investments
|
43
|
+
num_past_advisor_jobs
|
44
|
+
num_past_jobs
|
45
|
+
num_portfolio_organizations
|
46
|
+
num_relationships
|
47
|
+
override_layout_id
|
48
|
+
primary_job_title
|
49
|
+
primary_organization
|
50
|
+
rank_delta_d30
|
51
|
+
rank_delta_d7
|
52
|
+
rank_delta_d90
|
53
|
+
rank_person
|
54
|
+
rank_principal
|
55
|
+
rank_principal_investor
|
56
|
+
short_description
|
57
|
+
twitter
|
58
|
+
updated_at
|
59
|
+
] + basis_fields
|
60
|
+
end
|
61
|
+
|
62
|
+
def basis_fields
|
63
|
+
%w[
|
64
|
+
uuid
|
65
|
+
permalink
|
66
|
+
permalink_aliases
|
67
|
+
name
|
68
|
+
aliases
|
69
|
+
website
|
70
|
+
rank
|
71
|
+
short_description
|
72
|
+
description
|
73
|
+
]
|
74
|
+
end
|
75
|
+
|
76
|
+
def full_cards
|
77
|
+
%w[
|
78
|
+
partner_funding_rounds
|
79
|
+
participated_funds
|
80
|
+
participated_investments
|
81
|
+
degrees
|
82
|
+
primary_job
|
83
|
+
founded_organizations
|
84
|
+
event_appearances
|
85
|
+
jobs
|
86
|
+
participated_funding_rounds
|
87
|
+
fields
|
88
|
+
press_references
|
89
|
+
primary_organization
|
90
|
+
partner_investments
|
91
|
+
]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,37 @@
|
|
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 PressReference < Entity
|
8
|
+
RESOURCE_LIST = 'press_references'
|
9
|
+
|
10
|
+
def field_ids
|
11
|
+
%w[
|
12
|
+
activity_entities
|
13
|
+
created_at
|
14
|
+
entity_def_id
|
15
|
+
identifier
|
16
|
+
thumbnail_url
|
17
|
+
updated_at
|
18
|
+
] + basis_fields
|
19
|
+
end
|
20
|
+
|
21
|
+
def basis_fields
|
22
|
+
%w[
|
23
|
+
uuid
|
24
|
+
url
|
25
|
+
title
|
26
|
+
author
|
27
|
+
posted_on
|
28
|
+
publisher
|
29
|
+
]
|
30
|
+
end
|
31
|
+
|
32
|
+
def full_cards
|
33
|
+
%w[]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
# Whole Searches endpoints
|
5
|
+
module Searches
|
6
|
+
# Send request for entities endpoints
|
7
|
+
class Client
|
8
|
+
include ::Crunchbase::Utilities::Request
|
9
|
+
|
10
|
+
ROOT_LIST = 'searches'
|
11
|
+
LIMIT = 100
|
12
|
+
|
13
|
+
def initialize(field_id, value)
|
14
|
+
@field_id = field_id
|
15
|
+
@value = value
|
16
|
+
end
|
17
|
+
|
18
|
+
# Will include all attribute from API document
|
19
|
+
def search
|
20
|
+
search(root_uri, query_conditions)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def root_uri
|
26
|
+
[ROOT_LIST, endpoint].compact.join('/')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,52 @@
|
|
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
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
require 'faraday_middleware'
|
5
|
+
|
6
|
+
module Crunchbase
|
7
|
+
# Utilities
|
8
|
+
module Utilities
|
9
|
+
# API Request
|
10
|
+
module Request
|
11
|
+
module_function
|
12
|
+
|
13
|
+
def entity(uri, *args)
|
14
|
+
response = Faraday.new(url: BASE_URI, headers: headers) do |faraday|
|
15
|
+
faraday.adapter Faraday.default_adapter
|
16
|
+
faraday.response :json
|
17
|
+
end.get(uri, *args)
|
18
|
+
|
19
|
+
return response.body if response.status == 200
|
20
|
+
|
21
|
+
raise Error, response.reason_phrase
|
22
|
+
end
|
23
|
+
|
24
|
+
def search(uri, args)
|
25
|
+
response = Faraday.new(url: BASE_URI, headers: headers) do |faraday|
|
26
|
+
faraday.adapter Faraday.default_adapter
|
27
|
+
faraday.response :json
|
28
|
+
end.post(uri, args)
|
29
|
+
|
30
|
+
return response.body if response.status == 200
|
31
|
+
|
32
|
+
raise Error, response.reason_phrase
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def headers
|
38
|
+
{
|
39
|
+
'X-cb-user-key' => Crunchbase.config.user_key
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crunchbase
|
4
|
+
# Utilities
|
5
|
+
module Utilities
|
6
|
+
# Parse the response. build with object
|
7
|
+
module Response
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def dynamic_attributes(object, attribute_names, response)
|
11
|
+
attribute_names.each do |attribute_name|
|
12
|
+
attribute_value = field_value(attribute_name, response)
|
13
|
+
|
14
|
+
# Manually creates methods for both getter and setter and then
|
15
|
+
# sends a message to the new setter with the attribute_value
|
16
|
+
object.class.send(:define_method, "#{attribute_name}=".to_sym) do |value|
|
17
|
+
instance_variable_set('@' + attribute_name, value)
|
18
|
+
end
|
19
|
+
|
20
|
+
object.class.send(:define_method, attribute_name.to_sym) do
|
21
|
+
instance_variable_get('@' + attribute_name.to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
object.send("#{attribute_name}=".to_sym, attribute_value)
|
25
|
+
end
|
26
|
+
|
27
|
+
object
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def field_value(name, data)
|
33
|
+
value = data.dig(name)
|
34
|
+
|
35
|
+
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
|
39
|
+
return value.dig('value') if value.is_a?(Hash) && value.keys.include?('value')
|
40
|
+
|
41
|
+
value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crunchbase4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Encore Shao
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: vcr
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: A Ruby wrapper for Crunchbase API version 4.0, crunchbase build new API
|
98
|
+
interface by GraphQL
|
99
|
+
email:
|
100
|
+
- encore.shao@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".rubocop_todo.yml"
|
109
|
+
- ".travis.yml"
|
110
|
+
- CHANGELOG.md
|
111
|
+
- CODE_OF_CONDUCT.md
|
112
|
+
- Gemfile
|
113
|
+
- Gemfile.lock
|
114
|
+
- LICENSE.txt
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bin/console
|
118
|
+
- bin/setup
|
119
|
+
- crunchbase4.gemspec
|
120
|
+
- lib/crunchbase.rb
|
121
|
+
- lib/crunchbase/client.rb
|
122
|
+
- lib/crunchbase/config.rb
|
123
|
+
- lib/crunchbase/entities.rb
|
124
|
+
- lib/crunchbase/entities/client.rb
|
125
|
+
- lib/crunchbase/errors.rb
|
126
|
+
- lib/crunchbase/models.rb
|
127
|
+
- lib/crunchbase/models/category.rb
|
128
|
+
- lib/crunchbase/models/category_group.rb
|
129
|
+
- lib/crunchbase/models/entity.rb
|
130
|
+
- lib/crunchbase/models/funding_round.rb
|
131
|
+
- lib/crunchbase/models/investment.rb
|
132
|
+
- lib/crunchbase/models/organization.rb
|
133
|
+
- lib/crunchbase/models/person.rb
|
134
|
+
- lib/crunchbase/models/press_reference.rb
|
135
|
+
- lib/crunchbase/searches.rb
|
136
|
+
- lib/crunchbase/searches/client.rb
|
137
|
+
- lib/crunchbase/searches/organization.rb
|
138
|
+
- lib/crunchbase/utilities.rb
|
139
|
+
- lib/crunchbase/utilities/request.rb
|
140
|
+
- lib/crunchbase/utilities/response.rb
|
141
|
+
- lib/crunchbase/version.rb
|
142
|
+
homepage: https://github.com/encoreshao/crunchbase4
|
143
|
+
licenses:
|
144
|
+
- MIT
|
145
|
+
metadata:
|
146
|
+
allowed_push_host: https://rubygems.org
|
147
|
+
homepage_uri: https://github.com/encoreshao/crunchbase4
|
148
|
+
source_code_uri: https://github.com/encoreshao/crunchbase4
|
149
|
+
changelog_uri: https://github.com/encoreshao/crunchbase4/CHANGELOG.md
|
150
|
+
post_install_message: Thanks for installing!
|
151
|
+
rdoc_options: []
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 2.3.0
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
requirements: []
|
165
|
+
rubygems_version: 3.0.3
|
166
|
+
signing_key:
|
167
|
+
specification_version: 4
|
168
|
+
summary: Ruby Library for Crunchbase API Version 4.0
|
169
|
+
test_files: []
|