romniture 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +58 -0
- data/lib/romniture/client.rb +9 -6
- data/lib/romniture/version.rb +1 -1
- data/test/client_test.rb +6 -5
- metadata +8 -6
- data/README +0 -9
data/README.markdown
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# romniture
|
2
|
+
To be pronounced...RAWWWRROMNITURE
|
3
|
+
|
4
|
+
## what is it
|
5
|
+
romniture is a minimal Ruby wrapper to [Omniture's REST API](http://developer.omniture.com). It follows a design policy similar to that of [sucker](https://rubygems.org/gems/sucker) built for Amazon's API.
|
6
|
+
|
7
|
+
Omniture's API is closed, you have to be a paying customer in order to access the data.
|
8
|
+
|
9
|
+
## installation
|
10
|
+
[sudo] gem install romniture
|
11
|
+
|
12
|
+
## initialization and authentication
|
13
|
+
romniture requires you supply the `username`, `shared_secret` and `environment` which you can access within the Company > Web Services section of the Admin Console. The environment you'll use to connect to Omniture's API depends on which data center they're using to store your traffic data and will be one of:
|
14
|
+
|
15
|
+
* San Jose (https://api.omniture.com/admin/1.2/rest/)
|
16
|
+
* Dallas (https://api2.omniture.com/admin/1.2/rest/)
|
17
|
+
* London (https://api3.omniture.com/admin/1.2/rest/)
|
18
|
+
* San Jose Beta (https://beta-api.omniture.com/admin/1.2/rest/)
|
19
|
+
* Dallas (beta) (https://beta-api2.omniture.com/admin/1.2/rest/)
|
20
|
+
* Sandbox (https://api-sbx1.omniture.com/admin/1.2/rest/)
|
21
|
+
|
22
|
+
Here's an example of initializing with a few configuration options.
|
23
|
+
|
24
|
+
client = ROmniture::Client.new(
|
25
|
+
username,
|
26
|
+
shared_secret,
|
27
|
+
:san_jose,
|
28
|
+
:log => false, # Optionally turn off logging if it ticks you off
|
29
|
+
:wait_time => 1 # Amount of seconds to wait in between pinging
|
30
|
+
# Omniture's servers to see if a report is done processing (BEWARE OF TOKENS!)
|
31
|
+
)
|
32
|
+
|
33
|
+
## usage
|
34
|
+
There are only two core methods for the client which doesn't try to "over architect a spaghetti API":
|
35
|
+
|
36
|
+
* `get_report` - used to...while get reports and
|
37
|
+
* `request` - more generic used to make any kind of request
|
38
|
+
|
39
|
+
For reference, I'd recommend keeping [Omniture's Developer Portal](http://developer.omniture.com) open as you code . It's not the easiest to navigate but most of what you need is there.
|
40
|
+
|
41
|
+
The response returned by either of these requests Ruby (parsed JSON).
|
42
|
+
|
43
|
+
## examples
|
44
|
+
# Find all the company report suites
|
45
|
+
client.request('Company.GetReportSuites')
|
46
|
+
|
47
|
+
# Get an overtime report
|
48
|
+
client.get_report "Report.QueueOvertime", {
|
49
|
+
"reportDescription" => {
|
50
|
+
"reportSuiteID" => "#{@config["report_suite_id"]}",
|
51
|
+
"dateFrom" => "2011-01-01",
|
52
|
+
"dateTo" => "2011-01-10",
|
53
|
+
"metrics" => [{"id" => "pageviews"}]
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
## see also
|
58
|
+
My other client library [comscore_ruby](https://github.com/msukmanowsky/comscore_ruby) for those of you looking to pull data from comscore as well.
|
data/lib/romniture/client.rb
CHANGED
@@ -13,10 +13,13 @@ module ROmniture
|
|
13
13
|
:sandbox => "https://api-sbx1.omniture.com/admin/1.2/rest/"
|
14
14
|
}
|
15
15
|
|
16
|
-
def initialize(options={})
|
17
|
-
@username =
|
18
|
-
@shared_secret =
|
19
|
-
@
|
16
|
+
def initialize(username, shared_secret, environment, options={})
|
17
|
+
@username = username
|
18
|
+
@shared_secret = shared_secret
|
19
|
+
@environment = environment.is_a?(Symbol) ? ENVIRONMENTS[environment] : environment.to_s
|
20
|
+
|
21
|
+
@wait_time = options[:wait_time] ? options[:wait_time] : DEFAULT_REPORT_WAIT_TIME
|
22
|
+
@log = options[:log] ? options[:log] : false
|
20
23
|
HTTPI.log = false
|
21
24
|
end
|
22
25
|
|
@@ -67,7 +70,7 @@ module ROmniture
|
|
67
70
|
log(Logger::INFO, "Created new nonce: #{@password}")
|
68
71
|
|
69
72
|
request = HTTPI::Request.new
|
70
|
-
request.url = @
|
73
|
+
request.url = @environment + "?method=#{method}"
|
71
74
|
request.headers = request_headers
|
72
75
|
request.body = data.to_json
|
73
76
|
|
@@ -117,7 +120,7 @@ module ROmniture
|
|
117
120
|
error = true
|
118
121
|
end
|
119
122
|
|
120
|
-
sleep
|
123
|
+
sleep @wait_time if !done && !error
|
121
124
|
end while !done && !error
|
122
125
|
|
123
126
|
if error
|
data/lib/romniture/version.rb
CHANGED
data/test/client_test.rb
CHANGED
@@ -10,11 +10,12 @@ class ClientTest < Test::Unit::TestCase
|
|
10
10
|
config = YAML::load(File.open("test/config.yml"))
|
11
11
|
@config = config["omniture"]
|
12
12
|
|
13
|
-
@client = ROmniture::Client.new(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
@client = ROmniture::Client.new(
|
14
|
+
@config["username"],
|
15
|
+
@config["shared_secret"],
|
16
|
+
@config["environment"],
|
17
|
+
:wait_time => @config["wait_time"]
|
18
|
+
)
|
18
19
|
end
|
19
20
|
|
20
21
|
def test_simple_request
|
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: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mike Sukmanowsky
|
@@ -15,7 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-18 00:00:00 -04:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: httpi
|
@@ -57,13 +58,14 @@ extra_rdoc_files: []
|
|
57
58
|
files:
|
58
59
|
- .gitignore
|
59
60
|
- Gemfile
|
60
|
-
- README
|
61
|
+
- README.markdown
|
61
62
|
- ROmniture.gemspec
|
62
63
|
- Rakefile
|
63
64
|
- lib/romniture.rb
|
64
65
|
- lib/romniture/client.rb
|
65
66
|
- lib/romniture/version.rb
|
66
67
|
- test/client_test.rb
|
68
|
+
has_rdoc: true
|
67
69
|
homepage: http://github.com/msukmanowsky/ROmniture
|
68
70
|
licenses: []
|
69
71
|
|
@@ -93,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
95
|
requirements: []
|
94
96
|
|
95
97
|
rubyforge_project: romniture
|
96
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.5.0
|
97
99
|
signing_key:
|
98
100
|
specification_version: 3
|
99
101
|
summary: Use Omniture's REST API with ease.
|