crunchbase4 0.1.2 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,11 +56,30 @@ module Crunchbase
56
56
  value = data.dig(name)
57
57
 
58
58
  return value if value.nil? || value.is_a?(String)
59
- return value.collect { |e| e.dig('value') } if value.is_a?(Array) && value[0].is_a?(Hash) && value[0].keys.include?('value')
59
+ return parse_items(value, name) if value.is_a?(Array) && value[0].is_a?(Hash) && value[0].keys.include?('value')
60
60
  return value.dig('value') if value.is_a?(Hash) && value.keys.include?('value')
61
61
 
62
62
  value
63
63
  end
64
+
65
+ def parse_items(items, field_name)
66
+ return items.collect { |e| e.dig('value') } unless field_name == 'activity_entities'
67
+
68
+ # Sepcial case for activity_entities
69
+ items.each_with_object([]) do |item, objects|
70
+ card_model = case item['entity_def_id']
71
+ when 'person' then ::Crunchbase::Models::Person
72
+ when 'organization' then ::Crunchbase::Models::Organization
73
+ end
74
+ # Alias: value is name
75
+ item['name'] ||= item['value']
76
+
77
+ next if card_model.nil?
78
+
79
+ new_card_instance = card_model.new
80
+ objects << dynamic_attributes(new_card_instance, new_card_instance.basis_fields, item)
81
+ end
82
+ end
64
83
  end
65
84
  end
66
85
  end
@@ -142,7 +142,7 @@ module Crunchbase
142
142
  'online_and_on_campus' => 'Online and On Campus'
143
143
  }.freeze
144
144
 
145
- SCHOOL_METHODS = {
145
+ SCHOOL_PROGRAMS = {
146
146
  'bootcamp' => 'Bootcamp',
147
147
  'community_college' => 'Community College',
148
148
  'four_year_university' => 'Four Year University',
@@ -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.7'
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.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Encore Shao
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-07 00:00:00.000000000 Z
11
+ date: 2020-12-02 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,21 +135,30 @@ 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
141
142
  - lib/crunchbase/models.rb
142
143
  - lib/crunchbase/models/acquisition.rb
144
+ - lib/crunchbase/models/address.rb
143
145
  - lib/crunchbase/models/autocomplete_entity.rb
144
146
  - lib/crunchbase/models/category.rb
145
147
  - lib/crunchbase/models/category_group.rb
146
- - lib/crunchbase/models/entity.rb
148
+ - lib/crunchbase/models/concerns/entity.rb
149
+ - lib/crunchbase/models/concerns/mappings.rb
150
+ - lib/crunchbase/models/deleted_entity.rb
151
+ - lib/crunchbase/models/event_appearance.rb
152
+ - lib/crunchbase/models/fund.rb
147
153
  - lib/crunchbase/models/funding_round.rb
148
154
  - lib/crunchbase/models/investment.rb
149
155
  - lib/crunchbase/models/ipo.rb
156
+ - lib/crunchbase/models/job.rb
150
157
  - lib/crunchbase/models/organization.rb
158
+ - lib/crunchbase/models/ownership.rb
151
159
  - lib/crunchbase/models/person.rb
152
160
  - lib/crunchbase/models/press_reference.rb
161
+ - lib/crunchbase/models/principal.rb
153
162
  - lib/crunchbase/searches.rb
154
163
  - lib/crunchbase/searches/client.rb
155
164
  - lib/crunchbase/utilities.rb
@@ -170,7 +179,7 @@ metadata:
170
179
  allowed_push_host: https://rubygems.org
171
180
  homepage_uri: https://github.com/ekohe/crunchbase4
172
181
  source_code_uri: https://github.com/ekohe/crunchbase4
173
- changelog_uri: https://github.com/ekohe/crunchbase4/CHANGELOG.md
182
+ changelog_uri: https://github.com/ekohe/crunchbase4/blob/master/CHANGELOG.md
174
183
  post_install_message: Thanks for installing!
175
184
  rdoc_options: []
176
185
  require_paths:
@@ -187,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
196
  version: '0'
188
197
  requirements: []
189
198
  rubygems_version: 3.0.3
190
- signing_key:
199
+ signing_key:
191
200
  specification_version: 4
192
201
  summary: Crunchbase is a ruby wrapper base on Crunchbase V4 API
193
202
  test_files: []
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../utilities/response'
4
-
5
- module Crunchbase
6
- # Get the Organization data from API
7
- module Models
8
- # Root
9
- class Entity
10
- include ::Crunchbase::Utilities::Response
11
-
12
- def fields
13
- field_ids.map(&:to_sym)
14
- end
15
-
16
- def parse_response(response, request_field_ids = [])
17
- extract_fields = (request_field_ids.empty? ? field_ids : request_field_ids)
18
-
19
- dynamic_attributes(self, extract_fields, response.dig('properties'))
20
- end
21
-
22
- def parse_cards_response(response)
23
- parse_response(response, response.dig('properties'))
24
- # response.dig('cards')
25
- end
26
-
27
- def as_json
28
- fields.each_with_object({}) { |item, hash| hash[item] = send(item) }
29
- end
30
- end
31
- end
32
- end