Class: InfoconnectWrapper::FindCompany

Inherits:
Object
  • Object
show all
Defined in:
lib/infoconnect_wrapper/find_company.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



4
5
6
# File 'lib/infoconnect_wrapper/find_company.rb', line 4

def api_key
  @api_key
end

Instance Method Details

#find_by_name(name, city, state, resource_type) ⇒ Object

example InfoConnectWrapper::FindCompany.find_by_name(‘Infogroup’, ‘Papillion, ’NE’, ‘Enhanced’)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/infoconnect_wrapper/find_company.rb', line 10

def find_by_name(name, city, state, resource_type)
  url = "https://api.infoconnect.com/v3/match?apikey=#{self.api_key}"
  company = Company.new
  begin
    response = RestClient.post url,
      {
      :ResourceType => resource_type,
      :CompanyName => name,
      :RequestType => "Company",
      :Limit => "1",
      :City => city,
      :StateProvince => state
    }, :content_type => :json, :accept => :json
    r = JSON.parse response
    if r["MatchCount"] > 0
      company_to_parse = r["Matches"]["Companies"][0]
      company.init(company_to_parse)
    end
  rescue => e
    puts e
  end
  company
end

#init(apikey) ⇒ Object



5
6
7
# File 'lib/infoconnect_wrapper/find_company.rb', line 5

def init(apikey)
  self.api_key = apikey 
end