crunchbase-ruby-library 0.1.7 → 0.3.1
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 +4 -4
- data/.rubocop.yml +66 -0
- data/.rubocop_todo.yml +47 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/README.md +44 -54
- data/Rakefile +4 -1
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/crunchbase-ruby-library.gemspec +15 -12
- data/lib/crunchbase.rb +12 -3
- data/lib/crunchbase/api.rb +110 -102
- data/lib/crunchbase/client.rb +50 -0
- data/lib/crunchbase/exception.rb +13 -11
- data/lib/crunchbase/model.rb +50 -48
- data/lib/crunchbase/model/acquired_by.rb +23 -20
- data/lib/crunchbase/model/acquiree.rb +2 -1
- data/lib/crunchbase/model/acquirer.rb +2 -1
- data/lib/crunchbase/model/acquisition.rb +16 -19
- data/lib/crunchbase/model/address.rb +4 -6
- data/lib/crunchbase/model/advisory_role.rb +2 -2
- data/lib/crunchbase/model/board_members_and_advisor.rb +10 -9
- data/lib/crunchbase/model/category.rb +6 -7
- data/lib/crunchbase/model/competitor.rb +3 -2
- data/lib/crunchbase/model/current_team.rb +7 -11
- data/lib/crunchbase/model/customer.rb +3 -2
- data/lib/crunchbase/model/degree.rb +4 -5
- data/lib/crunchbase/model/entity.rb +98 -108
- data/lib/crunchbase/model/error.rb +3 -4
- data/lib/crunchbase/model/featured_team.rb +19 -0
- data/lib/crunchbase/model/founded_company.rb +2 -3
- data/lib/crunchbase/model/founder.rb +3 -4
- data/lib/crunchbase/model/fund.rb +8 -11
- data/lib/crunchbase/model/fund_raise.rb +7 -8
- data/lib/crunchbase/model/funding_round.rb +29 -24
- data/lib/crunchbase/model/headquarter.rb +2 -1
- data/lib/crunchbase/model/image.rb +6 -7
- data/lib/crunchbase/model/investment.rb +20 -27
- data/lib/crunchbase/model/investor.rb +6 -7
- data/lib/crunchbase/model/ipo.rb +12 -12
- data/lib/crunchbase/model/job.rb +11 -10
- data/lib/crunchbase/model/location.rb +20 -11
- data/lib/crunchbase/model/member.rb +3 -4
- data/lib/crunchbase/model/membership.rb +7 -8
- data/lib/crunchbase/model/new.rb +5 -6
- data/lib/crunchbase/model/office.rb +3 -4
- data/lib/crunchbase/model/organization.rb +39 -38
- data/lib/crunchbase/model/organization_summary.rb +7 -8
- data/lib/crunchbase/model/owned_by.rb +4 -5
- data/lib/crunchbase/model/parent_location.rb +3 -3
- data/lib/crunchbase/model/past_team.rb +7 -11
- data/lib/crunchbase/model/person.rb +53 -46
- data/lib/crunchbase/model/person_summary.rb +13 -14
- data/lib/crunchbase/model/primary_affiliation.rb +6 -6
- data/lib/crunchbase/model/primary_image.rb +3 -3
- data/lib/crunchbase/model/primary_location.rb +8 -7
- data/lib/crunchbase/model/product.rb +14 -13
- data/lib/crunchbase/model/product_summary.rb +4 -5
- data/lib/crunchbase/model/school.rb +3 -2
- data/lib/crunchbase/model/search.rb +39 -40
- data/lib/crunchbase/model/search_result.rb +7 -6
- data/lib/crunchbase/model/simple_organization.rb +9 -10
- data/lib/crunchbase/model/sub_organization.rb +3 -4
- data/lib/crunchbase/model/video.rb +4 -5
- data/lib/crunchbase/model/website.rb +7 -11
- data/lib/crunchbase/request.rb +8 -0
- data/lib/crunchbase/request/client.rb +69 -0
- data/lib/crunchbase/version.rb +2 -1
- data/spec/crunchbase.yml.example +2 -2
- data/spec/crunchbase/client_spec.rb +25 -0
- data/spec/crunchbase/data/board_members_and_advisors/facebook.json +462 -0
- data/spec/crunchbase/data/categories/facebook.json +67 -0
- data/spec/crunchbase/data/current_team/facebook.json +4335 -0
- data/spec/crunchbase/data/featured_team/facebook.json +286 -0
- data/spec/crunchbase/data/funding_rounds/37bd05f961af726ba3c1b279da842805.json +484 -0
- data/spec/crunchbase/data/funding_rounds/facebook.json +2049 -0
- data/spec/crunchbase/data/headquarters/facebook.json +50 -0
- data/spec/crunchbase/data/investors/facebook.json +776 -0
- data/spec/crunchbase/data/news/facebook.json +1426 -0
- data/spec/crunchbase/data/news/facebook_2.json +1426 -0
- data/spec/crunchbase/data/offices/facebook.json +50 -0
- data/spec/crunchbase/data/organizations/crunchbase.json +2845 -0
- data/spec/crunchbase/data/organizations/ekohe.json +654 -0
- data/spec/crunchbase/data/organizations/facebook-without-relationships.json +45 -0
- data/spec/crunchbase/data/organizations/facebook.json +6723 -0
- data/spec/crunchbase/data/organizations/mx-media-llc.json +7 -0
- data/spec/crunchbase/data/past_team/facebook.json +4336 -0
- data/spec/crunchbase/data/people/facebook_founders.json +148 -0
- data/spec/crunchbase/data/people/mark-zuckerberg.json +2602 -0
- data/spec/crunchbase/data/websites/facebook.json +74 -0
- data/spec/crunchbase/model/board_members_and_advisor_spec.rb +39 -11
- data/spec/crunchbase/model/category_spec.rb +47 -0
- data/spec/crunchbase/model/current_team_spec.rb +50 -0
- data/spec/crunchbase/model/featured_team_spec.rb +40 -0
- data/spec/crunchbase/model/founders_spec.rb +49 -0
- data/spec/crunchbase/model/fund_raise_spec.rb +4 -24
- data/spec/crunchbase/model/funding_round_spec.rb +75 -32
- data/spec/crunchbase/model/headquarter_spec.rb +37 -0
- data/spec/crunchbase/model/investment_spec.rb +4 -15
- data/spec/crunchbase/model/investor_spec.rb +37 -0
- data/spec/crunchbase/model/new_spec.rb +86 -0
- data/spec/crunchbase/model/office_spec.rb +29 -9
- data/spec/crunchbase/model/organization_spec.rb +160 -34
- data/spec/crunchbase/model/past_team_spec.rb +36 -14
- data/spec/crunchbase/model/person_spec.rb +21 -19
- data/spec/crunchbase/model/product_spec.rb +4 -31
- data/spec/crunchbase/model/search_spec.rb +25 -49
- data/spec/crunchbase/model/website_spec.rb +36 -9
- data/spec/crunchbase/support/api_helper.rb +19 -0
- data/spec/spec_helper.rb +14 -4
- metadata +103 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class Degree <
|
|
5
|
-
|
|
5
|
+
class Degree < Entity
|
|
6
6
|
RESOURCE_LIST = 'degrees'
|
|
7
7
|
|
|
8
8
|
attr_reader :degree_type_name, :degree_subject, :started_on, :started_on_trust_code, :is_completed,
|
|
@@ -20,12 +20,11 @@ module Crunchbase::Model
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def property_keys
|
|
23
|
-
%w
|
|
23
|
+
%w(
|
|
24
24
|
degree_type_name degree_subject started_on started_on_trust_code is_completed
|
|
25
25
|
completed_on completed_on_trust_code
|
|
26
26
|
created_at updated_at
|
|
27
|
-
|
|
27
|
+
)
|
|
28
28
|
end
|
|
29
|
-
|
|
30
29
|
end
|
|
31
30
|
end
|
|
@@ -1,144 +1,134 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
module Crunchbase
|
|
4
|
-
|
|
4
|
+
module Crunchbase
|
|
5
|
+
module Model
|
|
6
|
+
class Entity
|
|
7
|
+
extend Request::Client
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
attr_reader :type_name, :uuid
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
def initialize(json)
|
|
12
|
+
instance_variable_set('@type_name', json['type'] || nil)
|
|
13
|
+
instance_variable_set('@uuid', json['uuid'] || nil)
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
instance_variable_set("@#{v}",
|
|
14
|
-
|
|
15
|
+
properties = json['properties'] || {}
|
|
16
|
+
property_keys.each { |v| instance_variable_set("@#{v}", properties[v]) }
|
|
17
|
+
date_keys.each { |v| instance_variable_set("@#{v}", properties[v].nil? ? nil : Date.parse(properties[v])) }
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
instance_variable_set("@#{v}", json['properties'][v].nil? ? nil : Date.parse(json['properties'][v]))
|
|
18
|
-
}
|
|
19
|
+
instance_timestamps(properties)
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
if
|
|
22
|
-
instance_variable_set( "@#{v}", begin Time.parse(json['properties'][v]) rescue nil end )
|
|
23
|
-
else
|
|
24
|
-
instance_variable_set( "@#{v}", begin Time.at(json['properties'][v]) rescue nil end )
|
|
25
|
-
end
|
|
26
|
-
}
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Factory method to return an instance from a permalink
|
|
30
|
-
def self.get(permalink)
|
|
31
|
-
result = Crunchbase::API.single_entity(permalink, self::RESOURCE_NAME)
|
|
32
|
-
|
|
33
|
-
return self.new( result )
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def self.list(page=nil)
|
|
37
|
-
model_name = get_model_name(self::RESOURCE_LIST)
|
|
21
|
+
relationships = json['relationships']
|
|
22
|
+
return if relationships.nil? || relationship_lists.empty?
|
|
38
23
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def self.organization_lists(permalink, options={})
|
|
43
|
-
options = options.merge({ model_name: self })
|
|
44
|
-
|
|
45
|
-
return Crunchbase::API.organization_lists(permalink, self::RESOURCE_LIST, options)
|
|
46
|
-
end
|
|
24
|
+
setup_relationships_data!(relationships)
|
|
25
|
+
end
|
|
47
26
|
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
def setup_relationships_data!(relationships)
|
|
28
|
+
relationship_lists.each do |key, kclass|
|
|
29
|
+
set_relationships_object(kclass, key, relationships[key])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
50
32
|
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
def instance_timestamps(properties)
|
|
34
|
+
%w(created_at updated_at).each do |v|
|
|
35
|
+
instance_variable_set("@#{v}", convert_date!(properties[v]))
|
|
36
|
+
end
|
|
37
|
+
end
|
|
53
38
|
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
def convert_date!(date)
|
|
40
|
+
return Time.parse(date) if date.is_a?(String)
|
|
56
41
|
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
Time.at(date)
|
|
43
|
+
rescue
|
|
44
|
+
nil
|
|
45
|
+
end
|
|
59
46
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
def fetch
|
|
48
|
+
fetch_object = get_fetch_object
|
|
49
|
+
return [] if fetch_object.empty?
|
|
63
50
|
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
fetch_object[0].new Crunchbase::API.fetch(permalink, fetch_object[1])
|
|
52
|
+
end
|
|
66
53
|
|
|
67
|
-
|
|
68
|
-
|
|
54
|
+
# TODO: need to be implement
|
|
55
|
+
def property_keys
|
|
56
|
+
[]
|
|
57
|
+
end
|
|
69
58
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
end
|
|
59
|
+
def date_keys
|
|
60
|
+
[]
|
|
61
|
+
end
|
|
74
62
|
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
def relationship_lists
|
|
64
|
+
{ }
|
|
65
|
+
end
|
|
77
66
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
end
|
|
67
|
+
def set_relationships_object(kclass, key, list)
|
|
68
|
+
return if list.nil? || list.empty?
|
|
69
|
+
return unless list
|
|
82
70
|
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
if list.is_a?(Array)
|
|
72
|
+
set_variables(kclass, key, list)
|
|
73
|
+
elsif list.is_a?(Hash)
|
|
74
|
+
parse_hash_items(kclass, key, list)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
85
77
|
|
|
86
|
-
list
|
|
87
|
-
|
|
78
|
+
def parse_hash_items(kclass, key, list)
|
|
79
|
+
one_to_one(kclass, key, list)
|
|
80
|
+
one_to_one(kclass, key, list['item']) if list['item']
|
|
81
|
+
one_to_many(kclass, key, list) if list['items']
|
|
82
|
+
end
|
|
88
83
|
|
|
89
|
-
|
|
84
|
+
def one_to_one(kclass, key, item)
|
|
85
|
+
return unless item
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
result = special_relationship(kclass, item)
|
|
88
|
+
instance_variable_set "@#{key}", result[:item]
|
|
89
|
+
instance_variable_set "@#{key}_total_items", result[:count]
|
|
90
|
+
end
|
|
94
91
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
# {
|
|
93
|
+
# "cardinality"=>"OneToOne",
|
|
94
|
+
# "paging"=>{"total_items"=>0,
|
|
95
|
+
# "first_page_url"=>"https://api.crunchbase.com/v3.1/organizations/facebook/acquired_by",
|
|
96
|
+
# "sort_order"=>"not_ordered"
|
|
97
|
+
# }
|
|
98
|
+
def special_relationship(kclass, item)
|
|
99
|
+
return { item: nil, count: 0 } if verify_item?(item)
|
|
98
100
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
{ item: (kclass.new(item) || nil), count: (item ? 1 : 0) }
|
|
102
|
+
end
|
|
101
103
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
def verify_item?(item)
|
|
105
|
+
item['cardinality'] == 'OneToOne' && (item['paging']['total_items']).zero?
|
|
106
|
+
end
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
def one_to_many(kclass, key, list)
|
|
109
|
+
return unless list['items'].respond_to?(:each)
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
set_variables(kclass, key, list['items'])
|
|
112
|
+
instance_variable_set "@#{key}_total_items", list['paging']['total_items']
|
|
113
|
+
end
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
def set_variables(kclass, key, items)
|
|
116
|
+
instance_variable_set "@#{key}", items.inject([]) { |v, i| v << kclass.new(i) }
|
|
117
|
+
end
|
|
115
118
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
end
|
|
119
|
+
def instance_relationships_object(kclass, key, item)
|
|
120
|
+
return unless item
|
|
119
121
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
instance_variable_set "@#{key}", (kclass.new(item) || nil)
|
|
123
|
+
end
|
|
122
124
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
def instance_multi_relationship_objects(kclass, key, items)
|
|
126
|
+
multi_items = []
|
|
125
127
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
case resource_list
|
|
130
|
-
when 'organizations'
|
|
131
|
-
OrganizationSummary
|
|
132
|
-
when 'people'
|
|
133
|
-
PersonSummary
|
|
134
|
-
when 'products'
|
|
135
|
-
ProductSummary
|
|
136
|
-
when 'ipos'
|
|
137
|
-
Ipo
|
|
138
|
-
else
|
|
139
|
-
nil
|
|
128
|
+
items.map { |item| multi_items << kclass.new(item || nil) }
|
|
129
|
+
instance_variable_set "@#{key}", multi_items
|
|
130
|
+
instance_variable_set "@#{key}_total_items", multi_items.size
|
|
140
131
|
end
|
|
141
132
|
end
|
|
142
|
-
|
|
143
133
|
end
|
|
144
134
|
end
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class Error <
|
|
5
|
-
|
|
5
|
+
class Error < Entity
|
|
6
6
|
attr_reader :message, :code
|
|
7
7
|
|
|
8
8
|
def initialize(json)
|
|
9
9
|
@message = json['message']
|
|
10
10
|
@code = json['code']
|
|
11
11
|
end
|
|
12
|
-
|
|
13
12
|
end
|
|
14
|
-
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crunchbase::Model
|
|
4
|
+
class FeaturedTeam < Job
|
|
5
|
+
RESOURCE_LIST = 'featured_team'
|
|
6
|
+
|
|
7
|
+
attr_reader :person
|
|
8
|
+
|
|
9
|
+
def initialize(json)
|
|
10
|
+
super
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def relationship_lists
|
|
14
|
+
{
|
|
15
|
+
'person' => Person
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class FoundedCompany <
|
|
5
|
-
|
|
5
|
+
class FoundedCompany < Organization
|
|
6
6
|
RESOURCE_LIST = 'founded_companies'
|
|
7
7
|
|
|
8
8
|
#
|
|
@@ -25,6 +25,5 @@ module Crunchbase::Model
|
|
|
25
25
|
# type name path created_at updated_at
|
|
26
26
|
# ]
|
|
27
27
|
# end
|
|
28
|
-
|
|
29
28
|
end
|
|
30
29
|
end
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# encoding utf-8
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class Fund <
|
|
5
|
-
|
|
5
|
+
class Fund < Entity
|
|
6
6
|
RESOURCE_LIST = 'funds'
|
|
7
7
|
|
|
8
|
-
attr_reader :api_path, :web_path, :name, :announced_on, :announced_on_trust_code,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# attr_reader :venture_firm_total_items, :investor_total_items, :images_total_items, :videos_total_items, :news_total_items
|
|
8
|
+
attr_reader :api_path, :web_path, :name, :announced_on, :announced_on_trust_code,
|
|
9
|
+
:money_raised, :money_raised_currency_code, :money_raised_usd,
|
|
10
|
+
:created_at, :updated_at
|
|
13
11
|
|
|
14
12
|
def property_keys
|
|
15
|
-
%w
|
|
13
|
+
%w(
|
|
16
14
|
api_path web_path name announced_on announced_on_trust_code
|
|
17
15
|
money_raised money_raised_currency_code money_raised_usd created_at updated_at
|
|
18
|
-
|
|
16
|
+
)
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
def date_keys
|
|
22
|
-
%w
|
|
20
|
+
%w(announced_on)
|
|
23
21
|
end
|
|
24
|
-
|
|
25
22
|
end
|
|
26
23
|
end
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
# encoding utf-8
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class FundRaise <
|
|
5
|
-
|
|
5
|
+
class FundRaise < Entity
|
|
6
6
|
RESOURCE_LIST = 'funds'
|
|
7
7
|
|
|
8
8
|
attr_reader :name, :path, :created_at, :updated_at
|
|
9
9
|
|
|
10
10
|
def initialize(json)
|
|
11
|
-
property_keys.each
|
|
11
|
+
property_keys.each do |v|
|
|
12
12
|
instance_variable_set("@#{v}", json[v] || nil)
|
|
13
|
-
|
|
13
|
+
end
|
|
14
14
|
|
|
15
|
-
%w
|
|
15
|
+
%w(created_at updated_at).each do |v|
|
|
16
16
|
instance_variable_set("@#{v}", Time.at(json[v]))
|
|
17
|
-
|
|
17
|
+
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def property_keys
|
|
21
|
-
%w
|
|
21
|
+
%w(name path created_at updated_at)
|
|
22
22
|
end
|
|
23
|
-
|
|
24
23
|
end
|
|
25
24
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class FundingRound <
|
|
5
|
-
|
|
5
|
+
class FundingRound < Entity
|
|
6
6
|
RESOURCE_LIST = 'funding_rounds'
|
|
7
7
|
RESOURCE_NAME = 'funding-rounds'
|
|
8
8
|
|
|
@@ -12,49 +12,54 @@ module Crunchbase::Model
|
|
|
12
12
|
:target_money_raised, :target_money_raised_currency_code, :target_money_raised_usd,
|
|
13
13
|
:created_at, :updated_at
|
|
14
14
|
|
|
15
|
-
attr_reader :investments, :funded_organization, :images, :videos, :news
|
|
15
|
+
attr_reader :investments, :funded_organization, :images, :videos, :news, :investors
|
|
16
16
|
|
|
17
17
|
attr_reader :investments_total_items, :funded_organization_total_items, :images_total_items,
|
|
18
|
-
:videos_total_items, :news_total_items
|
|
18
|
+
:videos_total_items, :news_total_items, :investors_total_items
|
|
19
19
|
|
|
20
20
|
def initialize(json)
|
|
21
|
-
super
|
|
22
|
-
|
|
23
|
-
unless (relationships = json['relationships']).nil?
|
|
24
|
-
set_relationships_object(Crunchbase::Model::Investment, 'investments', relationships['investments'])
|
|
21
|
+
super(json)
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
relationships = json['relationships']
|
|
24
|
+
return if relationships.nil?
|
|
25
|
+
relationship_with_funded(relationships['funded_organization'])
|
|
26
|
+
end
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
else
|
|
32
|
-
# Get funding-rounds (funded_organization - item)
|
|
28
|
+
def relationship_with_funded(funded_organization)
|
|
29
|
+
return if funded_organization.nil?
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
if funded_organization['item'].nil?
|
|
32
|
+
# Get organization's (investments - funding - organization)
|
|
33
|
+
instance_relationships_object(Organization, 'funded_organization', funded_organization)
|
|
34
|
+
else
|
|
35
|
+
# Get funding-rounds (funded_organization - item)
|
|
37
36
|
|
|
38
|
-
set_relationships_object(
|
|
39
|
-
set_relationships_object(Crunchbase::Model::Video, 'videos', relationships['videos'])
|
|
40
|
-
set_relationships_object(Crunchbase::Model::New, 'news', relationships['news'])
|
|
37
|
+
set_relationships_object(Organization, 'funded_organization', funded_organization)
|
|
41
38
|
end
|
|
39
|
+
end
|
|
42
40
|
|
|
41
|
+
def relationship_lists
|
|
42
|
+
{
|
|
43
|
+
'investments' => Investment,
|
|
44
|
+
'images' => Image,
|
|
45
|
+
'videos' => Video,
|
|
46
|
+
'news' => New,
|
|
47
|
+
'investors' => Investor
|
|
48
|
+
}
|
|
43
49
|
end
|
|
44
50
|
|
|
45
51
|
def property_keys
|
|
46
|
-
%w
|
|
52
|
+
%w(
|
|
47
53
|
permalink api_path web_path funding_type series series_qualifier
|
|
48
54
|
announced_on announced_on_trust_code closed_on closed_on_trust_code
|
|
49
55
|
money_raised money_raised_currency_code money_raised_usd
|
|
50
56
|
target_money_raised target_money_raised_currency_code target_money_raised_usd
|
|
51
57
|
created_at updated_at
|
|
52
|
-
|
|
58
|
+
)
|
|
53
59
|
end
|
|
54
60
|
|
|
55
61
|
def date_keys
|
|
56
|
-
%w
|
|
62
|
+
%w(announced_on closed_on)
|
|
57
63
|
end
|
|
58
|
-
|
|
59
64
|
end
|
|
60
65
|
end
|