Module: Crunchbase::Request::Client
- Included in:
- Model::Entity
- Defined in:
- lib/crunchbase/request/client.rb
Instance Method Summary collapse
- #api ⇒ Object
- #array_from_list(list) ⇒ Object
- #funding_rounds_lists(permalink, options = {}) ⇒ Object
-
#get(permalink) ⇒ Object
Factory method to return an instance from a permalink.
- #kclass_name(resource_list) ⇒ Object
- #list(page = nil) ⇒ Object
- #organization_lists(permalink, options = {}) ⇒ Object
- #parsing_from_list(list) ⇒ Object
- #person_lists(permalink, options = {}) ⇒ Object
- #total_items_from_list(list) ⇒ Object
Instance Method Details
#api ⇒ Object
63 64 65 |
# File 'lib/crunchbase/request/client.rb', line 63 def api Crunchbase::API end |
#array_from_list(list) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/crunchbase/request/client.rb', line 37 def array_from_list(list) return [] if list.nil? list['items'].map do |l| new l if l.is_a?(Hash) end.compact end |
#funding_rounds_lists(permalink, options = {}) ⇒ Object
31 32 33 34 35 |
# File 'lib/crunchbase/request/client.rb', line 31 def funding_rounds_lists(permalink, = {}) = .merge(model_name: self) api.funding_rounds_lists(permalink, self::RESOURCE_LIST.tr('_', '-'), ) end |
#get(permalink) ⇒ Object
Factory method to return an instance from a permalink
7 8 9 10 11 |
# File 'lib/crunchbase/request/client.rb', line 7 def get(permalink) result = api.single_entity(permalink, self::RESOURCE_NAME) new(result) end |
#kclass_name(resource_list) ⇒ Object
59 60 61 |
# File 'lib/crunchbase/request/client.rb', line 59 def kclass_name(resource_list) api::SUPPORTED_ENTITIES[resource_list] || nil end |
#list(page = nil) ⇒ Object
13 14 15 16 17 |
# File 'lib/crunchbase/request/client.rb', line 13 def list(page = nil) model_name = kclass_name(self::RESOURCE_LIST) api.list({ page: page, model_name: model_name }, self::RESOURCE_LIST) end |
#organization_lists(permalink, options = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/crunchbase/request/client.rb', line 19 def organization_lists(permalink, = {}) = .merge(model_name: self) api.organization_lists(permalink, self::RESOURCE_LIST, ) end |
#parsing_from_list(list) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/crunchbase/request/client.rb', line 45 def parsing_from_list(list) return [] if list.nil? list.map do |l| new l if l.is_a?(Hash) end.compact end |
#person_lists(permalink, options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/crunchbase/request/client.rb', line 25 def person_lists(permalink, = {}) = .merge(model_name: self) api.person_lists(permalink, self::RESOURCE_LIST, ) end |
#total_items_from_list(list) ⇒ Object
53 54 55 56 57 |
# File 'lib/crunchbase/request/client.rb', line 53 def total_items_from_list(list) return 0 if list.nil? list['paging']['total_items'] end |