module Fsquare
Constants
- VERSION
Public Class Methods
initialize(clientId, clientSecret)
click to toggle source
# File lib/fsquare.rb, line 7 def self.initialize(clientId, clientSecret) @clientId = clientId @clientSecret = clientSecret end
request_data(path, data)
click to toggle source
# 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)
click to toggle source
# 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