kynetx_am_api 0.1.29 → 0.1.30
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.
- data/lib/kynetx_am_api/application.rb +17 -0
- data/lib/kynetx_am_api/direct_api.rb +37 -3
- data/lib/kynetx_am_api/user.rb +13 -0
- metadata +4 -4
@@ -135,6 +135,23 @@ module KynetxAmApi
|
|
135
135
|
load_base
|
136
136
|
load_versions
|
137
137
|
end
|
138
|
+
|
139
|
+
#----- Stats Methods
|
140
|
+
|
141
|
+
def kpis(range="previous_day")
|
142
|
+
return @api.get_app_stats_kpis(@application_id, range)
|
143
|
+
end
|
144
|
+
|
145
|
+
def stats(k,d,c=nil,r=nil)
|
146
|
+
# Accept kpis and dims as a String or Array
|
147
|
+
kpis = k.class == Array ? k.split(",") : k
|
148
|
+
dims = d.class == Array ? d.split(",") : d
|
149
|
+
return @api.get_stats_query(kpis,dims,c,r)
|
150
|
+
end
|
151
|
+
|
152
|
+
def logging(range="previous_day")
|
153
|
+
return @api.get_stats_logging(@application_id, range)
|
154
|
+
end
|
138
155
|
|
139
156
|
#----- Distrubution Methods
|
140
157
|
|
@@ -4,8 +4,7 @@ module KynetxAmApi
|
|
4
4
|
require 'json'
|
5
5
|
require 'net/http/post/multipart'
|
6
6
|
|
7
|
-
class DirectApi
|
8
|
-
|
7
|
+
class DirectApi
|
9
8
|
attr_accessor :oauth
|
10
9
|
|
11
10
|
#
|
@@ -158,6 +157,31 @@ module KynetxAmApi
|
|
158
157
|
return user
|
159
158
|
end
|
160
159
|
|
160
|
+
def get_app_stats_kpis(application_id, range)
|
161
|
+
return get_response("app/#{application_id}/stats/kpis/#{range}", :json)
|
162
|
+
end
|
163
|
+
|
164
|
+
def get_stats_query(k,d,c=nil,r=nil)
|
165
|
+
q_params = QueryParams.new.merge({:k => k, :d => d})
|
166
|
+
if c
|
167
|
+
# c are the conditions and they are supplied like so:
|
168
|
+
# [ {:field => "fieldname", :value => "value"}, ...]
|
169
|
+
c.each do |condition|
|
170
|
+
q_params["where_#{condition[:field]}".to_sym] = condition[:value]
|
171
|
+
end
|
172
|
+
end
|
173
|
+
q_params[:r] = r if r
|
174
|
+
return get_response("stats/query" + q_params.to_params, :json)
|
175
|
+
end
|
176
|
+
|
177
|
+
def get_stats_interface
|
178
|
+
return get_response("stats/interface", :json)
|
179
|
+
end
|
180
|
+
|
181
|
+
def get_stats_logging(application_id, range)
|
182
|
+
return get_response("app/#{application_id}/stats/logging/#{range}", :json)
|
183
|
+
end
|
184
|
+
|
161
185
|
private
|
162
186
|
|
163
187
|
def get_response(api_method, format = nil)
|
@@ -207,4 +231,14 @@ module KynetxAmApi
|
|
207
231
|
|
208
232
|
|
209
233
|
end
|
210
|
-
|
234
|
+
|
235
|
+
|
236
|
+
class QueryParams < Hash
|
237
|
+
def to_params
|
238
|
+
return "" if self.empty?
|
239
|
+
p = "?"
|
240
|
+
self.each {|k,v| p += "#{CGI::escape k.to_s}=#{CGI::escape v.to_s}&"}
|
241
|
+
return p.chop
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
data/lib/kynetx_am_api/user.rb
CHANGED
@@ -102,6 +102,7 @@ module KynetxAmApi
|
|
102
102
|
|
103
103
|
def owns_current?
|
104
104
|
return false unless @current_application
|
105
|
+
return false unless @current_application.owner
|
105
106
|
return @current_application.owner["kynetxuserid"].to_i == self.userid.to_i
|
106
107
|
end
|
107
108
|
|
@@ -118,6 +119,18 @@ module KynetxAmApi
|
|
118
119
|
}
|
119
120
|
end
|
120
121
|
|
122
|
+
def kpis(rulesets=[], range=nil)
|
123
|
+
conditions = rulesets.empty? ? nil : []
|
124
|
+
rulesets.each do |ruleset|
|
125
|
+
conditions.push << {:field => "ruleset", :value => ruleset}
|
126
|
+
end
|
127
|
+
return api.get_stats_query("rse,brse,rules,rules_fired,actions,callbacks", 'ruleset,day', conditions, range)
|
128
|
+
end
|
129
|
+
|
130
|
+
def stats_interface
|
131
|
+
return api.get_stats_interface
|
132
|
+
end
|
133
|
+
|
121
134
|
|
122
135
|
end
|
123
136
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kynetx_am_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 30
|
10
|
+
version: 0.1.30
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Farmer, Cid Dennis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-17 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|