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 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.
@@ -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 = options[:username]
18
- @shared_secret = options[:shared_secret]
19
- @base_uri = options[:environment].is_a?(Symbol) ? ENVIRONMENTS[options[:environment]] : options[:environment].to_s
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 = @base_uri + "?method=#{method}"
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 DEFAULT_REPORT_WAIT_TIME if !done && !error
123
+ sleep @wait_time if !done && !error
121
124
  end while !done && !error
122
125
 
123
126
  if error
@@ -1,3 +1,3 @@
1
1
  module ROmniture
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
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
- :username => "#{@config["username"]}",
15
- :shared_secret => "#{@config["shared_secret"]}",
16
- :environment => "#{@config["environment"]}"
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: 29
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
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-12 00:00:00 Z
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.8.4
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.
data/README DELETED
@@ -1,9 +0,0 @@
1
- TODO: Write an actual read me file...for now check out the stuff in test
2
-
3
- To run unit tests properly, add a config.yml in /test with this structure:
4
-
5
- omniture:
6
- username:
7
- shared_secret:
8
- report_suite_id:
9
- environment: