Module: Crunchbase::Utilities::Request

Included in:
Autocompletes::Client, DeletedEntities::Client, Entities::Client, Searches::Client
Defined in:
lib/crunchbase/utilities/request.rb

Overview

Key Reminder

entity_id must be provided in the request
entity_id can be the uuid or the permalink of the entity
you can pass your API key in the request's header if you do not want to pass the API key in the URL

Class Method Summary collapse

Class Method Details

.deleted(uri, *args) ⇒ Object



25
26
27
# File 'lib/crunchbase/utilities/request.rb', line 25

def deleted(uri, *args)
  fetch_request(uri, *args)
end

.entity(uri, *args) ⇒ Object

Entity endpoints

https://app.swaggerhub.com/apis-docs/Crunchbase/crunchbase-enterprise_api/1.0.1#/Entity/get_entities_organizations__entity_id_


32
33
34
# File 'lib/crunchbase/utilities/request.rb', line 32

def entity(uri, *args)
  fetch_request(uri, *args)
end

.get(uri, *args) ⇒ Object

Autocompletes endpoint



21
22
23
# File 'lib/crunchbase/utilities/request.rb', line 21

def get(uri, *args)
  fetch_request(uri, *args)
end

.search(uri, args) ⇒ Object

Search endpoints

https://app.swaggerhub.com/apis-docs/Crunchbase/crunchbase-enterprise_api/1.0.1#/Search/post_searches_organizations

Raises:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/crunchbase/utilities/request.rb', line 39

def search(uri, args)
  response = Faraday.new(url: BASE_URI, headers: post_headers) do |faraday|
    faraday.adapter Faraday.default_adapter
    faraday.response :json
    faraday.request :curl, ::Logger.new(STDOUT), :warn if debug_mode?
    faraday.response :logger, ::Logger.new(STDOUT), bodies: true if debug_mode?
  end.post(uri, args)

  resp_body = response.body
  resp_status = response.status
  return resp_body if resp_status == 200

  raise Error, resp_body.is_a?(Array) ? resp_body[0]['message'] : resp_body['error']
end