g_ruby 0.0.3 → 0.0.4
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 +63 -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: 53e3e76e11e3c4e052383526390eb5b62ee40ea9
|
4
|
+
data.tar.gz: bcd26746404bfcea68009b701aa0463f951d4ec3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94b45960edb4bd905370de4717deb40e8e8e036715904aed2b29e73361c8a7521a10612892d283e0edc11db15953434b6fbd8eec405b70191ded14a5736f9d34
|
7
|
+
data.tar.gz: 012cf4a4f9bac5626eff28097375de0b404c8fbea38eddfb399893c4884424e97022cff424cd09110337553bbccf77bdbd90ad60c2a8be80b9d85b031c5db4ad
|
data/lib/g_ruby/analytics.rb
CHANGED
@@ -1,6 +1,69 @@
|
|
1
1
|
class GRuby::Analytics
|
2
2
|
|
3
3
|
require 'g_ruby/util'
|
4
|
+
|
5
|
+
#---------------------------------------------------------------------------------------------------
|
6
|
+
|
7
|
+
#GRuby::Analytics.accounts(access_token, pid)
|
8
|
+
def self.accounts(access_token, pid)
|
9
|
+
url = "https://www.googleapis.com/analytics/v3/management/accounts?access_token=#{access_token}"
|
10
|
+
a = GRuby::Util.get_json(Nestful.get(url))
|
11
|
+
response_obj = []
|
12
|
+
if !a.blank?
|
13
|
+
if !a["items"].blank?
|
14
|
+
if !a["items"].first.blank?
|
15
|
+
a["items"].each do |account|
|
16
|
+
if !account["id"].blank?
|
17
|
+
url_w = "https://www.googleapis.com/analytics/v3/management/accounts/#{account['id'].to_s}/webproperties?access_token=#{access_token}"
|
18
|
+
w = GRuby::Util.get_json(Nestful.get(url_w))
|
19
|
+
if !w.blank?
|
20
|
+
if !w["items"].blank?
|
21
|
+
if !w["items"].first.blank?
|
22
|
+
w["items"].each do |webprop|
|
23
|
+
if !webprop["id"].blank?
|
24
|
+
url_p = "https://www.googleapis.com/analytics/v3/management/accounts/#{account['id'].to_s}/webproperties/#{webprop['id'].to_s}/profiles?access_token=#{access_token}"
|
25
|
+
p = GRuby::Util.get_json(Nestful.get(url_p))
|
26
|
+
if !p.blank?
|
27
|
+
if !p["items"].blank?
|
28
|
+
if !p["items"].first.blank?
|
29
|
+
p["items"].each do |prof|
|
30
|
+
if !prof["id"].blank?
|
31
|
+
if pid == prof["id"]
|
32
|
+
response_obj << [account["id"], webprop["id"], prof["created"]]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
return response_obj
|
50
|
+
end
|
51
|
+
|
52
|
+
#---------------------------------------------------------------------------------------------------
|
53
|
+
|
54
|
+
#def self.goals(access_token, aid, wid, pid)
|
55
|
+
#url = "https://www.googleapis.com/analytics/v3/management/accounts/#{aid}/webproperties/#{wid}/profiles/#{pid}/goals?access_token=#{access_token}"
|
56
|
+
#a = GRuby::Util.get_json(Nestful.get(url))
|
57
|
+
#response_obj = []
|
58
|
+
#if !a["items"].blank?
|
59
|
+
#if !a["items"].first.blank?
|
60
|
+
#a["items"].each do b
|
61
|
+
#response_obj << [start_date: , end_date: ]
|
62
|
+
#end
|
63
|
+
#end
|
64
|
+
#end
|
65
|
+
#return response_obj
|
66
|
+
#end
|
4
67
|
|
5
68
|
#---------------------------------------------------------------------------------------------------
|
6
69
|
|