Module: Fsquare
- Defined in:
- lib/fsquare.rb,
lib/fsquare/version.rb
Constant Summary collapse
- VERSION =
"1.0.14"
Class Method Summary collapse
- .initialize(clientId, clientSecret) ⇒ Object
- .request_data(path, data) ⇒ Object
- .venue_search(query, location, lat, long) ⇒ Object
Class Method Details
.initialize(clientId, clientSecret) ⇒ Object
7 8 9 10 |
# File 'lib/fsquare.rb', line 7 def self.initialize(clientId, clientSecret) @clientId = clientId @clientSecret = clientSecret end |
.request_data(path, data) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fsquare.rb', line 12 def self.request_data(path, data) cacheKey = path + data.to_s Rails.cache.fetch(cacheKey, :expires => 24.hour) do unless data.nil? || data[:v].nil? data[:v] = data[:v].strftime "%Y%m%d" end if @clientId.nil? || @clientSecret.nil? raise "client_id or client_secret is not defined. Please call initialize()" end search_url = "https://api.foursquare.com#{path}&client_id=#{@clientId}&client_secret=#{@clientSecret}&" + data.to_query result = HTTParty.get(search_url) result['response'] end result = Rails.cache.fetch(cacheKey) return result end |
.venue_search(query, location, lat, long) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fsquare.rb', line 28 def self.venue_search(query, location, lat, long) query = CGI.escape(query) path = "/v2/venues/search?query=#{query}&" if location === "Current Location" path += "li=#{lat}.#{long}" else location = CGI.escape(location) path += "near=#{location}" end end |