Class: BizRatr::FactualConnector

Inherits:
Connector show all
Defined in:
lib/bizratr/connector.rb

Instance Method Summary collapse

Methods inherited from Connector

#initialize

Constructor Details

This class inherits a constructor from BizRatr::Connector

Instance Method Details

#make_business(item) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/bizratr/connector.rb', line 69

def make_business(item)
  b = Business.new(@uberclient, item['latitude'], item['longitude'], item['name'])
  b.add_id(:factual, item['factual_id'])
  b.add_categories(:factual, item['category'].split(",").map(&:strip))
  b.phone = item['tel'].gsub(/[\ ()-]*/, '')
  b.website = item['website']
  b.city = item['locality']
  b.country = item['country']
  b.zip = item['postcode']
  b.address = item['address']
  b
end

#make_client(config) ⇒ Object



60
61
62
# File 'lib/bizratr/connector.rb', line 60

def make_client(config)
  Factual.new(config[:key], config[:secret])
end

#search_location(location, query) ⇒ Object



64
65
66
67
# File 'lib/bizratr/connector.rb', line 64

def search_location(location, query)
  results = @client.table("places").filters("name" => query).geo("$circle" => { "$center" => location, "$meters" => 1000 })
  results.map { |item| make_business(item) }
end