crunchbase-ruby-library 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/.gitignore +24 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +102 -0
  6. data/Rakefile +2 -0
  7. data/crunchbase-ruby-library.gemspec +25 -0
  8. data/lib/crunchbase.rb +12 -0
  9. data/lib/crunchbase/api.rb +160 -0
  10. data/lib/crunchbase/exception.rb +18 -0
  11. data/lib/crunchbase/model.rb +49 -0
  12. data/lib/crunchbase/model/acquired_by.rb +7 -0
  13. data/lib/crunchbase/model/acquisition.rb +36 -0
  14. data/lib/crunchbase/model/address.rb +20 -0
  15. data/lib/crunchbase/model/advisory_role.rb +10 -0
  16. data/lib/crunchbase/model/board_members_and_advisor.rb +25 -0
  17. data/lib/crunchbase/model/category.rb +17 -0
  18. data/lib/crunchbase/model/competitor.rb +7 -0
  19. data/lib/crunchbase/model/current_team.rb +25 -0
  20. data/lib/crunchbase/model/customer.rb +7 -0
  21. data/lib/crunchbase/model/degree.rb +31 -0
  22. data/lib/crunchbase/model/entity.rb +134 -0
  23. data/lib/crunchbase/model/error.rb +14 -0
  24. data/lib/crunchbase/model/founded_company.rb +27 -0
  25. data/lib/crunchbase/model/founder.rb +9 -0
  26. data/lib/crunchbase/model/fund.rb +26 -0
  27. data/lib/crunchbase/model/funding_round.rb +58 -0
  28. data/lib/crunchbase/model/headquarter.rb +6 -0
  29. data/lib/crunchbase/model/image.rb +17 -0
  30. data/lib/crunchbase/model/investment.rb +27 -0
  31. data/lib/crunchbase/model/investor.rb +28 -0
  32. data/lib/crunchbase/model/ipo.rb +35 -0
  33. data/lib/crunchbase/model/job.rb +39 -0
  34. data/lib/crunchbase/model/location.rb +29 -0
  35. data/lib/crunchbase/model/member.rb +7 -0
  36. data/lib/crunchbase/model/membership.rb +28 -0
  37. data/lib/crunchbase/model/new.rb +21 -0
  38. data/lib/crunchbase/model/office.rb +9 -0
  39. data/lib/crunchbase/model/organization.rb +88 -0
  40. data/lib/crunchbase/model/organization_summary.rb +19 -0
  41. data/lib/crunchbase/model/owned_by.rb +27 -0
  42. data/lib/crunchbase/model/parent_location.rb +7 -0
  43. data/lib/crunchbase/model/past_team.rb +25 -0
  44. data/lib/crunchbase/model/person.rb +55 -0
  45. data/lib/crunchbase/model/person_summary.rb +23 -0
  46. data/lib/crunchbase/model/primary_affiliation.rb +22 -0
  47. data/lib/crunchbase/model/primary_image.rb +7 -0
  48. data/lib/crunchbase/model/primary_location.rb +17 -0
  49. data/lib/crunchbase/model/product.rb +47 -0
  50. data/lib/crunchbase/model/school.rb +6 -0
  51. data/lib/crunchbase/model/search.rb +50 -0
  52. data/lib/crunchbase/model/search_result.rb +10 -0
  53. data/lib/crunchbase/model/sub_organization.rb +9 -0
  54. data/lib/crunchbase/model/video.rb +17 -0
  55. data/lib/crunchbase/model/website.rb +17 -0
  56. data/lib/crunchbase/version.rb +3 -0
  57. data/spec/crunchbase.yml.example +2 -0
  58. data/spec/crunchbase/model/board_members_and_advisor_spec.rb +20 -0
  59. data/spec/crunchbase/model/office_spec.rb +17 -0
  60. data/spec/crunchbase/model/organization_spec.rb +60 -0
  61. data/spec/crunchbase/model/past_team_spec.rb +26 -0
  62. data/spec/crunchbase/model/person_spec.rb +28 -0
  63. data/spec/crunchbase/model/product_spec.rb +33 -0
  64. data/spec/crunchbase/model/search_spec.rb +50 -0
  65. data/spec/crunchbase/model/website_spec.rb +18 -0
  66. data/spec/spec_helper.rb +20 -0
  67. metadata +192 -0
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Investment < Crunchbase::Model::Entity
5
+
6
+ RESOURCE_LIST = 'investments'
7
+
8
+ attr_reader :money_invested, :money_invested_currency_code, :money_invested_usd, :created_at, :updated_at
9
+
10
+ attr_reader :funding_round, :invested_in
11
+
12
+ def initialize(json)
13
+ super
14
+
15
+ unless (relationships = json['relationships']).nil?
16
+ instance_relationships_object(Crunchbase::Model::FundingRound, 'funding_round', relationships['funding_round'])
17
+ end
18
+ end
19
+
20
+ def property_keys
21
+ %w[
22
+ money_invested money_invested_currency_code money_invested_usd created_at updated_at
23
+ ]
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Investor < Crunchbase::Model::Entity
5
+
6
+ RESOURCE_LIST = 'investors'
7
+
8
+ attr_reader :object
9
+
10
+ def initialize(json)
11
+ set_relationship_object('object', Crunchbase::Model::Person, json) if json['type'] == 'Person'
12
+ set_relationship_object('object', Crunchbase::Model::Organization, json) if json['type'] == 'Organization'
13
+ end
14
+
15
+ def set_relationship_object(key, object_name, json)
16
+ instance_variable_set "@#{key}", ( object_name.new(json) || nil )
17
+ end
18
+
19
+ def person?
20
+ (object.type_name == "Person")
21
+ end
22
+
23
+ def organization?
24
+ (object.type_name == "Organization")
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Ipo < Crunchbase::Model::Entity
5
+
6
+ RESOURCE_LIST = 'ipos'
7
+
8
+ attr_reader :api_path, :web_path, :went_public_on, :went_public_on_trust_code,
9
+ :stock_exchange_symbol, :stock_symbol,
10
+ :shares_sold, :opening_share_price,
11
+ :opening_share_price_currency_code, :opening_share_price_usd, :opening_valuation,
12
+ :opening_valuation_currency_code, :opening_valuation_usd,
13
+ :money_raised, :money_raised_currency_code, :money_raised_usd,
14
+ :created_at, :updated_at
15
+
16
+ attr_reader :funded_company, :stock_exchange, :images, :videos, :news
17
+
18
+ def property_keys
19
+ %w[
20
+ api_path web_path went_public_on went_public_on_trust_code
21
+ stock_exchange_symbol stock_symbol
22
+ shares_sold opening_share_price
23
+ opening_share_price_currency_code opening_share_price_usd opening_valuation
24
+ opening_valuation_currency_code opening_valuation_usd
25
+ money_raised money_raised_currency_code money_raised_usd
26
+ created_at updated_at
27
+ ]
28
+ end
29
+
30
+ def date_keys
31
+ %w[went_public_on]
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Job < Crunchbase::Model::Entity
5
+
6
+ RESOURCE_LIST = 'jobs'
7
+
8
+ attr_reader :title, :started_on, :started_on_trust_code, :ended_on, :ended_on_trust_code,
9
+ :created_at, :updated_at
10
+
11
+ attr_reader :person, :organization
12
+
13
+ def initialize(json)
14
+ super
15
+
16
+ unless (relationships = json['relationships']).nil?
17
+ set_relationships_object(Crunchbase::Model::Person, 'person', relationships['person'])
18
+ set_relationships_object(Crunchbase::Model::Organization, 'organization', relationships['organization'])
19
+ end
20
+ end
21
+
22
+ def property_keys
23
+ %w[
24
+ title started_on started_on_trust_code ended_on ended_on_trust_code created_at updated_at
25
+ ]
26
+ end
27
+
28
+ def date_keys
29
+ %w[ started_on ended_on ]
30
+ end
31
+
32
+ def set_relationships_object(object_name, key, item)
33
+ return unless item
34
+
35
+ instance_variable_set "@#{key}", ( object_name.new(item) || nil )
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Location < Crunchbase::Model::Entity
5
+
6
+ RESOURCE_LIST = 'locations'
7
+
8
+ attr_reader :web_path, :name, :location_type, :parent_location_uuid, :created_at, :updated_at
9
+
10
+ attr_reader :parent_locations
11
+
12
+ attr_reader :parent_locations_total_items
13
+
14
+ def initialize(json)
15
+ super
16
+
17
+ unless (relationships = json['relationships']).nil?
18
+ set_relationships_object(Crunchbase::Model::ParentLocation, 'parent_locations', relationships['parent_locations'])
19
+ end
20
+ end
21
+
22
+ def property_keys
23
+ %w[
24
+ web_path name location_type parent_location_uuid created_at updated_at
25
+ ]
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Member < Crunchbase::Model::Organization
5
+ RESOURCE_LIST = 'members'
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Membership < Crunchbase::Model::Organization
5
+
6
+ RESOURCE_LIST = 'memberships'
7
+
8
+ attr_reader :object
9
+
10
+ def initialize(json)
11
+ set_relationship_object('object', Crunchbase::Model::Person, json) if json['type'] == 'Person'
12
+ set_relationship_object('object', Crunchbase::Model::Organization, json) if json['type'] == 'Organization'
13
+ end
14
+
15
+ def set_relationship_object(key, object_name, json)
16
+ instance_variable_set "@#{key}", ( object_name.new(json) || nil )
17
+ end
18
+
19
+ def person?
20
+ (object.type_name == "Person")
21
+ end
22
+
23
+ def organization?
24
+ (object.type_name == "Organization")
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class New < Crunchbase::Model::Entity
5
+
6
+ RESOURCE_LIST = 'news'
7
+
8
+ attr_reader :title, :author, :posted_on, :url, :created_at, :updated_at, :type
9
+
10
+ def property_keys
11
+ %w[
12
+ title author posted_on url created_at updated_at type
13
+ ]
14
+ end
15
+
16
+ def date_keys
17
+ %w[posted_on]
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Office < Crunchbase::Model::Address
5
+
6
+ RESOURCE_LIST = 'offices'
7
+
8
+ end
9
+ end
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Organization < Crunchbase::Model::Entity
5
+
6
+ RESOURCE_LIST = RESOURCE_NAME = 'organizations'
7
+
8
+ attr_reader :permalink, :api_path, :web_path, :name, :also_known_as, :short_description, :description,
9
+ :primary_role, :role_company, :role_investor, :role_group, :role_school,
10
+ :founded_on, :founded_on_trust_code, :is_closed, :closed_on, :closed_on_trust_code,
11
+ :num_employees_min, :num_employees_max,
12
+ :total_funding_usd,
13
+ :stock_exchange, :stock_symbol,
14
+ :number_of_investments, :homepage_url,
15
+ :created_at, :updated_at
16
+
17
+ attr_reader :primary_image, :founders, :current_team, :past_team, :board_members_and_advisors,
18
+ :investors, :owned_by, :sub_organizations, :headquarters, :offices, :products,
19
+ :categories, :customers, :competitors, :members, :memberships, :funding_rounds, :investments,
20
+ :acquisitions, :acquired_by, :ipo, :funds, :websites, :images, :videos, :news
21
+
22
+ attr_reader :primary_image_total_items, :founders_total_items, :current_team_total_items,
23
+ :past_team_total_items, :board_members_and_advisors_total_items, :investors_total_items,
24
+ :owned_by_total_items, :sub_organizations_total_items, :headquarters_total_items,
25
+ :offices_total_items, :products_total_items, :categories_total_items,
26
+ :customers_total_items, :competitors_total_items, :members_total_items,
27
+ :memberships_total_items, :funding_rounds_total_items, :investments_total_items,
28
+ :acquisitions_total_items, :acquired_by_total_items,
29
+ :ipo_total_items, :funds_total_items, :websites_total_items, :images_total_items,
30
+ :videos_total_items, :news_total_items
31
+
32
+ def initialize(json)
33
+ super
34
+
35
+ unless (relationships = json['relationships']).nil?
36
+
37
+ set_relationships_object(Crunchbase::Model::PrimaryImage, 'primary_image', relationships['primary_image'])
38
+ set_relationships_object(Crunchbase::Model::Founder, 'founders', relationships['founders'])
39
+ set_relationships_object(Crunchbase::Model::CurrentTeam, 'current_team', relationships['current_team'])
40
+ set_relationships_object(Crunchbase::Model::PastTeam, 'past_team', relationships['past_team'])
41
+ # set_relationships_object(PrimaryImage, 'board_members_and_advisors', relationships['board_members_and_advisors'])
42
+ set_relationships_object(Crunchbase::Model::Investor, 'investors', relationships['investors'])
43
+ set_relationships_object(Crunchbase::Model::OwnedBy, 'owned_by', relationships['owned_by'])
44
+ set_relationships_object(Crunchbase::Model::SubOrganization, 'sub_organizations', relationships['sub_organizations'])
45
+ set_relationships_object(Crunchbase::Model::Headquarter, 'headquarters', relationships['headquarters'])
46
+ set_relationships_object(Crunchbase::Model::Office, 'offices', relationships['offices'])
47
+ set_relationships_object(Crunchbase::Model::Product, 'products', relationships['products'])
48
+ set_relationships_object(Crunchbase::Model::Category, 'categories', relationships['categories'])
49
+ set_relationships_object(Crunchbase::Model::Customer, 'customers', relationships['customers'])
50
+ set_relationships_object(Crunchbase::Model::Competitor, 'competitors', relationships['competitors'])
51
+ # set_relationships_object(PrimaryImage, 'members', relationships['members'])
52
+ set_relationships_object(Crunchbase::Model::Membership, 'memberships', relationships['memberships'])
53
+ set_relationships_object(Crunchbase::Model::FundingRound, 'funding_rounds', relationships['funding_rounds'])
54
+ set_relationships_object(Crunchbase::Model::Investment, 'investments', relationships['investments'])
55
+ set_relationships_object(Crunchbase::Model::Acquisition, 'acquisitions', relationships['acquisitions'])
56
+ set_relationships_object(Crunchbase::Model::AcquiredBy, 'acquired_by', relationships['acquired_by'])
57
+ set_relationships_object(Crunchbase::Model::Ipo, 'ipo', relationships['ipo'])
58
+ set_relationships_object(Crunchbase::Model::Fund, 'funds', relationships['funds'])
59
+ set_relationships_object(Crunchbase::Model::Website, 'websites', relationships['websites'])
60
+ set_relationships_object(Crunchbase::Model::Image, 'images', relationships['images'])
61
+ set_relationships_object(Crunchbase::Model::Video, 'videos', relationships['videos'])
62
+ set_relationships_object(Crunchbase::Model::New, 'news', relationships['news'])
63
+ end
64
+ end
65
+
66
+ def property_keys
67
+ %w[
68
+ permalink api_path web_path name also_known_as short_description description
69
+ primary_role role_company role_investor role_group role_school
70
+ founded_on founded_on_trust_code is_closed closed_on closed_on_trust_code
71
+ num_employees_min num_employees_max
72
+ total_funding_usd
73
+ stock_exchange stock_symbol
74
+ number_of_investments homepage_url
75
+ created_at updated_at
76
+ ]
77
+ end
78
+
79
+ def date_keys
80
+ %w[founded_on closed_on]
81
+ end
82
+
83
+ def self.organization_lists(permalink, options={})
84
+ return []
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class OrganizationSummary < Crunchbase::Model::Entity
5
+
6
+ attr_reader :permalink, :api_path, :web_path, :name, :primary_role, :short_description, :profile_image_url,
7
+ :domain, :homepage_url, :facebook_url, :twitter_url, :linkedin_url, :city_name, :region_name, :country_code,
8
+ :created_at, :updated_at
9
+
10
+ def property_keys
11
+ %w[
12
+ permalink api_path web_path name primary_role short_description profile_image_url
13
+ domain homepage_url facebook_url twitter_url linkedin_url city_name region_name country_code
14
+ created_at updated_at
15
+ ]
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class OwnedBy < Crunchbase::Model::Entity
5
+
6
+ attr_reader :name, :path, :created_at, :updated_at
7
+
8
+ def initialize(json)
9
+ instance_variable_set("@type_name", json['type'] || nil)
10
+
11
+ property_keys.each { |v|
12
+ instance_variable_set("@#{v}", json[v] || nil)
13
+ }
14
+
15
+ %w[created_at updated_at].each { |v|
16
+ instance_variable_set("@#{v}", Time.at(json[v]))
17
+ }
18
+ end
19
+
20
+ def property_keys
21
+ %w[
22
+ name path created_at updated_at
23
+ ]
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class ParentLocation < Crunchbase::Model::Location
5
+
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class PastTeam < Crunchbase::Model::Job
5
+
6
+ RESOURCE_LIST = 'past_team'
7
+
8
+ attr_reader :person
9
+
10
+ def initialize(json)
11
+ super
12
+
13
+ unless (relationships = json['relationships']).nil?
14
+ set_relationships_object(Crunchbase::Model::Person, 'person', relationships['person'])
15
+ end
16
+ end
17
+
18
+ def set_relationships_object(object_name, key, item)
19
+ return unless item
20
+
21
+ instance_variable_set "@#{key}", ( object_name.new(item) || nil )
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ module Crunchbase::Model
4
+ class Person < Crunchbase::Model::Entity
5
+
6
+ RESOURCE_LIST = RESOURCE_NAME = 'people'
7
+
8
+ attr_reader :permalink, :api_path, :web_path, :first_name, :last_name, :also_known_as, :bio,
9
+ :role_investor, :born_on, :born_on_trust_code, :is_deceased, :died_on, :died_on_trust_code,
10
+ :created_at, :updated_at
11
+
12
+ attr_reader :primary_affiliation, :primary_location, :primary_image, :websites, :degrees, :jobs,
13
+ :advisory_roles, :founded_companies, :investments, :memberships, :images, :videos, :news
14
+
15
+ attr_reader :primary_affiliation_total_items, :primary_location_total_items,
16
+ :primary_image_total_items, :websites_total_items, :degrees_total_items, :jobs_total_items,
17
+ :advisory_roles_total_items, :founded_companies_total_items,
18
+ :investments_total_items, :memberships_total_items, :images_total_items, :videos_total_items,
19
+ :news_total_items
20
+
21
+ def initialize(json)
22
+ super
23
+
24
+ unless (relationships = json['relationships']).nil?
25
+ set_relationships_object(Crunchbase::Model::PrimaryAffiliation, 'primary_affiliation', relationships['primary_affiliation'])
26
+ set_relationships_object(Crunchbase::Model::PrimaryAffiliation, 'primary_location', relationships['primary_location'])
27
+ set_relationships_object(Crunchbase::Model::PrimaryImage, 'primary_image', relationships['primary_image'])
28
+ set_relationships_object(Crunchbase::Model::Website, 'websites', relationships['websites'])
29
+ set_relationships_object(Crunchbase::Model::Degree, 'degrees', relationships['degrees'])
30
+ set_relationships_object(Crunchbase::Model::Job, 'jobs', relationships['jobs'])
31
+ set_relationships_object(Crunchbase::Model::AdvisoryRole, 'advisory_roles', relationships['advisor_at'])
32
+ set_relationships_object(Crunchbase::Model::FoundedCompany, 'founded_companies', relationships['founded_companies'])
33
+ set_relationships_object(Crunchbase::Model::Investment, 'investments', relationships['investments'])
34
+ set_relationships_object(Crunchbase::Model::Membership, 'memberships', relationships['memberships'])
35
+ set_relationships_object(Crunchbase::Model::Image, 'images', relationships['images'])
36
+ set_relationships_object(Crunchbase::Model::Video, 'videos', relationships['videos'])
37
+ set_relationships_object(Crunchbase::Model::New, 'news', relationships['news'])
38
+ end
39
+ end
40
+
41
+ def property_keys
42
+ %w[
43
+ permalink api_path web_path first_name last_name also_known_as bio
44
+ role_investor born_on born_on_trust_code is_deceased died_on died_on_trust_code
45
+ created_at updated_at
46
+ ]
47
+ end
48
+
49
+ def date_keys
50
+ %w[ born_on died_on ]
51
+ end
52
+
53
+
54
+ end
55
+ end