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,19 +1,18 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class OrganizationSummary <
|
|
5
|
-
|
|
5
|
+
class OrganizationSummary < Entity
|
|
6
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,
|
|
7
|
+
:domain, :homepage_url, :facebook_url, :twitter_url, :linkedin_url, :city_name, :region_name, :country_code,
|
|
8
8
|
:created_at, :updated_at
|
|
9
9
|
|
|
10
10
|
def property_keys
|
|
11
|
-
%w
|
|
11
|
+
%w(
|
|
12
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
|
|
13
|
+
domain homepage_url facebook_url twitter_url linkedin_url city_name region_name country_code
|
|
14
14
|
created_at updated_at
|
|
15
|
-
|
|
15
|
+
)
|
|
16
16
|
end
|
|
17
|
-
|
|
18
17
|
end
|
|
19
|
-
end
|
|
18
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class OwnedBy <
|
|
5
|
-
|
|
5
|
+
class OwnedBy < Entity
|
|
6
6
|
attr_reader :name, :api_path, :web_path, :created_at, :updated_at
|
|
7
7
|
|
|
8
8
|
def initialize(json)
|
|
@@ -10,10 +10,9 @@ module Crunchbase::Model
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def property_keys
|
|
13
|
-
%w
|
|
13
|
+
%w(
|
|
14
14
|
name api_path web_path created_at updated_at
|
|
15
|
-
|
|
15
|
+
)
|
|
16
16
|
end
|
|
17
|
-
|
|
18
17
|
end
|
|
19
18
|
end
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class PastTeam <
|
|
5
|
-
|
|
5
|
+
class PastTeam < Job
|
|
6
6
|
RESOURCE_LIST = 'past_team'
|
|
7
7
|
|
|
8
8
|
attr_reader :person
|
|
9
9
|
|
|
10
10
|
def initialize(json)
|
|
11
11
|
super
|
|
12
|
-
|
|
13
|
-
unless (relationships = json['relationships']).nil?
|
|
14
|
-
instance_relationships_object(Crunchbase::Model::Person, 'person', relationships['person'])
|
|
15
|
-
end
|
|
16
12
|
end
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
def relationship_lists
|
|
15
|
+
{
|
|
16
|
+
'person' => Person
|
|
17
|
+
}
|
|
21
18
|
end
|
|
22
|
-
|
|
23
19
|
end
|
|
24
|
-
end
|
|
20
|
+
end
|
|
@@ -1,55 +1,62 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
module Crunchbase
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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'])
|
|
4
|
+
module Crunchbase
|
|
5
|
+
module Model
|
|
6
|
+
class Person < Entity
|
|
7
|
+
RESOURCE_LIST = RESOURCE_NAME = 'people'
|
|
8
|
+
|
|
9
|
+
attr_reader :permalink, :api_path, :web_path, :first_name, :last_name, :gender, :also_known_as, :bio, :profile_image_url,
|
|
10
|
+
:role_investor, :born_on, :born_on_trust_code, :is_deceased, :died_on, :died_on_trust_code, :name,
|
|
11
|
+
:created_at, :updated_at
|
|
12
|
+
|
|
13
|
+
attr_reader :primary_affiliation, :primary_location, :primary_image, :websites, :degrees, :jobs,
|
|
14
|
+
:advisory_roles, :founded_companies, :investments, :memberships, :images, :videos, :news
|
|
15
|
+
|
|
16
|
+
attr_reader :primary_affiliation_total_items, :primary_location_total_items,
|
|
17
|
+
:primary_image_total_items, :websites_total_items, :degrees_total_items, :jobs_total_items,
|
|
18
|
+
:advisory_roles_total_items, :founded_companies_total_items,
|
|
19
|
+
:investments_total_items, :memberships_total_items, :images_total_items, :videos_total_items,
|
|
20
|
+
:news_total_items
|
|
21
|
+
|
|
22
|
+
def initialize(json)
|
|
23
|
+
super(json)
|
|
38
24
|
end
|
|
39
|
-
end
|
|
40
25
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
def relationship_lists
|
|
27
|
+
{
|
|
28
|
+
'primary_affiliation' => PrimaryAffiliation,
|
|
29
|
+
'primary_location' => PrimaryLocation,
|
|
30
|
+
'primary_image' => PrimaryImage,
|
|
31
|
+
'websites' => Website,
|
|
32
|
+
'degrees' => Degree,
|
|
33
|
+
'jobs' => Job,
|
|
34
|
+
'advisory_roles' => AdvisoryRole,
|
|
35
|
+
'founded_companies' => FoundedCompany,
|
|
36
|
+
'investments' => Investment,
|
|
37
|
+
'memberships' => Membership,
|
|
38
|
+
'images' => Image,
|
|
39
|
+
'videos' => Video,
|
|
40
|
+
'news' => New
|
|
41
|
+
}
|
|
42
|
+
end
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
def property_keys
|
|
45
|
+
%w(
|
|
46
|
+
permalink api_path web_path first_name last_name gender also_known_as bio profile_image_url
|
|
47
|
+
role_investor born_on born_on_trust_code is_deceased died_on died_on_trust_code
|
|
48
|
+
created_at updated_at
|
|
49
|
+
)
|
|
50
|
+
end
|
|
52
51
|
|
|
52
|
+
def date_keys
|
|
53
|
+
%w(born_on died_on)
|
|
54
|
+
end
|
|
53
55
|
|
|
56
|
+
# custom name from first name and last name
|
|
57
|
+
def name
|
|
58
|
+
[first_name, last_name].compact.join(' ')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
54
61
|
end
|
|
55
62
|
end
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class PersonSummary <
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
:
|
|
8
|
-
:
|
|
9
|
-
:city_name, :region_name, :country_code,
|
|
5
|
+
class PersonSummary < Entity
|
|
6
|
+
attr_reader :permalink, :api_path, :web_path, :first_name, :last_name, :title,
|
|
7
|
+
:organization_permalink, :organization_api_path, :organization_web_path, :organization_name,
|
|
8
|
+
:profile_image_url, :homepage_url, :facebook_url, :twitter_url, :linkedin_url,
|
|
9
|
+
:city_name, :region_name, :country_code,
|
|
10
10
|
:created_at, :updated_at
|
|
11
11
|
|
|
12
12
|
def property_keys
|
|
13
|
-
%w
|
|
14
|
-
permalink api_path web_path first_name last_name title
|
|
15
|
-
organization_permalink organization_api_path organization_web_path organization_name
|
|
16
|
-
profile_image_url homepage_url facebook_url twitter_url linkedin_url
|
|
17
|
-
city_name region_name country_code
|
|
13
|
+
%w(
|
|
14
|
+
permalink api_path web_path first_name last_name title
|
|
15
|
+
organization_permalink organization_api_path organization_web_path organization_name
|
|
16
|
+
profile_image_url homepage_url facebook_url twitter_url linkedin_url
|
|
17
|
+
city_name region_name country_code
|
|
18
18
|
created_at updated_at
|
|
19
|
-
|
|
19
|
+
)
|
|
20
20
|
end
|
|
21
|
-
|
|
22
21
|
end
|
|
23
|
-
end
|
|
22
|
+
end
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class PrimaryAffiliation <
|
|
5
|
-
|
|
5
|
+
class PrimaryAffiliation < Job
|
|
6
6
|
attr_reader :organization
|
|
7
7
|
|
|
8
8
|
def initialize(json)
|
|
9
9
|
super
|
|
10
10
|
|
|
11
11
|
unless (relationships = json['relationships']).nil?
|
|
12
|
-
set_relationships_object(
|
|
12
|
+
set_relationships_object(Organization, 'organization', relationships['organization'])
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def set_relationships_object(
|
|
16
|
+
def set_relationships_object(kclass_name, key, item)
|
|
17
17
|
return unless item
|
|
18
18
|
|
|
19
|
-
instance_variable_set "@#{key}", (
|
|
19
|
+
instance_variable_set "@#{key}", (kclass_name.new(item) || nil)
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
-
end
|
|
22
|
+
end
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class PrimaryLocation <
|
|
5
|
-
|
|
5
|
+
class PrimaryLocation < Location
|
|
6
6
|
attr_reader :parent_locations
|
|
7
7
|
|
|
8
8
|
def initialize(json)
|
|
9
9
|
super
|
|
10
|
-
|
|
11
|
-
unless (relationships = json['relationships']).nil?
|
|
12
|
-
set_relationships_object(Crunchbase::Model::ParentLocation, 'parent_locations', relationships['parent_locations'])
|
|
13
|
-
end
|
|
14
10
|
end
|
|
15
11
|
|
|
12
|
+
def relationship_lists
|
|
13
|
+
{
|
|
14
|
+
'parent_locations' => ParentLocation
|
|
15
|
+
}
|
|
16
|
+
end
|
|
16
17
|
end
|
|
17
|
-
end
|
|
18
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
4
|
module Crunchbase::Model
|
|
4
|
-
class Product <
|
|
5
|
-
|
|
5
|
+
class Product < Entity
|
|
6
6
|
RESOURCE_LIST = RESOURCE_NAME = 'products'
|
|
7
7
|
|
|
8
8
|
attr_reader :permalink, :api_path, :web_path, :name, :also_known_as,
|
|
@@ -20,28 +20,29 @@ module Crunchbase::Model
|
|
|
20
20
|
|
|
21
21
|
def initialize(json)
|
|
22
22
|
super
|
|
23
|
+
end
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
def relationship_lists
|
|
26
|
+
{
|
|
27
|
+
'categories' => Category,
|
|
28
|
+
'primary_image' => PrimaryImage,
|
|
29
|
+
'images' => Image,
|
|
30
|
+
'video' => Video,
|
|
31
|
+
'news' => New
|
|
32
|
+
}
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def property_keys
|
|
34
|
-
%w
|
|
36
|
+
%w(
|
|
35
37
|
permalink api_path web_path name also_known_as
|
|
36
38
|
lifecycle_stage short_description description profile_image_url
|
|
37
39
|
launched_on launched_on_trust_code closed_on closed_on_trust_code
|
|
38
40
|
homepage_url created_at updated_at
|
|
39
|
-
|
|
41
|
+
)
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
def date_keys
|
|
43
|
-
%w
|
|
45
|
+
%w(launched_on closed_on)
|
|
44
46
|
end
|
|
45
|
-
|
|
46
47
|
end
|
|
47
48
|
end
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module Crunchbase::Model
|
|
2
|
-
class ProductSummary <
|
|
3
|
-
|
|
3
|
+
class ProductSummary < Entity
|
|
4
4
|
attr_reader :permalink, :api_path, :web_path, :name, :short_description,
|
|
5
5
|
:owner_permalink, :owner_api_path, :owner_web_path, :owner_name,
|
|
6
6
|
:profile_image_url, :homepage_url, :facebook_url, :twitter_url, :linkedin_url,
|
|
7
7
|
:created_at, :updated_at
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
def property_keys
|
|
11
|
-
%w
|
|
10
|
+
%w(
|
|
12
11
|
permalink api_path web_path name short_description
|
|
13
12
|
owner_permalink owner_api_path owner_web_path owner_name
|
|
14
13
|
profile_image_url homepage_url facebook_url twitter_url linkedin_url
|
|
15
14
|
created_at updated_at
|
|
16
|
-
|
|
15
|
+
)
|
|
17
16
|
end
|
|
18
17
|
end
|
|
19
18
|
end
|
|
@@ -1,55 +1,54 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
module Crunchbase
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
module Crunchbase
|
|
5
|
+
module Model
|
|
6
|
+
class Search < Entity
|
|
7
|
+
include Enumerable
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
attr_reader :total_items, :per_page, :pages, :current_page, :prev_page_url, :next_page_url
|
|
10
|
+
attr_reader :sort_order, :results
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
alias length total_items
|
|
13
|
+
alias size total_items
|
|
14
|
+
alias items results
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
def initialize(query, json, kclass)
|
|
17
|
+
@query = query
|
|
18
|
+
@results = []
|
|
19
|
+
@total_items = 0
|
|
20
|
+
@pages = 0
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def populate_results(json, _model)
|
|
24
|
-
@results = if json["items"].nil?
|
|
25
|
-
[]
|
|
26
|
-
else
|
|
27
|
-
json["items"].map{|r| _model.new(r)}
|
|
22
|
+
populate_results(json, kclass) if json['error'].nil?
|
|
28
23
|
end
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
def populate_results(json, kclass)
|
|
26
|
+
@results = []
|
|
27
|
+
@results = json['items'].map { |r| kclass.new(r) } unless json['items'].nil?
|
|
28
|
+
|
|
29
|
+
@total_items = json['paging']['total_items']
|
|
30
|
+
@per_page = json['paging']['items_per_page']
|
|
31
|
+
@pages = json['paging']['number_of_pages']
|
|
32
|
+
@current_page = json['paging']['current_page']
|
|
33
|
+
@prev_page_url = json['paging']['prev_page_url']
|
|
34
|
+
@next_page_url = json['paging']['next_page_url']
|
|
35
|
+
@sort_order = json['paging']['sort_order']
|
|
36
|
+
end
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
# Finds an entity by its name. Uses two HTTP requests; one to find the
|
|
39
|
+
# permalink, and another to request the actual entity.
|
|
40
|
+
def self.search(options, resource_list)
|
|
41
|
+
model_name = kclass_name(resource_list)
|
|
43
42
|
|
|
44
|
-
|
|
43
|
+
raise 'Unknown type error!' if model_name.nil?
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
Search.new options, API.search(options, resource_list), model_name
|
|
46
|
+
end
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
# Factory method to return an instance from a permalink
|
|
49
|
+
def self.get(_permalink)
|
|
50
|
+
nil
|
|
51
|
+
end
|
|
52
52
|
end
|
|
53
|
-
|
|
54
53
|
end
|
|
55
54
|
end
|