g_ruby 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/g_ruby/analytics.rb +3 -1
- data/lib/g_ruby/auth.rb +6 -0
- 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: 89cf9ad379738fe1cc5ac11eb32b7e05dc4ba2ad
|
4
|
+
data.tar.gz: 0b4a62d5dda205b2c6f9d562b5b50c575719e45d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b64ada8be3dbb13f30bfb63bf2c819842265d934bd80783079d390142388d0cb0aac96160e97a8d0961fd0d8d1de441b875b38ccc2d92ce070920c7394b77f8c
|
7
|
+
data.tar.gz: 0bc55d9ed48513113413efb00d1929acdeac61855988939cb8ffee8c6a38188155ea718f75665a8bfd23d424f37a52e79f0b466e63b05838931950261416ff16
|
data/lib/g_ruby/analytics.rb
CHANGED
@@ -6,10 +6,12 @@ class GRuby::Analytics
|
|
6
6
|
|
7
7
|
#---------------------------------------------------------------------------------------------------
|
8
8
|
|
9
|
+
a_json = GRuby::Analytics.get(ak.app_password, start_date, end_date, ak.entity_name, "ga:visits", "ga:medium", "-ga:visits", nil)
|
10
|
+
|
9
11
|
#GRuby::Analytics.get(access_token, start_date, end_date, profile_id, metrics, dimensions, sort, max_results)
|
10
12
|
def self.get(access_token, start_date, end_date, profile_id, metrics, dimensions=nil, sort=nil, limit=nil)
|
11
13
|
#begin
|
12
|
-
url =
|
14
|
+
url = "https://www.googleapis.com/analytics/v3/data/ga?access_token=#{access_token}&start-date=#{start_date}&end-date=#{end_date}&ids=ga:#{profile_id}&metrics=#{metrics}"
|
13
15
|
url = url + "&dimensions=#{dimensions}" if !dimensions.blank?
|
14
16
|
url = url + "&sort=#{sort}" if !sort.blank?
|
15
17
|
url = url + "&max-results=#{limit}" if !limit.blank?
|
data/lib/g_ruby/auth.rb
CHANGED
@@ -14,5 +14,11 @@ class GRuby::Auth
|
|
14
14
|
g = Nestful.post "https://accounts.google.com/o/oauth2/token?method=POST&grant_type=authorization_code&code=#{auth_code}&client_id=#{GOOGLE_CLIENTID}&client_secret=#{GOOGLE_SECRET}&redirect_uri=#{GOOGLE_CALLBACK}"
|
15
15
|
return GRuby::Util.get_json(g)
|
16
16
|
end
|
17
|
+
|
18
|
+
#GRuby::Auth.refresh(refresh_token)
|
19
|
+
def self.refresh(refresh_token)
|
20
|
+
g = Nestful.post "https://accounts.google.com/o/oauth2/token?method=POST&grant_type=refresh_token&refresh_token=#{refresh_token}&client_id=#{GOOGLE_CLIENTID}&client_secret=#{GOOGLE_SECRET}"
|
21
|
+
return GRuby::Util.get_json(g)
|
22
|
+
end
|
17
23
|
|
18
24
|
end
|