Class: BizRatr::FourSquareConnector
Instance Method Summary
collapse
Methods inherited from Connector
#initialize
Instance Method Details
#make_business(item) ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/bizratr/connector.rb', line 119
def make_business(item)
b = Business.new(@uberclient, item['location']['lat'], item['location']['lng'], item['name'])
b.add_id(:foursquare, item['id'])
categories = item.categories.map { |c| [ c.name ] + c.parents }.flatten
b.add_categories(:foursquare, categories)
b.phone = item['contact'].fetch('phone', '').gsub(/[\ ()-]*/, '')
b. = item['contact'].fetch('twitter', nil)
b.state = item['location']['state']
b.city = item['location']['city']
b.country = item['location']['cc']
b.address = item['location']['address']
b.add_checkins(:foursquare, item['stats']['checkinsCount'])
b.website = item['url']
b.add_users(:foursquare, item['stats']['usersCount'])
b
end
|
#make_client(config) ⇒ Object
110
111
112
|
# File 'lib/bizratr/connector.rb', line 110
def make_client(config)
Foursquare2::Client.new(config)
end
|
#search_location(location, query) ⇒ Object
114
115
116
117
|
# File 'lib/bizratr/connector.rb', line 114
def search_location(location, query)
results = @client.search_venues(:ll => location.join(","), :query => query)
results['groups'].first['items'].map { |item| make_business(item) }
end
|