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
64 65 66 |
# File 'lib/crunchbase/request/client.rb', line 64 def api Crunchbase::API end |
#array_from_list(list) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/crunchbase/request/client.rb', line 38 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
32 33 34 35 36 |
# File 'lib/crunchbase/request/client.rb', line 32 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
8 9 10 11 12 |
# File 'lib/crunchbase/request/client.rb', line 8 def get(permalink) result = api.single_entity(permalink, self::RESOURCE_NAME) new(result) end |
#kclass_name(resource_list) ⇒ Object
60 61 62 |
# File 'lib/crunchbase/request/client.rb', line 60 def kclass_name(resource_list) api::SUPPORTED_ENTITIES[resource_list] || nil end |
#list(page = nil) ⇒ Object
14 15 16 17 18 |
# File 'lib/crunchbase/request/client.rb', line 14 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
20 21 22 23 24 |
# File 'lib/crunchbase/request/client.rb', line 20 def organization_lists(permalink, = {}) = .merge(model_name: self) api.organization_lists(permalink, self::RESOURCE_LIST, ) end |
#parsing_from_list(list) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/crunchbase/request/client.rb', line 46 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
26 27 28 29 30 |
# File 'lib/crunchbase/request/client.rb', line 26 def person_lists(permalink, = {}) = .merge(model_name: self) api.person_lists(permalink, self::RESOURCE_LIST, ) end |
#total_items_from_list(list) ⇒ Object
54 55 56 57 58 |
# File 'lib/crunchbase/request/client.rb', line 54 def total_items_from_list(list) return 0 if list.nil? list['paging']['total_items'] end |