Module: Nymeria::Company

Defined in:
lib/nymeria/company.rb

Class Method Summary collapse

Class Method Details

.enrich(args = {}) ⇒ Object

args: { name: ”, website: ”, profile: ” }



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nymeria/company.rb', line 5

def self.enrich(args={})
  uri = URI("#{BASE_URL}/company/enrich")

  uri.query = URI.encode_www_form(args)

  req = Nymeria::request(Net::HTTP::Get.new(uri))

  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
    http.request(req)
  end

  return OpenStruct.new(JSON.parse(res.body))
rescue => e
  OpenStruct.new(
    success?: false,
    error: "#{e}"
  )
end

.search(args = {}) ⇒ Object

args: { query: ‘name:Nymeria’, size: 10, from: 0 }



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/nymeria/company.rb', line 25

def self.search(args={})
  uri = URI("#{BASE_URL}/company/search")

  uri.query = URI.encode_www_form(args)

  req = Nymeria::request(Net::HTTP::Get.new(uri))

  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
    http.request(req)
  end

  return OpenStruct.new(JSON.parse(res.body))
rescue => e
  OpenStruct.new(
    success?: false,
    error: "#{e}"
  )
end