romniture 0.0.3 → 0.0.4
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/README.markdown +4 -3
- data/Rakefile +5 -6
- data/lib/romniture/client.rb +10 -4
- data/lib/romniture/exceptions.rb +13 -0
- data/lib/romniture/version.rb +1 -1
- data/lib/romniture.rb +1 -0
- data/test/client_test.rb +17 -1
- metadata +5 -4
data/README.markdown
CHANGED
@@ -25,9 +25,10 @@ Here's an example of initializing with a few configuration options.
|
|
25
25
|
username,
|
26
26
|
shared_secret,
|
27
27
|
:san_jose,
|
28
|
-
:
|
29
|
-
:
|
30
|
-
|
28
|
+
:verify_mode => nil # Optionaly change the ssl verify mode.
|
29
|
+
:log => false, # Optionally turn off logging if it ticks you off
|
30
|
+
:wait_time => 1 # Amount of seconds to wait in between pinging
|
31
|
+
# Omniture's servers to see if a report is done processing (BEWARE OF TOKENS!)
|
31
32
|
)
|
32
33
|
|
33
34
|
## usage
|
data/Rakefile
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
+
require "rubygems"
|
1
2
|
require "bundler/gem_tasks"
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
system "ruby #{test_path}"
|
8
|
-
end
|
4
|
+
desc "Run all tests in /test"
|
5
|
+
task :test do
|
6
|
+
Dir["test/**/*_test.rb"].each do |test_path|
|
7
|
+
system "ruby #{test_path}"
|
9
8
|
end
|
10
9
|
end
|
data/lib/romniture/client.rb
CHANGED
@@ -2,7 +2,7 @@ module ROmniture
|
|
2
2
|
|
3
3
|
class Client
|
4
4
|
|
5
|
-
DEFAULT_REPORT_WAIT_TIME =
|
5
|
+
DEFAULT_REPORT_WAIT_TIME = 0.25
|
6
6
|
|
7
7
|
ENVIRONMENTS = {
|
8
8
|
:san_jose => "https://api.omniture.com/admin/1.2/rest/",
|
@@ -20,6 +20,7 @@ module ROmniture
|
|
20
20
|
|
21
21
|
@wait_time = options[:wait_time] ? options[:wait_time] : DEFAULT_REPORT_WAIT_TIME
|
22
22
|
@log = options[:log] ? options[:log] : false
|
23
|
+
@verify_mode = options[:verify_mode] ? options[:verify_mode] : false
|
23
24
|
HTTPI.log = false
|
24
25
|
end
|
25
26
|
|
@@ -70,6 +71,11 @@ module ROmniture
|
|
70
71
|
log(Logger::INFO, "Created new nonce: #{@password}")
|
71
72
|
|
72
73
|
request = HTTPI::Request.new
|
74
|
+
|
75
|
+
if @verify_mode
|
76
|
+
request.auth.ssl.verify_mode = @verify_mode
|
77
|
+
end
|
78
|
+
|
73
79
|
request.url = @environment + "?method=#{method}"
|
74
80
|
request.headers = request_headers
|
75
81
|
request.body = data.to_json
|
@@ -124,8 +130,9 @@ module ROmniture
|
|
124
130
|
end while !done && !error
|
125
131
|
|
126
132
|
if error
|
127
|
-
|
128
|
-
|
133
|
+
msg = "Unable to get data for report #{report_id}. Status: #{status}. Error Code: #{json["error_code"]}. #{json["error_msg"]}."
|
134
|
+
log(:error, msg)
|
135
|
+
raise ROmniture::Exceptions::OmnitureReportException.new(json), msg
|
129
136
|
end
|
130
137
|
|
131
138
|
response = send_request("Report.GetReport", {"reportID" => "#{report_id}"})
|
@@ -136,5 +143,4 @@ module ROmniture
|
|
136
143
|
JSON.parse(response.body)
|
137
144
|
end
|
138
145
|
end
|
139
|
-
|
140
146
|
end
|
data/lib/romniture/version.rb
CHANGED
data/lib/romniture.rb
CHANGED
data/test/client_test.rb
CHANGED
@@ -14,6 +14,7 @@ class ClientTest < Test::Unit::TestCase
|
|
14
14
|
@config["username"],
|
15
15
|
@config["shared_secret"],
|
16
16
|
@config["environment"],
|
17
|
+
:verify_mode => @config['verify_mode'],
|
17
18
|
:wait_time => @config["wait_time"]
|
18
19
|
)
|
19
20
|
end
|
@@ -39,4 +40,19 @@ class ClientTest < Test::Unit::TestCase
|
|
39
40
|
assert(response["report"].has_key?("data"), "Returned hash has no data!")
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
+
def test_a_bad_request
|
44
|
+
# Bad request, mixing commerce and traffic variables
|
45
|
+
assert_raise(ROmniture::Exceptions::OmnitureReportException) do
|
46
|
+
response = @client.get_report("Report.QueueTrended", {
|
47
|
+
"reportDescription" => {
|
48
|
+
"reportSuiteID" => @config["report_suite_id"],
|
49
|
+
"dateFrom" => "2011-01-01",
|
50
|
+
"dateTo" => "2011-01-11",
|
51
|
+
"metrics" => [{"id" => "pageviews"}, {"id" => "event11"}],
|
52
|
+
"elements" => [{"id" => "siteSection"}]
|
53
|
+
}
|
54
|
+
})
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: romniture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Sukmanowsky
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-30 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- Rakefile
|
64
64
|
- lib/romniture.rb
|
65
65
|
- lib/romniture/client.rb
|
66
|
+
- lib/romniture/exceptions.rb
|
66
67
|
- lib/romniture/version.rb
|
67
68
|
- test/client_test.rb
|
68
69
|
has_rdoc: true
|