zanox 0.2.0 → 0.2.1

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.
Files changed (4) hide show
  1. data/README.textile +32 -2
  2. data/lib/zanox.rb +13 -9
  3. data/zanox.gemspec +1 -1
  4. metadata +2 -2
data/README.textile CHANGED
@@ -1,6 +1,36 @@
1
- h2. the zanox gem
1
+ h1. zanox
2
2
 
3
- The ruby way to use the zanox API.
3
+ by Krispin Schulz
4
+
5
+ The zanox gem is the ruby way to use the zanox API.
6
+ It is a coherent wrapper for the zanox Publisher web services and you can use resources like
7
+ models in ActiveRecord.
8
+
9
+ h2. Getting started
10
+
11
+ * Install the gem
12
+ * Learn its usage with the examples below
13
+ * Create shiny ruby apps with it
14
+
15
+ h2. Examples
16
+
17
+ <pre><code>
18
+ require 'rubygems'
19
+ require 'zanox'
20
+
21
+ # first authenticate with your zanox connect id
22
+ Zanox::API.authenticate('26EE1314AEA84BB7C9FC')
23
+
24
+ # request products as easy as hell
25
+ Zanox::Product.find('ipod').each do |product|
26
+ puts product.id + " : " + product.name
27
+ end
28
+
29
+ # request products by its zupid
30
+ Zanox::Product.find('afdd090e0ee25e796e5146f6fcd7b15e').each do |product|
31
+ puts product.id + " : " + product.name
32
+ end
33
+ </code></pre>
4
34
 
5
35
 
6
36
 
data/lib/zanox.rb CHANGED
@@ -66,11 +66,13 @@ module Zanox
66
66
  items = []
67
67
  class_name = self.name.split('::').last
68
68
  api_method = 'get'+self.pluralize
69
- timestamp = Zanox::API.get_timestamp
70
- nonce = Zanox::API.generate_nonce
69
+ unless Zanox::API.secret_key.nil?
70
+ timestamp = Zanox::API.get_timestamp
71
+ nonce = Zanox::API.generate_nonce
71
72
 
72
- signature = Zanox::API.create_signature(Zanox::API.secret_key, "publisherservice"+api_method.downcase + timestamp + nonce)
73
- options.merge!(:timestamp=>timestamp, :nonce=>nonce, :signature=>signature)
73
+ signature = Zanox::API.create_signature(Zanox::API.secret_key, "publisherservice"+api_method.downcase + timestamp + nonce)
74
+ options.merge!(:timestamp=>timestamp, :nonce=>nonce, :signature=>signature)
75
+ end
74
76
 
75
77
  response = Zanox::API.request(api_method, options)
76
78
 
@@ -106,14 +108,16 @@ module Zanox
106
108
 
107
109
  class_name = self.name.split('::').last
108
110
  api_method = ''
109
- timestamp = Zanox::API.get_timestamp
110
- nonce = Zanox::API.generate_nonce
111
111
 
112
112
  if(ids.size>0)
113
113
  api_method = 'get'+class_name.capitalize
114
- signature = Zanox::API.create_signature(Zanox::API.secret_key, "publisherservice"+api_method.downcase + timestamp + nonce)
115
- options.merge!(:timestamp=>timestamp, :nonce=>nonce, :signature=>signature)
116
-
114
+ unless Zanox::API.secret_key.nil?
115
+ timestamp = Zanox::API.get_timestamp
116
+ nonce = Zanox::API.generate_nonce
117
+ signature = Zanox::API.create_signature(Zanox::API.secret_key, "publisherservice"+api_method.downcase + timestamp + nonce)
118
+ options.merge!(:timestamp=>timestamp, :nonce=>nonce, :signature=>signature)
119
+ end
120
+
117
121
  ids.each do |id|
118
122
  options.merge!(self.key_symbol=>id)
119
123
  response = Zanox::API.request(api_method, options)
data/zanox.gemspec CHANGED
@@ -7,7 +7,7 @@ require 'rake'
7
7
  spec = Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.name = %q{zanox}
10
- s.version = "0.2.0"
10
+ s.version = "0.2.1"
11
11
  s.authors = ["Krispin Schulz"]
12
12
  s.homepage = %q{http://kr1sp1n.com/}
13
13
  s.date = %q{2010-05-07}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Krispin Schulz