Class: Foursquare::Merchant::Venues

Inherits:
Base
  • Object
show all
Defined in:
lib/foursquare/venues.rb

Constant Summary

Constants included from Requests

Requests::API, Requests::OAUTH

Instance Attribute Summary

Attributes inherited from Base

#consumer

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Requests

#get, #post

Constructor Details

This class inherits a constructor from Foursquare::Merchant::Base

Instance Method Details

#find(venue_id, params = {}) ⇒ Object



7
8
9
10
# File 'lib/foursquare/venues.rb', line 7

def find(venue_id, params={})
  response = self.get("/#{venue_id}", params)
  Foursquare::Merchant::Venue.new(response['venue'], @consumer)
end

#managed(params = {}) ⇒ Object



12
13
14
15
16
# File 'lib/foursquare/venues.rb', line 12

def managed(params={})
  response = self.get("/managed", params)
  venues = response['venues']
  venues.map { |item| Foursquare::Merchant::Venue.new(item, @consumer) }
end

#search(params) ⇒ Object



28
29
30
31
32
33
# File 'lib/foursquare/venues.rb', line 28

def search(params)
  raise "Must include lat/lng string" unless params.has_key? :ll
  response = self.get("/search", params)
  venues = response['groups'].map { |res| res['items'] }.flatten
  venues.map { |item| Foursquare::Merchant::Venue.new(item, @consumer) }
end

#timeseries(venue_ids, start_at = nil, end_at = nil) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/foursquare/venues.rb', line 18

def timeseries(venue_ids, start_at=nil, end_at=nil)
  params = {}
  params[:venue_id] = listify(venue_ids)
  params[:start_at] = start_at if start_at
  params[:end_at]   = end_at if end_at

  response = self.get("/timeseries", params)['timeseries']
  response.map { |ts| TimeSeries.new(ts) }
end