fsquare 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fsquare/version.rb +1 -1
- data/lib/fsquare.rb +31 -7
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1761fdde444b8e1da706cce5872da685d5f1b2cb
|
|
4
|
+
data.tar.gz: 198dd55f806aebe057033134151f018f1294a78e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 18d843e2343ac65618f0168a86513f9e2c87a52b177c62d547092c9b25e79ee9e05f3c62290d604e5f8be235b170f4b06c8ea7a92957881bdfb5fa816b5ea13b
|
|
7
|
+
data.tar.gz: 826bdeb006d75ffc32e6f9df8b03dd02536c533829dbac368cc677e49a214e2e767594b49240ddb0d292938f020609c18bbbffa93c27731571f00807f961ce65
|
data/lib/fsquare/version.rb
CHANGED
data/lib/fsquare.rb
CHANGED
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
require "fsquare/version"
|
|
2
2
|
|
|
3
3
|
module Fsquare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
client_id = ENV['foursquare_client_id']
|
|
7
|
-
client_secret = ENV['foursquare_client_secret']
|
|
8
|
-
v = Time.now.strftime = "%Y%m%d"
|
|
4
|
+
@@client_id
|
|
5
|
+
@@client_secret
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
def self.set_client_id(clientId)
|
|
8
|
+
@@client_id = clientId
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.get_client_id
|
|
12
|
+
return @@client_id
|
|
13
|
+
end
|
|
14
|
+
def self.set_client_secret(clientSecret)
|
|
15
|
+
@@client_secret = clientSecret
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.get_client_secret
|
|
19
|
+
return @@client_secret
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.request_data(path, data)
|
|
23
|
+
cacheKey = path + data.to_s
|
|
24
|
+
Rails.cache.fetch(cacheKey, :expires => 24.hour) do
|
|
25
|
+
v = currentTime.strftime "%Y%m%d"
|
|
26
|
+
|
|
27
|
+
clientId = self.get_client_id()
|
|
28
|
+
if clientId.nil?
|
|
29
|
+
raise "client_id is not defined. Please call set_client_id()"
|
|
30
|
+
end
|
|
31
|
+
if clientSecret.nil?
|
|
32
|
+
raise "client_secret is not defined. Please call set_client_secret()"
|
|
33
|
+
end
|
|
34
|
+
search_url = "https://api.foursquare.com#{path}&client_id=#{clientId}&client_secret=#{@@clientSecret}&" + JSON.parse(data)
|
|
11
35
|
result = HTTParty.get(search_url)
|
|
12
36
|
result['response']
|
|
13
37
|
end
|
|
14
|
-
result = Rails.cache.fetch(
|
|
38
|
+
result = Rails.cache.fetch(cacheKey)
|
|
15
39
|
return result
|
|
16
40
|
end
|
|
17
41
|
def self.venue_search(query, location, lat, long)
|