crunchbase4 0.1.3 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@
3
3
  module Crunchbase
4
4
  # Models
5
5
  module Models
6
- autoload :Entity, 'crunchbase/models/entity'
6
+ autoload :Entity, 'crunchbase/models/concerns/entity'
7
7
  autoload :AutocompleteEntity, 'crunchbase/models/autocomplete_entity'
8
8
  autoload :DeletedEntity, 'crunchbase/models/deleted_entity'
9
9
  autoload :Organization, 'crunchbase/models/organization'
@@ -15,5 +15,11 @@ module Crunchbase
15
15
  autoload :CategoryGroup, 'crunchbase/models/category_group'
16
16
  autoload :Category, 'crunchbase/models/category'
17
17
  autoload :Ipo, 'crunchbase/models/ipo'
18
+ autoload :Fund, 'crunchbase/models/fund'
19
+ autoload :Ownership, 'crunchbase/models/ownership'
20
+ autoload :EventAppearance, 'crunchbase/models/event_appearance'
21
+ autoload :Principal, 'crunchbase/models/principal'
22
+ autoload :Job, 'crunchbase/models/job'
23
+ autoload :Address, 'crunchbase/models/address'
18
24
  end
19
25
  end
@@ -0,0 +1,36 @@
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 Address < Entity
8
+ RESOURCE_LIST = 'addresses'
9
+
10
+ def field_ids
11
+ %w[
12
+ created_at
13
+ entity_def_id
14
+ updated_at
15
+ ] + basis_fields
16
+ end
17
+
18
+ def basis_fields
19
+ %w[
20
+ uuid
21
+ name
22
+ postal_code
23
+ street_1
24
+ street_2
25
+ identifier
26
+ location_identifiers
27
+ ]
28
+ end
29
+
30
+ def full_cards
31
+ %w[
32
+ ]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../utilities/response'
4
+ require_relative './mappings'
5
+
6
+ module Crunchbase
7
+ # Get the Organization data from API
8
+ module Models
9
+ # Root
10
+ class Entity
11
+ include ::Crunchbase::Utilities::Response
12
+ include Mappings
13
+
14
+ def fields
15
+ field_ids.concat(custom_fields).map(&:to_sym)
16
+ end
17
+
18
+ def parse_response(response, request_field_ids = [], cards = [])
19
+ extract_fields = (request_field_ids.empty? ? field_ids : request_field_ids)
20
+
21
+ dynamic_attributes(self, extract_fields, response.dig('properties'))
22
+ setup_relationships(self, cards, response.dig('cards'))
23
+ self
24
+ end
25
+
26
+ def setup_relationships(object, request_card_ids, response_cards)
27
+ request_card_ids.each do |card_id|
28
+ card_data = response_cards.dig(card_id)
29
+ card_model = 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.field_ids, data)
34
+ end
35
+ else
36
+ card_data.nil? ? nil : 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
+ private
48
+
49
+ def custom_fields
50
+ []
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crunchbase
4
+ # Get the Organization data from API
5
+ module Models
6
+ # Build card mappings
7
+ module Mappings
8
+ def model_mappings
9
+ {
10
+ 'investments' => Investment,
11
+ 'raised_investments' => Investment,
12
+ 'participated_investments' => Investment,
13
+ 'participated_funds' => Fund,
14
+ 'raised_funds' => Fund,
15
+ 'child_organizations' => Organization,
16
+ 'parent_organization' => Organization,
17
+ 'investors' => Principal,
18
+ 'raised_funding_rounds' => FundingRound,
19
+ 'participated_funding_rounds' => FundingRound,
20
+ 'ipos' => Ipo,
21
+ 'event_appearances' => EventAppearance,
22
+ 'acquiree_acquisitions' => Acquisition,
23
+ 'parent_ownership' => Ownership,
24
+ 'child_ownerships' => Ownership,
25
+ 'jobs' => Job,
26
+ 'founders' => Person,
27
+ 'press_references' => PressReference,
28
+ 'headquarters_address' => Address
29
+ }
30
+ end
31
+
32
+ def card_num_field(card_id)
33
+ field_ids & ["num_#{card_id}"]
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crunchbase
4
+ # Get the Entities data from API
5
+ module Models
6
+ # Get the EventAppearances data from API
7
+ class EventAppearance < Entity
8
+ RESOURCE_LIST = 'event_appearances'
9
+
10
+ def field_ids
11
+ %w[
12
+ created_at
13
+ updated_at
14
+ entity_def_id
15
+ event_identifier
16
+ event_location_identifiers
17
+ participant_identifier
18
+ ] + basis_fields
19
+ end
20
+
21
+ def basis_fields
22
+ %w[
23
+ appearance_type
24
+ identifier
25
+ name
26
+ permalink
27
+ short_description
28
+ event_starts_on
29
+ uuid
30
+ ]
31
+ end
32
+
33
+ def full_cards
34
+ %w[
35
+ ]
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crunchbase
4
+ # Get the Entities data from API
5
+ module Models
6
+ # Get the Fund data from API
7
+ class Fund < Entity
8
+ RESOURCE_LIST = 'funds'
9
+
10
+ def field_ids
11
+ %w[
12
+ created_at
13
+ entity_def_id
14
+ image_id
15
+ investor_identifiers
16
+ num_investors
17
+ owner_identifier
18
+ short_description
19
+ started_on
20
+ updated_at
21
+ ] + basis_fields
22
+ end
23
+
24
+ def basis_fields
25
+ %w[
26
+ uuid
27
+ name
28
+ announced_on
29
+ money_raised
30
+ permalink
31
+ ]
32
+ end
33
+
34
+ def full_cards
35
+ %w[
36
+ investors
37
+ owner
38
+ press_references
39
+ ]
40
+ end
41
+ end
42
+ end
43
+ end
@@ -18,6 +18,7 @@ module Crunchbase
18
18
  funded_organization_identifier
19
19
  funded_organization_location
20
20
  funded_organization_revenue_range
21
+ funded_organization_diversity_spotlights
21
22
  identifier
22
23
  image_id
23
24
  investor_identifiers
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crunchbase
4
+ # Get the Entities data from API
5
+ module Models
6
+ # Get the Principal data from API
7
+ class Job < Entity
8
+ RESOURCE_LIST = 'jobs'
9
+
10
+ def field_ids
11
+ %w[
12
+ created_at
13
+ employee_featured_order
14
+ entity_def_id
15
+ identifier
16
+ short_description
17
+ updated_at
18
+ ] + basis_fields
19
+ end
20
+
21
+ def basis_fields
22
+ %w[
23
+ uuid
24
+ name
25
+ title
26
+ started_on
27
+ ended_on
28
+ permalink
29
+ job_type
30
+ is_current
31
+ organization_identifier
32
+ person_identifier
33
+ ]
34
+ end
35
+
36
+ def full_cards
37
+ %w[
38
+ ]
39
+ end
40
+ end
41
+ end
42
+ end
@@ -134,6 +134,16 @@ module Crunchbase
134
134
  headquarters_address
135
135
  ]
136
136
  end
137
+
138
+ def employees_range
139
+ Crunchbase::Utils::NUM_EMPLOYEES_ENUM[num_employees_enum]
140
+ end
141
+
142
+ private
143
+
144
+ def custom_fields
145
+ %w[employees_range]
146
+ end
137
147
  end
138
148
  end
139
149
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crunchbase
4
+ # Get the Entities data from API
5
+ module Models
6
+ # Get the Ownership data from API
7
+ class Ownership < Entity
8
+ RESOURCE_LIST = 'ownerships'
9
+
10
+ def field_ids
11
+ %w[
12
+ created_at
13
+ entity_def_id
14
+ identifier
15
+ updated_at
16
+ ] + basis_fields
17
+ end
18
+
19
+ def basis_fields
20
+ %w[
21
+ uuid
22
+ permalink
23
+ name
24
+ ownee_identifier
25
+ owner_identifier
26
+ ownership_type
27
+ ]
28
+ end
29
+
30
+ def full_cards
31
+ %w[
32
+ child_organization
33
+ parent_organization
34
+ press_references
35
+ ]
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crunchbase
4
+ # Get the Entities data from API
5
+ module Models
6
+ # Get the Principal data from API
7
+ class Principal < Entity
8
+ RESOURCE_LIST = 'principals'
9
+
10
+ def field_ids
11
+ %w[
12
+ category_groups
13
+ created_at
14
+ delisted_on
15
+ description
16
+ died_on
17
+ entity_def_id
18
+ equity_funding_total
19
+ exited_on
20
+ facet_ids
21
+ first_name
22
+ founded_on
23
+ founder_identifiers
24
+ funding_stage
25
+ funding_total
26
+ gender
27
+ hub_tags
28
+ identifier
29
+ image_id
30
+ image_url
31
+ investor_identifiers
32
+ ipo_status
33
+ last_equity_funding_total
34
+ last_equity_funding_type
35
+ last_funding_at
36
+ last_funding_total
37
+ last_funding_type
38
+ last_name
39
+ layout_id
40
+ location_group_identifiers
41
+ location_identifiers
42
+ num_alumni
43
+ num_articles
44
+ num_employees_enum
45
+ num_enrollments
46
+ num_event_appearances
47
+ num_exits
48
+ num_exits_ipo
49
+ num_founded_organizations
50
+ num_founders
51
+ num_funding_rounds
52
+ num_funds
53
+ num_investments
54
+ num_investments_funding_rounds
55
+ num_investors
56
+ num_jobs
57
+ num_lead_investments
58
+ num_lead_investors
59
+ num_partner_investments
60
+ num_portfolio_organizations
61
+ program_application_deadline
62
+ program_duration
63
+ program_type
64
+ rank_delta_d30
65
+ rank_delta_d7
66
+ rank_delta_d90
67
+ rank_principal
68
+ revenue_range
69
+ school_method
70
+ school_program
71
+ school_type
72
+ status
73
+ stock_exchange_symbol
74
+ stock_symbol
75
+ updated_at
76
+ went_public_on
77
+ ] + basis_fields
78
+ end
79
+
80
+ def basis_fields
81
+ %w[
82
+ name
83
+ uuid
84
+ website
85
+ short_description
86
+ operating_status
87
+ permalink
88
+ permalink_aliases
89
+ phone_number
90
+ primary_job_title
91
+ primary_organization
92
+ contact_email
93
+ aliases
94
+ born_on
95
+ closed_on
96
+ categories
97
+ company_type
98
+ linkedin
99
+ twitter
100
+ facebook
101
+ investor_stage
102
+ investor_type
103
+ ]
104
+ end
105
+
106
+ def full_cards
107
+ %w[
108
+ ]
109
+ end
110
+ end
111
+ end
112
+ end