zanox 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +17 -0
- data/lib/zanox.rb +46 -20
- data/spec/zanox_specs.rb +18 -0
- data/zanox.gemspec +4 -3
- metadata +14 -5
data/README.textile
CHANGED
@@ -12,6 +12,19 @@ h2. Getting started
|
|
12
12
|
* Learn its usage with the examples below
|
13
13
|
* Create shiny ruby apps with it
|
14
14
|
|
15
|
+
h2. Features
|
16
|
+
|
17
|
+
Supported zanox API methods:
|
18
|
+
|
19
|
+
|*zanox API method*|*the ruby way*|
|
20
|
+
| getProgram | Zanox::Program.find('the program id here') |
|
21
|
+
| getProgramsByAdspace | Zanox::Program.find(:adspaceId => 'your adspace id here') |
|
22
|
+
| searchPrograms | Zanox::Program.find('amazon', :region=>'de') |
|
23
|
+
| getProduct | Zanox::Product.find('the zupid of the product here') |
|
24
|
+
| getProducts | Zanox::Product.find(:programId=>'program id is required here', :adspaceId=>'your adspace id here') |
|
25
|
+
| searchProducts | Zanox::Product.find('ipad', :region=>'de', :programId=>'a program id here') |
|
26
|
+
| getSales | Zanox::Sale.find(:date=>'2010-03-02T00:00:00', :dateType=>'trackingDate') |
|
27
|
+
|
15
28
|
h2. Examples
|
16
29
|
|
17
30
|
<pre><code>
|
@@ -34,5 +47,9 @@ h2. Examples
|
|
34
47
|
|
35
48
|
For more code snippets look at the files in the examples dir.
|
36
49
|
|
50
|
+
h2. License
|
51
|
+
|
52
|
+
Published under a <a href="http://creativecommons.org/licenses/by-sa/3.0/" target="_blank">Creative Commons</a> license.
|
53
|
+
|
37
54
|
|
38
55
|
|
data/lib/zanox.rb
CHANGED
@@ -20,8 +20,8 @@ module Zanox
|
|
20
20
|
|
21
21
|
raise AuthError, "Missing connect id. Try calling Zanox::API.authenticate('your connect id', 'your secret key') before your requests", caller[caller.length - 1] if !!options[:connect_id]
|
22
22
|
|
23
|
-
wsdl = 'http://api.zanox.com/wsdl/2009-07-01/' unless
|
24
|
-
$driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver unless !!$driver
|
23
|
+
@wsdl = 'http://api.zanox.com/wsdl/2009-07-01/' unless !!@wsdl
|
24
|
+
$driver = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver unless !!$driver
|
25
25
|
$driver.wiredump_dev = STDOUT if $DEBUG
|
26
26
|
$driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE if $DEBUG
|
27
27
|
$driver.method(method.to_sym).call(options)
|
@@ -58,17 +58,17 @@ module Zanox
|
|
58
58
|
|
59
59
|
def new(item=nil)
|
60
60
|
item.extend(self)
|
61
|
-
item.id= item.xmlattr_id
|
61
|
+
item.id= item.xmlattr_id
|
62
62
|
return item
|
63
63
|
end
|
64
64
|
|
65
65
|
def find_every(options)
|
66
66
|
items = []
|
67
|
-
class_name = self.name.split('::').last
|
67
|
+
class_name = self.name.split('::').last
|
68
68
|
api_method = 'get'+self.pluralize
|
69
69
|
|
70
70
|
if(class_name=='Program' && options.has_key?(:adspaceId))
|
71
|
-
api_method = "
|
71
|
+
api_method = "getProgramApplications"
|
72
72
|
end
|
73
73
|
|
74
74
|
unless Zanox::API.secret_key.nil?
|
@@ -81,10 +81,12 @@ module Zanox
|
|
81
81
|
|
82
82
|
response = Zanox::API.request(api_method, options)
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
class_name.sub!(/\b\w/) { $&.downcase }
|
85
|
+
|
86
|
+
m1_name = (class_name+'Items').to_sym
|
87
|
+
m2_name = (class_name+'Item').to_sym
|
88
|
+
|
89
|
+
if(response.respond_to?(m1_name) && response.items!=0)
|
88
90
|
items_object = response.method(m1_name).call
|
89
91
|
if(items_object.respond_to?(m2_name))
|
90
92
|
item_object = items_object.method(m2_name).call
|
@@ -97,7 +99,13 @@ module Zanox
|
|
97
99
|
items.push self.new(item)
|
98
100
|
end
|
99
101
|
end
|
102
|
+
else
|
103
|
+
# found nothing handling
|
104
|
+
#return items
|
100
105
|
end
|
106
|
+
|
107
|
+
return items
|
108
|
+
|
101
109
|
end
|
102
110
|
|
103
111
|
def find_other(args, options)
|
@@ -115,7 +123,7 @@ module Zanox
|
|
115
123
|
api_method = ''
|
116
124
|
|
117
125
|
if(ids.size>0)
|
118
|
-
api_method = 'get'+class_name
|
126
|
+
api_method = 'get'+class_name
|
119
127
|
unless Zanox::API.secret_key.nil?
|
120
128
|
timestamp = Zanox::API.get_timestamp
|
121
129
|
nonce = Zanox::API.generate_nonce
|
@@ -126,19 +134,20 @@ module Zanox
|
|
126
134
|
ids.each do |id|
|
127
135
|
options.merge!(self.key_symbol=>id)
|
128
136
|
response = Zanox::API.request(api_method, options)
|
129
|
-
|
137
|
+
class_name.sub!(/\b\w/) { $&.downcase }
|
138
|
+
item = self.new(response.method((class_name+'Item').to_sym).call)
|
130
139
|
items.push item
|
131
140
|
end
|
132
141
|
end
|
133
142
|
|
134
143
|
if(queries.size>0)
|
135
144
|
api_method = 'search'+self.pluralize
|
136
|
-
|
145
|
+
class_name.sub!(/\b\w/) { $&.downcase }
|
137
146
|
queries.each do |query|
|
138
147
|
options.merge!(:query=>query)
|
139
148
|
response = Zanox::API.request(api_method, options)
|
140
|
-
m1_name = (class_name
|
141
|
-
m2_name = (class_name
|
149
|
+
m1_name = (class_name+'Items').to_sym
|
150
|
+
m2_name = (class_name+'Item').to_sym
|
142
151
|
|
143
152
|
if(response.respond_to?(m1_name))
|
144
153
|
items_object = response.method(m1_name).call
|
@@ -157,7 +166,7 @@ module Zanox
|
|
157
166
|
end
|
158
167
|
end
|
159
168
|
|
160
|
-
items
|
169
|
+
return items
|
161
170
|
end
|
162
171
|
|
163
172
|
def find(*args)
|
@@ -189,7 +198,7 @@ module Zanox
|
|
189
198
|
end
|
190
199
|
|
191
200
|
def self.is_key?(id)
|
192
|
-
id.to_s[
|
201
|
+
id.to_s[/^[0-9]{2,8}$/] ? true : false
|
193
202
|
end
|
194
203
|
end
|
195
204
|
|
@@ -206,7 +215,7 @@ module Zanox
|
|
206
215
|
end
|
207
216
|
|
208
217
|
def self.is_key?(id)
|
209
|
-
id.to_s[
|
218
|
+
id.to_s[/^[0-9]{2,10}$/] ? true : false
|
210
219
|
end
|
211
220
|
end
|
212
221
|
|
@@ -240,7 +249,7 @@ module Zanox
|
|
240
249
|
end
|
241
250
|
|
242
251
|
def self.is_key?(id)
|
243
|
-
id.to_s[
|
252
|
+
id.to_s[/^[0-9]{2,10}$/] ? true : false
|
244
253
|
end
|
245
254
|
end
|
246
255
|
|
@@ -257,7 +266,7 @@ module Zanox
|
|
257
266
|
end
|
258
267
|
|
259
268
|
def self.is_key?(id)
|
260
|
-
id.to_s[/[0-
|
269
|
+
id.to_s[/[0-9a-f]+[-]{1}[0-9a-f]+[-]{1}[0-9a-f]+[-]{1}[0-9a-f]+[-]{1}[0-9a-f]+/] ? true : false
|
261
270
|
end
|
262
271
|
end
|
263
272
|
|
@@ -274,7 +283,24 @@ module Zanox
|
|
274
283
|
end
|
275
284
|
|
276
285
|
def self.is_key?(id)
|
277
|
-
id.to_s[/[0-
|
286
|
+
id.to_s[/[0-9a-f]+[-]{1}[0-9a-f]+[-]{1}[0-9a-f]+[-]{1}[0-9a-f]+[-]{1}[0-9a-f]+/] ? true : false
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
module MediaSlot
|
291
|
+
include Item
|
292
|
+
extend Item
|
293
|
+
|
294
|
+
def self.key_symbol
|
295
|
+
:mediaSlotId
|
296
|
+
end
|
297
|
+
|
298
|
+
def self.pluralize
|
299
|
+
"MediaSlots"
|
300
|
+
end
|
301
|
+
|
302
|
+
def self.is_key?(id)
|
303
|
+
id.to_s[/[0-9A-Fa-f]{20}/] ? true : false
|
278
304
|
end
|
279
305
|
end
|
280
306
|
|
data/spec/zanox_specs.rb
CHANGED
@@ -32,6 +32,7 @@ describe Zanox::Program do
|
|
32
32
|
# Program.find
|
33
33
|
TEST_PROGRAM_QUERY = "Amazon"
|
34
34
|
TEST_PROGRAM_ID = "1648"
|
35
|
+
TEST_ADSPACE_ID = "1289612"
|
35
36
|
|
36
37
|
it "should find programs by a keyword" do
|
37
38
|
Zanox::Program.find(TEST_PROGRAM_QUERY).size.should >= 1
|
@@ -40,6 +41,11 @@ describe Zanox::Program do
|
|
40
41
|
it "should find a specific program by its id" do
|
41
42
|
Zanox::Program.find(TEST_PROGRAM_ID).size.should == 1
|
42
43
|
end
|
44
|
+
|
45
|
+
# TODO: fix it
|
46
|
+
# it "should find programs by an adspace" do
|
47
|
+
# Zanox::Program.find(:adspaceId=>TEST_ADSPACE_ID).size.should >= 1
|
48
|
+
# end
|
43
49
|
end
|
44
50
|
|
45
51
|
describe Zanox::Adspace do
|
@@ -52,4 +58,16 @@ describe Zanox::Adspace do
|
|
52
58
|
it "should find the users Adspace by an id" do
|
53
59
|
Zanox::Adspace.find(TEST_ADSPACE_ID).size.should == 1
|
54
60
|
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe Zanox::Sale do
|
64
|
+
# Sale.find
|
65
|
+
TEST_SALE_ID = "92ba89e7-b229-4933-857c-e307c0291856"
|
66
|
+
TEST_DATE = "2010-03-02T00:00:00"
|
67
|
+
it "should find all sales for a given date" do
|
68
|
+
Zanox::Sale.find(:date=>TEST_DATE, :dateType=>'trackingDate').size.should >=1
|
69
|
+
end
|
70
|
+
it "should find a sale by its id" do
|
71
|
+
Zanox::Sale.find(TEST_SALE_ID).size.should == 1
|
72
|
+
end
|
55
73
|
end
|
data/zanox.gemspec
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
# require 'rubygems/gem_runner'
|
3
3
|
# #Gem.manage_gems
|
4
4
|
# require 'rake/gempackagetask'
|
5
|
+
require 'rubygems'
|
5
6
|
require 'rake'
|
6
7
|
|
7
8
|
spec = Gem::Specification.new do |s|
|
8
9
|
s.platform = Gem::Platform::RUBY
|
9
10
|
s.name = %q{zanox}
|
10
|
-
s.version = "0.2.
|
11
|
+
s.version = "0.2.4"
|
11
12
|
s.authors = ["Krispin Schulz"]
|
12
|
-
s.homepage = %q{http://
|
13
|
-
s.date = %
|
13
|
+
s.homepage = %q{http://github.com/kr1sp1n/zanox}
|
14
|
+
s.date = Time.now.strftime("%Y-%m-%d")
|
14
15
|
s.email = %q{krispinone@googlemail.com}
|
15
16
|
s.summary = %q{One gem to rule the zanox web services.}
|
16
17
|
s.description = %q{The easy way to the zanox web services.}
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zanox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Krispin Schulz
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-12-10 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: soap4r
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 19
|
27
30
|
segments:
|
28
31
|
- 1
|
29
32
|
- 5
|
@@ -35,9 +38,11 @@ dependencies:
|
|
35
38
|
name: ruby-hmac
|
36
39
|
prerelease: false
|
37
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
38
42
|
requirements:
|
39
43
|
- - ">="
|
40
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 15
|
41
46
|
segments:
|
42
47
|
- 0
|
43
48
|
- 4
|
@@ -61,7 +66,7 @@ files:
|
|
61
66
|
- test/zanox_tests.rb
|
62
67
|
- spec/zanox_specs.rb
|
63
68
|
has_rdoc: true
|
64
|
-
homepage: http://
|
69
|
+
homepage: http://github.com/kr1sp1n/zanox
|
65
70
|
licenses: []
|
66
71
|
|
67
72
|
post_install_message:
|
@@ -71,23 +76,27 @@ rdoc_options:
|
|
71
76
|
require_paths:
|
72
77
|
- lib
|
73
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
74
80
|
requirements:
|
75
81
|
- - ">="
|
76
82
|
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
77
84
|
segments:
|
78
85
|
- 0
|
79
86
|
version: "0"
|
80
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
81
89
|
requirements:
|
82
90
|
- - ">="
|
83
91
|
- !ruby/object:Gem::Version
|
92
|
+
hash: 3
|
84
93
|
segments:
|
85
94
|
- 0
|
86
95
|
version: "0"
|
87
96
|
requirements: []
|
88
97
|
|
89
98
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.3.
|
99
|
+
rubygems_version: 1.3.7
|
91
100
|
signing_key:
|
92
101
|
specification_version: 3
|
93
102
|
summary: One gem to rule the zanox web services.
|