zanox 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/License.txt +20 -0
- data/README.txt +82 -0
- data/lib/zanox.rb +34 -0
- data/lib/zanox/zanox_base.rb +48 -0
- data/lib/zanox/zanox_json.rb +19 -0
- data/lib/zanox/zanox_soap.rb +581 -0
- data/lib/zanox/zanox_xml.rb +552 -0
- metadata +60 -0
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Chi-Dong Ly
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.txt
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
= Zanox.rb
|
2
|
+
|
3
|
+
* Rubyforge profile: http://zanox.rubyforge.org
|
4
|
+
* Source code repository:
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
Ruby wrapper around Zanox.com[http://www.zanox.com] API.
|
9
|
+
|
10
|
+
== FEATURES:
|
11
|
+
|
12
|
+
Currently implemented API methods:
|
13
|
+
|
14
|
+
* get_adspaces
|
15
|
+
* get_adspace
|
16
|
+
* delete_adspace
|
17
|
+
* get_program
|
18
|
+
* get_programs
|
19
|
+
* search_programs
|
20
|
+
* get_program_news
|
21
|
+
* get_program_categories
|
22
|
+
* get_programs_by_adspace
|
23
|
+
* delete_program_application
|
24
|
+
* get_product
|
25
|
+
* get_products_by_program
|
26
|
+
* search_products
|
27
|
+
* get_admedium
|
28
|
+
* get_admedia_by_program
|
29
|
+
* get_admedia_categories_by_program
|
30
|
+
* get_sales
|
31
|
+
* get_leads
|
32
|
+
* get_payments
|
33
|
+
* get_payment
|
34
|
+
* get_balances
|
35
|
+
* get_balance
|
36
|
+
* get_accounts
|
37
|
+
* get_account
|
38
|
+
* get_profile
|
39
|
+
|
40
|
+
|
41
|
+
== NOT YET IMPLEMENTED:
|
42
|
+
|
43
|
+
* create and update methods
|
44
|
+
|
45
|
+
== REQUIREMENTS:
|
46
|
+
|
47
|
+
* active_support[http://rubyforge.org/projects/activesupport/]
|
48
|
+
* rest-client[http://rubyforge.org/projects/rest-client/]
|
49
|
+
* mime-types[http://rubyforge.org/projects/mime-types/]
|
50
|
+
|
51
|
+
== INSTALL:
|
52
|
+
|
53
|
+
* sudo gem install zanox
|
54
|
+
|
55
|
+
== CONTACT:
|
56
|
+
|
57
|
+
* chi-dong.ly@palabea.com
|
58
|
+
|
59
|
+
== LICENSE:
|
60
|
+
|
61
|
+
(The MIT License)
|
62
|
+
|
63
|
+
Copyright (c) 2009 Chi-Dong Ly
|
64
|
+
|
65
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
66
|
+
a copy of this software and associated documentation files (the
|
67
|
+
'Software'), to deal in the Software without restriction, including
|
68
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
69
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
70
|
+
permit persons to whom the Software is furnished to do so, subject to
|
71
|
+
the following conditions:
|
72
|
+
|
73
|
+
The above copyright notice and this permission notice shall be
|
74
|
+
included in all copies or substantial portions of the Software.
|
75
|
+
|
76
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
77
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
78
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
79
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
80
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
81
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
82
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/zanox.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'active_support'
|
6
|
+
|
7
|
+
require 'zanox/zanox_base'
|
8
|
+
require 'zanox/zanox_xml'
|
9
|
+
require 'zanox/zanox_json'
|
10
|
+
require 'zanox/zanox_soap'
|
11
|
+
|
12
|
+
# Module to encapsule the Zanox API.
|
13
|
+
module Zanox
|
14
|
+
|
15
|
+
class Factory
|
16
|
+
|
17
|
+
def Factory.get_interface(interface, version = false)
|
18
|
+
case interface
|
19
|
+
when 'xml'
|
20
|
+
obj = ZanoxXml.new(version)
|
21
|
+
when 'json'
|
22
|
+
obj = ZanoxJson.new(version)
|
23
|
+
when 'soap'
|
24
|
+
obj = ZanoxSoap.new
|
25
|
+
else
|
26
|
+
raise 'No such Interface!'
|
27
|
+
end
|
28
|
+
|
29
|
+
return obj
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'hmac-sha1'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
module Zanox
|
5
|
+
|
6
|
+
class ZanoxBase
|
7
|
+
|
8
|
+
attr_accessor :timestamp
|
9
|
+
attr_reader :application_id, :last_error_msg
|
10
|
+
attr_writer :version
|
11
|
+
|
12
|
+
def initialize(version = false)
|
13
|
+
@version = version
|
14
|
+
@application_id = ''
|
15
|
+
@shared_key = ''
|
16
|
+
@timestamp = false
|
17
|
+
@version = false
|
18
|
+
@api_security = false
|
19
|
+
@last_error_msg = false
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_message_credentials(application_id, shared_key)
|
23
|
+
@application_id = application_id
|
24
|
+
@shared_key = shared_key
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def get_hmac_signature(mesgparams)
|
30
|
+
hmac = Base64.encode64(HMAC::SHA1.digest(@shared_key, mesgparams)).chomp
|
31
|
+
hmac
|
32
|
+
end
|
33
|
+
|
34
|
+
def enable_api_security
|
35
|
+
@api_security = true
|
36
|
+
end
|
37
|
+
|
38
|
+
def disable_api_security
|
39
|
+
@api_security = false
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_timestamp
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Zanox
|
2
|
+
|
3
|
+
class ZanoxJson < ZanoxXml
|
4
|
+
|
5
|
+
def initialize(version = false)
|
6
|
+
@version = version
|
7
|
+
@rest_action = 'GET'
|
8
|
+
@url = 'http://api.zanox.com/json'
|
9
|
+
@content_type = 'application/json'
|
10
|
+
@raw_data_disabled = true
|
11
|
+
end
|
12
|
+
|
13
|
+
# def serialize#TODO
|
14
|
+
#
|
15
|
+
# end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,581 @@
|
|
1
|
+
require 'soap/wsdlDriver'
|
2
|
+
|
3
|
+
module Zanox
|
4
|
+
|
5
|
+
class ZanoxSoap < ZanoxBase
|
6
|
+
|
7
|
+
attr_accessor :service, :wsdl, :soap
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@service = 'publisherservice'
|
11
|
+
@wsdl = 'http://api.zanox.com/wsdl'
|
12
|
+
@soap = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_adspaces
|
16
|
+
method = 'GetAdspaces'
|
17
|
+
|
18
|
+
enable_api_security
|
19
|
+
|
20
|
+
if result = send_request(method)
|
21
|
+
return result
|
22
|
+
end
|
23
|
+
|
24
|
+
return false
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_adspace(adspace_id)
|
28
|
+
method = 'GetAdspace'
|
29
|
+
|
30
|
+
params = {'adspaceId' => adspace_id.to_s }
|
31
|
+
|
32
|
+
enable_api_security
|
33
|
+
|
34
|
+
if result = send_request(method, params)
|
35
|
+
return result
|
36
|
+
end
|
37
|
+
|
38
|
+
return false
|
39
|
+
end
|
40
|
+
|
41
|
+
# def create_adspace(adspace_item, lang = 'en')#FIXME
|
42
|
+
# method = 'CreateAdspace'
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# def update_adspace(adspace_id, adspace_item)#FIXME
|
46
|
+
# method = 'UpdateAdspace'
|
47
|
+
# end
|
48
|
+
|
49
|
+
def delete_adspace(adspace_id)
|
50
|
+
method = 'DeleteAdspace'
|
51
|
+
|
52
|
+
params = { 'adspaceId' => adspace_id.to_s }
|
53
|
+
|
54
|
+
enable_api_security
|
55
|
+
|
56
|
+
if send_request(method, params)
|
57
|
+
return true
|
58
|
+
end
|
59
|
+
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_program(program_id)
|
64
|
+
method = 'GetProgram'
|
65
|
+
|
66
|
+
params = { 'programId' => program_id.to_s }
|
67
|
+
|
68
|
+
disable_api_security
|
69
|
+
|
70
|
+
if result = send_request(method, params)
|
71
|
+
return result
|
72
|
+
end
|
73
|
+
|
74
|
+
return false
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_programs(category_id = false, page = 0, items = 10)
|
78
|
+
method = 'GetPrograms'
|
79
|
+
|
80
|
+
params = {
|
81
|
+
'page' => page,
|
82
|
+
'items' => items,
|
83
|
+
'adspaceId' => 0,
|
84
|
+
'categoryId' => 0
|
85
|
+
}
|
86
|
+
|
87
|
+
if ( category_id )
|
88
|
+
params['categoryId'] = category_id.to_s
|
89
|
+
end
|
90
|
+
|
91
|
+
disable_api_security
|
92
|
+
|
93
|
+
if result = send_request(method, params)
|
94
|
+
return result
|
95
|
+
end
|
96
|
+
|
97
|
+
return false
|
98
|
+
end
|
99
|
+
|
100
|
+
def search_programs(q, page = 0, items = 10)
|
101
|
+
method = 'SearchPrograms'
|
102
|
+
|
103
|
+
params = {
|
104
|
+
'query' => q,
|
105
|
+
'page' => page,
|
106
|
+
'items' => items,
|
107
|
+
'categoryId' => 0
|
108
|
+
}
|
109
|
+
|
110
|
+
disable_api_security
|
111
|
+
|
112
|
+
if result = send_request(method, params)
|
113
|
+
return result
|
114
|
+
end
|
115
|
+
|
116
|
+
return false
|
117
|
+
end
|
118
|
+
|
119
|
+
def get_program_news
|
120
|
+
method = 'GetProgramPromotions'
|
121
|
+
|
122
|
+
disable_api_security
|
123
|
+
|
124
|
+
if result = send_request(method)
|
125
|
+
return result
|
126
|
+
end
|
127
|
+
|
128
|
+
return false
|
129
|
+
end
|
130
|
+
|
131
|
+
def get_program_categories
|
132
|
+
method = 'GetProgramCategories'
|
133
|
+
|
134
|
+
disable_api_security
|
135
|
+
|
136
|
+
if result = send_request(method)
|
137
|
+
return result
|
138
|
+
end
|
139
|
+
|
140
|
+
return false
|
141
|
+
end
|
142
|
+
|
143
|
+
def get_programs_by_adspace(adspace_id, page = 0, items = 10)
|
144
|
+
method = 'GetPrograms'
|
145
|
+
|
146
|
+
params = {
|
147
|
+
'page' => page,
|
148
|
+
'items' => items,
|
149
|
+
'adspaceId' => adspace_id.to_s,
|
150
|
+
'categoryId' => 0
|
151
|
+
}
|
152
|
+
|
153
|
+
enable_api_security
|
154
|
+
|
155
|
+
if result = send_request(method, params)
|
156
|
+
return result
|
157
|
+
end
|
158
|
+
|
159
|
+
return false
|
160
|
+
end
|
161
|
+
|
162
|
+
# def create_program_application(program_id, adspace_id)#FIXME
|
163
|
+
# method = 'CreateProgramApplication'
|
164
|
+
# end
|
165
|
+
|
166
|
+
def delete_program_application(program_id, adspace_id)#TODO test
|
167
|
+
method = 'DeleteProgramApplication'
|
168
|
+
|
169
|
+
params = {
|
170
|
+
'programId' => program_id.to_s,
|
171
|
+
'adspaceId' => adspace_id.to_s
|
172
|
+
}
|
173
|
+
|
174
|
+
enable_api_security
|
175
|
+
|
176
|
+
if send_request(method, params)
|
177
|
+
return true
|
178
|
+
end
|
179
|
+
|
180
|
+
return false
|
181
|
+
end
|
182
|
+
|
183
|
+
def get_product(zup_id)
|
184
|
+
method = 'GetProduct'
|
185
|
+
|
186
|
+
params = {'zupId' => zup_id.to_s }
|
187
|
+
|
188
|
+
disable_api_security
|
189
|
+
|
190
|
+
if result = send_request(method, params)
|
191
|
+
return result
|
192
|
+
end
|
193
|
+
|
194
|
+
return false
|
195
|
+
end
|
196
|
+
|
197
|
+
def get_products_by_program(program_id, filter = {}, page = 0, items = 10)
|
198
|
+
method = 'GetProducts'
|
199
|
+
|
200
|
+
params = {
|
201
|
+
'programId' => program_id.to_s,
|
202
|
+
'page' => page,
|
203
|
+
'items' => items,
|
204
|
+
'adspaceId' => 0
|
205
|
+
}
|
206
|
+
|
207
|
+
if ( !filter['adspace'].blank? )
|
208
|
+
params['adspaceId'] = filter['adspace']
|
209
|
+
end
|
210
|
+
|
211
|
+
if ( !filter['modified'].blank? )
|
212
|
+
params['modifiedDate'] = filter['modified']
|
213
|
+
end
|
214
|
+
|
215
|
+
disable_api_security
|
216
|
+
|
217
|
+
if result = send_request(method, params)
|
218
|
+
return result
|
219
|
+
end
|
220
|
+
|
221
|
+
return false
|
222
|
+
end
|
223
|
+
|
224
|
+
def search_products(q, filter = {}, page = 0, items = 10)
|
225
|
+
method = 'SearchProducts'
|
226
|
+
|
227
|
+
params = {
|
228
|
+
'query' => q,
|
229
|
+
'page' => page,
|
230
|
+
'items' => items,
|
231
|
+
'adspaceId' => 0
|
232
|
+
}
|
233
|
+
|
234
|
+
if ( !filter['adspace'].blank? )
|
235
|
+
params['adspaceId'] = filter['adspace']
|
236
|
+
end
|
237
|
+
|
238
|
+
if ( !filter['region'].blank? && filter['region'].size == 2)
|
239
|
+
params['region'] = filter['region']
|
240
|
+
end
|
241
|
+
|
242
|
+
if ( !filter['minprice'].blank? )
|
243
|
+
params['minPrice'] = filter['minprice']
|
244
|
+
end
|
245
|
+
|
246
|
+
if ( !filter['maxprice'].blank? )
|
247
|
+
params['maxPrice'] = filter['maxprice']
|
248
|
+
end
|
249
|
+
|
250
|
+
if ( !filter['ip'].blank? )
|
251
|
+
params['ipAddress'] = filter['ip']
|
252
|
+
end
|
253
|
+
|
254
|
+
disable_api_security
|
255
|
+
|
256
|
+
if result = send_request(method, params)
|
257
|
+
return result
|
258
|
+
end
|
259
|
+
|
260
|
+
return false
|
261
|
+
end
|
262
|
+
|
263
|
+
def get_admedium(admedium_id)
|
264
|
+
method = 'GetAdmedium'
|
265
|
+
|
266
|
+
params = {
|
267
|
+
'admediaId' => admedium_id.to_s,
|
268
|
+
'adspaceId' => 0
|
269
|
+
}
|
270
|
+
|
271
|
+
disable_api_security
|
272
|
+
|
273
|
+
if result = send_request(method, params)
|
274
|
+
return result
|
275
|
+
end
|
276
|
+
|
277
|
+
return false
|
278
|
+
end
|
279
|
+
|
280
|
+
def get_admedia_by_program(program_id, filter = {}, page = 0, items = 10)
|
281
|
+
method = 'GetAdmedia'
|
282
|
+
|
283
|
+
params = {
|
284
|
+
'programId' => program_id.to_s,
|
285
|
+
'page' => page,
|
286
|
+
'items' => items,
|
287
|
+
'categoryId' => 0,
|
288
|
+
'type' => 0,
|
289
|
+
'format' => 0,
|
290
|
+
'adspaceId' => 0
|
291
|
+
}
|
292
|
+
|
293
|
+
if ( !filter['adspace'].blank? )
|
294
|
+
params['adspaceId'] = filter['adspace']
|
295
|
+
end
|
296
|
+
|
297
|
+
if ( !filter['category'].blank? )
|
298
|
+
params['goryId'] = filter['category']
|
299
|
+
end
|
300
|
+
|
301
|
+
if ( !filter['type'].blank? )
|
302
|
+
params['type'] = filter['type']
|
303
|
+
end
|
304
|
+
|
305
|
+
disable_api_security
|
306
|
+
|
307
|
+
if result = send_request(method, params)
|
308
|
+
return result
|
309
|
+
end
|
310
|
+
|
311
|
+
return false
|
312
|
+
end
|
313
|
+
|
314
|
+
def get_admedia_categories_by_program(program_id)
|
315
|
+
method = 'GetAdmediumCategories'
|
316
|
+
|
317
|
+
params = { 'programId' => program_id.to_s }
|
318
|
+
|
319
|
+
disable_api_security
|
320
|
+
|
321
|
+
if result = send_request(method, params)
|
322
|
+
return result
|
323
|
+
end
|
324
|
+
|
325
|
+
return false
|
326
|
+
end
|
327
|
+
|
328
|
+
def get_sales(filter = {}, page = 0, items = 10)
|
329
|
+
method = 'GetSales'
|
330
|
+
|
331
|
+
params = {
|
332
|
+
'page' => page,
|
333
|
+
'items' => items
|
334
|
+
}
|
335
|
+
|
336
|
+
if ( !filter['date'].blank? )
|
337
|
+
params['date'] = filter['date']
|
338
|
+
end
|
339
|
+
|
340
|
+
if ( !filter['modifieddate'].blank? )
|
341
|
+
params['modifieddate'] = filter['modifieddate']
|
342
|
+
end
|
343
|
+
|
344
|
+
if ( !filter['clickdate'].blank? )
|
345
|
+
params['clickdate'] = filter['clickdate']
|
346
|
+
end
|
347
|
+
|
348
|
+
enable_api_security
|
349
|
+
|
350
|
+
if result = send_request(method, params)
|
351
|
+
return result
|
352
|
+
end
|
353
|
+
|
354
|
+
return false
|
355
|
+
end
|
356
|
+
|
357
|
+
def get_leads(filter = {}, page = 0, items = 10)
|
358
|
+
method = 'GetLeads'
|
359
|
+
|
360
|
+
params = {
|
361
|
+
'page' => page,
|
362
|
+
'items' => items
|
363
|
+
}
|
364
|
+
|
365
|
+
if ( !filter['date'].blank? )
|
366
|
+
params['date'] = filter['date']
|
367
|
+
end
|
368
|
+
|
369
|
+
if ( !filter['modifieddate'].blank? )
|
370
|
+
params['modifieddate'] = filter['modifieddate']
|
371
|
+
end
|
372
|
+
|
373
|
+
if ( !filter['clickdate'].blank? )
|
374
|
+
params['clickdate'] = filter['clickdate']
|
375
|
+
end
|
376
|
+
|
377
|
+
enable_api_security
|
378
|
+
|
379
|
+
if result = send_request(method, params)
|
380
|
+
return result
|
381
|
+
end
|
382
|
+
|
383
|
+
return false
|
384
|
+
end
|
385
|
+
|
386
|
+
def get_payments(page = 0, items = 10)
|
387
|
+
method = 'GetPayments'
|
388
|
+
|
389
|
+
params = {
|
390
|
+
'page' => page,
|
391
|
+
'items' => items
|
392
|
+
}
|
393
|
+
|
394
|
+
enable_api_security
|
395
|
+
|
396
|
+
if result = send_request(method, params)
|
397
|
+
return result
|
398
|
+
end
|
399
|
+
|
400
|
+
return false
|
401
|
+
end
|
402
|
+
|
403
|
+
def get_payment(payment_id)
|
404
|
+
method = 'GetPayments'
|
405
|
+
|
406
|
+
params = { 'paymentId' => payment_id.to_s }
|
407
|
+
|
408
|
+
#just has to be set to false to work around the bug
|
409
|
+
# 3 lines can be removed after fixing
|
410
|
+
params['page'] = page
|
411
|
+
params['items'] = items
|
412
|
+
|
413
|
+
enable_api_security
|
414
|
+
|
415
|
+
if result = send_request(method, params)
|
416
|
+
return result
|
417
|
+
end
|
418
|
+
|
419
|
+
return false
|
420
|
+
end
|
421
|
+
|
422
|
+
def get_balances
|
423
|
+
method = 'GetBalances'
|
424
|
+
|
425
|
+
enable_api_security
|
426
|
+
|
427
|
+
if result = send_request(method)
|
428
|
+
return result
|
429
|
+
end
|
430
|
+
|
431
|
+
return false
|
432
|
+
end
|
433
|
+
|
434
|
+
def get_balance(currency_code)
|
435
|
+
method = 'GetBalances'
|
436
|
+
|
437
|
+
params = { 'currency' => currency_code }
|
438
|
+
|
439
|
+
enable_api_security
|
440
|
+
|
441
|
+
if result = send_request(method, params)
|
442
|
+
return result
|
443
|
+
end
|
444
|
+
|
445
|
+
return false
|
446
|
+
end
|
447
|
+
|
448
|
+
def get_accounts
|
449
|
+
method = 'GetAccounts'
|
450
|
+
|
451
|
+
enable_api_security
|
452
|
+
|
453
|
+
if result = send_request(method)
|
454
|
+
return result
|
455
|
+
end
|
456
|
+
|
457
|
+
return false
|
458
|
+
end
|
459
|
+
|
460
|
+
def get_account(account_id)
|
461
|
+
method = 'GetAccounts'
|
462
|
+
|
463
|
+
params = { 'accountId' => account_id }
|
464
|
+
|
465
|
+
enable_api_security
|
466
|
+
|
467
|
+
if result = send_request(method, params)
|
468
|
+
return result
|
469
|
+
end
|
470
|
+
|
471
|
+
return false
|
472
|
+
end
|
473
|
+
|
474
|
+
def get_profile
|
475
|
+
method = 'GetProfile'
|
476
|
+
|
477
|
+
enable_api_security
|
478
|
+
|
479
|
+
if result = send_request(method)
|
480
|
+
return result
|
481
|
+
end
|
482
|
+
|
483
|
+
return false
|
484
|
+
end
|
485
|
+
|
486
|
+
# def update_profile(profile_item)#FIXME
|
487
|
+
# method = 'UpdateProfile'
|
488
|
+
# end
|
489
|
+
|
490
|
+
def get_timestamp
|
491
|
+
timestamp = Time.now.gmtime
|
492
|
+
timestamp = timestamp.strftime("%Y-%m-%dT%H:%M:%S.000Z")
|
493
|
+
timestamp.to_s
|
494
|
+
end
|
495
|
+
|
496
|
+
def send_request(method, params = {})
|
497
|
+
params['applicationId'] = @application_id
|
498
|
+
|
499
|
+
if @api_security
|
500
|
+
params['timestamp'] = get_timestamp
|
501
|
+
params['signature'] = build_signature(method)
|
502
|
+
end
|
503
|
+
|
504
|
+
begin
|
505
|
+
proxy = SOAP::WSDLDriverFactory.new(@wsdl).create_rpc_driver
|
506
|
+
case method
|
507
|
+
when 'GetAdspaces'
|
508
|
+
res = proxy.GetAdspaces(params)
|
509
|
+
when 'GetAdspace'
|
510
|
+
res = proxy.GetAdspace(params)
|
511
|
+
when 'CreateAdspace'
|
512
|
+
res = proxy.CreateAdspace(params)
|
513
|
+
when 'UpdateAdspace'
|
514
|
+
res = proxy.UpdateAdspace(params)
|
515
|
+
when 'DeleteAdspace'
|
516
|
+
res = proxy.DeleteAdspace(params)
|
517
|
+
when 'GetProgram'
|
518
|
+
res = proxy.GetProgram(params)
|
519
|
+
when 'GetPrograms'
|
520
|
+
res = proxy.GetPrograms(params)
|
521
|
+
when 'SearchPrograms'
|
522
|
+
res = proxy.SearchPrograms(params)
|
523
|
+
when 'GetProgramPromotions'
|
524
|
+
res = proxy.GetProgramPromotions(params)
|
525
|
+
when 'GetProgramCategories'
|
526
|
+
res = proxy.GetProgramCategories(params)
|
527
|
+
when 'CreateProgramApplication'
|
528
|
+
res = proxy.CreateProgramApplication(params)
|
529
|
+
when 'DeleteProgramApplication'
|
530
|
+
res = proxy.DeleteProgramApplication(params)
|
531
|
+
when 'GetProduct'
|
532
|
+
res = proxy.GetProduct(params)
|
533
|
+
when 'GetProducts'
|
534
|
+
res = proxy.GetProducts(params)
|
535
|
+
when 'SearchProducts'
|
536
|
+
res = proxy.SearchProducts(params)
|
537
|
+
when 'GetAdmedium'
|
538
|
+
res = proxy.GetAdmedium(params)
|
539
|
+
when 'GetAdmedia'
|
540
|
+
res = proxy.GetAdmedia(params)
|
541
|
+
when 'GetAdmediumCategories'
|
542
|
+
res = proxy.GetAdmediumCategories(params)
|
543
|
+
when 'GetSales'
|
544
|
+
res = proxy.GetSales(params)
|
545
|
+
when 'GetLeads'
|
546
|
+
res = proxy.GetLeads(params)
|
547
|
+
when 'GetPayments'
|
548
|
+
res = proxy.GetPayments(params)
|
549
|
+
when 'GetBalances'
|
550
|
+
res = proxy.GetBalances(params)
|
551
|
+
when 'GetAccounts'
|
552
|
+
res = proxy.GetAccounts(params)
|
553
|
+
when 'GetProfile'
|
554
|
+
res = proxy.GetProfile(params)
|
555
|
+
when 'UpdateProfile'
|
556
|
+
res = proxy.UpdateProfile(params)
|
557
|
+
end
|
558
|
+
|
559
|
+
return res
|
560
|
+
rescue Exception => e
|
561
|
+
@last_error_msg = e.to_s
|
562
|
+
end
|
563
|
+
|
564
|
+
return false
|
565
|
+
end
|
566
|
+
|
567
|
+
private
|
568
|
+
|
569
|
+
def build_signature(method)
|
570
|
+
sign = @service + method.downcase + get_timestamp
|
571
|
+
|
572
|
+
if hmac = get_hmac_signature(sign)
|
573
|
+
return hmac
|
574
|
+
end
|
575
|
+
|
576
|
+
return false
|
577
|
+
end
|
578
|
+
|
579
|
+
end
|
580
|
+
|
581
|
+
end
|
@@ -0,0 +1,552 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "uri"
|
3
|
+
|
4
|
+
module Zanox
|
5
|
+
|
6
|
+
class ZanoxXml < ZanoxBase
|
7
|
+
|
8
|
+
def initialize(version = false)
|
9
|
+
@version = version
|
10
|
+
@rest_action = 'GET'
|
11
|
+
@url = 'http://api.zanox.com/xml'
|
12
|
+
@content_type = 'application/xml'
|
13
|
+
@raw_data_disabled = true
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_adspaces
|
17
|
+
resource = ['adspaces']
|
18
|
+
|
19
|
+
@rest_action = 'GET'
|
20
|
+
enable_api_security
|
21
|
+
|
22
|
+
if result = send_request(resource)
|
23
|
+
return result
|
24
|
+
end
|
25
|
+
|
26
|
+
return false
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_adspace(adspace_id)
|
30
|
+
resource = ['adspaces', 'adspace', adspace_id.to_s]
|
31
|
+
|
32
|
+
@rest_action = 'GET'
|
33
|
+
enable_api_security
|
34
|
+
|
35
|
+
if result = send_request(resource)
|
36
|
+
return result
|
37
|
+
end
|
38
|
+
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
|
42
|
+
# def create_adspace(adspace_item, lang = 'en')#TODO test
|
43
|
+
# resource = ['adspaces', 'adspace']
|
44
|
+
#
|
45
|
+
# @rest_action = 'POST'
|
46
|
+
# enable_api_security
|
47
|
+
#
|
48
|
+
# body = serialize('adspaceItem', adspace_item, lang);
|
49
|
+
#
|
50
|
+
# if send_request(resource, false, body)
|
51
|
+
# return true
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# return false
|
55
|
+
# end
|
56
|
+
|
57
|
+
# def update_adspace(adspace_id, adspace_item)#TODO test
|
58
|
+
# resource = ['adspaces', 'adspace', adspace_id.to_s]
|
59
|
+
#
|
60
|
+
# @rest_action = 'PUT'
|
61
|
+
# enable_api_security
|
62
|
+
#
|
63
|
+
# body = serialize('adspaceItem', adspace_item);
|
64
|
+
#
|
65
|
+
# if send_request(resource, false, body)
|
66
|
+
# return true
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# return false
|
70
|
+
# end
|
71
|
+
|
72
|
+
def delete_adspace(adspace_id)
|
73
|
+
resource = ['adspaces', 'adspace', adspace_id.to_s]
|
74
|
+
|
75
|
+
@rest_action = "DELETE"
|
76
|
+
enable_api_security
|
77
|
+
|
78
|
+
if send_request(resource)
|
79
|
+
return true
|
80
|
+
end
|
81
|
+
|
82
|
+
return false
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_program(program_id)
|
86
|
+
resource = ['programs', 'program', program_id.to_s]
|
87
|
+
|
88
|
+
@rest_action = "GET"
|
89
|
+
disable_api_security
|
90
|
+
|
91
|
+
if result = send_request(resource)
|
92
|
+
return result
|
93
|
+
end
|
94
|
+
|
95
|
+
return false
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_programs(category_id = false, page = 0, items = 10)
|
99
|
+
if category_id
|
100
|
+
resource = ['programs', 'category', category_id.to_s]
|
101
|
+
else
|
102
|
+
resource = ['programs']
|
103
|
+
end
|
104
|
+
|
105
|
+
query = {'page' => page, 'items' => items}
|
106
|
+
|
107
|
+
@rest_action = "GET"
|
108
|
+
disable_api_security
|
109
|
+
|
110
|
+
if result = send_request(resource, query)
|
111
|
+
return result
|
112
|
+
end
|
113
|
+
|
114
|
+
return false
|
115
|
+
end
|
116
|
+
|
117
|
+
def search_programs(q, page = 0, items = 10)
|
118
|
+
resource = ['programs']
|
119
|
+
query = {'q' => q, 'page' => page, 'items' => items}
|
120
|
+
|
121
|
+
@rest_action = 'GET'
|
122
|
+
disable_api_security
|
123
|
+
|
124
|
+
result = send_request(resource, query)
|
125
|
+
|
126
|
+
return result
|
127
|
+
end
|
128
|
+
|
129
|
+
def get_program_news
|
130
|
+
resource = ['programs', 'news']
|
131
|
+
|
132
|
+
@rest_action = 'GET'
|
133
|
+
disable_api_security
|
134
|
+
|
135
|
+
result = send_request(resource)
|
136
|
+
|
137
|
+
return result
|
138
|
+
end
|
139
|
+
|
140
|
+
def get_program_categories
|
141
|
+
resource = ['programs', 'categories']
|
142
|
+
|
143
|
+
@rest_action = 'GET'
|
144
|
+
disable_api_security
|
145
|
+
|
146
|
+
result = send_request(resource)
|
147
|
+
|
148
|
+
return result
|
149
|
+
end
|
150
|
+
|
151
|
+
def get_programs_by_adspace(adspace_id, page = 0, items = 10)
|
152
|
+
resource = ['programs', 'adspace', adspace_id.to_s]
|
153
|
+
query = {'page' => page, 'items' => items}
|
154
|
+
|
155
|
+
@rest_action = 'GET'
|
156
|
+
enable_api_security
|
157
|
+
|
158
|
+
result = send_request(resource, query)
|
159
|
+
|
160
|
+
return result
|
161
|
+
end
|
162
|
+
|
163
|
+
# def create_program_application(program_id, adspace_id)#TODO test
|
164
|
+
# resource = ['programs', 'program', program_id.to_s, 'adspace', adspace_id.to_s]
|
165
|
+
#
|
166
|
+
# @rest_action = 'POST'
|
167
|
+
# enable_api_security
|
168
|
+
#
|
169
|
+
# if send_request(resource, false, 'hallo')
|
170
|
+
# return true
|
171
|
+
# end
|
172
|
+
#
|
173
|
+
# return false
|
174
|
+
# end
|
175
|
+
|
176
|
+
def delete_program_application(program_id, adspace_id)#TODO test
|
177
|
+
resource = ['programs', 'program', program_id.to_s, 'adspace', adspace_id.to_s]
|
178
|
+
|
179
|
+
@rest_action = 'DELETE'
|
180
|
+
enable_api_security
|
181
|
+
|
182
|
+
if send_request(resource)
|
183
|
+
return true
|
184
|
+
end
|
185
|
+
|
186
|
+
return false
|
187
|
+
end
|
188
|
+
|
189
|
+
def get_product(zup_id)
|
190
|
+
resource = ['products', 'product', zup_id.to_s]
|
191
|
+
|
192
|
+
@rest_action = 'GET'
|
193
|
+
disable_api_security
|
194
|
+
|
195
|
+
if result = send_request(resource)
|
196
|
+
return result
|
197
|
+
end
|
198
|
+
|
199
|
+
return false
|
200
|
+
end
|
201
|
+
|
202
|
+
def get_products_by_program(program_id, filter = {}, page = 0, items = 10)
|
203
|
+
if !filter['adspace'].blank?
|
204
|
+
resource = ['products', 'program', program_id.to_s, 'adspace', filter['adspace']]
|
205
|
+
else
|
206
|
+
resource = ['products', 'program', program_id.to_s]
|
207
|
+
end
|
208
|
+
|
209
|
+
query = {'page' => page, 'items' => items}
|
210
|
+
|
211
|
+
if !filter['modified'].blank?
|
212
|
+
query['modified'] = filter['modified']
|
213
|
+
end
|
214
|
+
|
215
|
+
@rest_action = 'GET'
|
216
|
+
disable_api_security
|
217
|
+
|
218
|
+
if result = send_request(resource, query)
|
219
|
+
return result
|
220
|
+
end
|
221
|
+
|
222
|
+
return false
|
223
|
+
end
|
224
|
+
|
225
|
+
def search_products(q, filter = {}, page = 0, items = 10)
|
226
|
+
if !filter['adspace'].blank?
|
227
|
+
resource = ['products', 'adspace', filter['adspace']]
|
228
|
+
else
|
229
|
+
resource = ['products']
|
230
|
+
end
|
231
|
+
|
232
|
+
query = {'q' => q, 'page' => page, 'items' => items}
|
233
|
+
|
234
|
+
if !filter['region'].blank? && filter['region'].length == 2
|
235
|
+
query['region'] = filter['region']
|
236
|
+
end
|
237
|
+
|
238
|
+
if !filter['minprice'].blank?
|
239
|
+
query['minprice'] = filter['minprice']
|
240
|
+
end
|
241
|
+
|
242
|
+
if !filter['maxprice'].blank?
|
243
|
+
query['maxprice'] = filter['maxprice']
|
244
|
+
end
|
245
|
+
|
246
|
+
if !filter['ip'].blank?
|
247
|
+
query['ip'] = filter['ip']
|
248
|
+
end
|
249
|
+
|
250
|
+
@rest_action = 'GET'
|
251
|
+
disable_api_security
|
252
|
+
|
253
|
+
if result = send_request(resource, query)
|
254
|
+
return result
|
255
|
+
end
|
256
|
+
|
257
|
+
return false
|
258
|
+
end
|
259
|
+
|
260
|
+
def get_admedium(admedium_id)
|
261
|
+
resource = ['admedia', 'admedium', admedium_id.to_s]
|
262
|
+
|
263
|
+
@rest_action = 'GET'
|
264
|
+
disable_api_security
|
265
|
+
|
266
|
+
if result = send_request(resource)
|
267
|
+
return result
|
268
|
+
end
|
269
|
+
|
270
|
+
return false
|
271
|
+
end
|
272
|
+
|
273
|
+
def get_admedia_by_program(program_id, filter = {}, page = 0, items = 10)
|
274
|
+
if !filter['category'].blank?
|
275
|
+
resource = ['admedia', 'program', program_id.to_s, 'category', filter['category']]
|
276
|
+
elsif !filter['type'].blank?
|
277
|
+
resource = ['admedia', 'program', program_id.to_s, 'type', filter['type']]
|
278
|
+
else
|
279
|
+
resource = ['admedia', 'program', program_id.to_s]
|
280
|
+
end
|
281
|
+
|
282
|
+
query = {'page' => page, 'items' => items}
|
283
|
+
|
284
|
+
@rest_action = 'GET'
|
285
|
+
disable_api_security
|
286
|
+
|
287
|
+
if result = send_request(resource, query)
|
288
|
+
return result
|
289
|
+
end
|
290
|
+
|
291
|
+
return false
|
292
|
+
end
|
293
|
+
|
294
|
+
def get_admedia_categories_by_program(program_id)
|
295
|
+
resource = ['admedia', 'program', program_id.to_s, 'categories']
|
296
|
+
|
297
|
+
@rest_action = 'GET'
|
298
|
+
disable_api_security
|
299
|
+
|
300
|
+
if result = send_request(resource)
|
301
|
+
return result
|
302
|
+
end
|
303
|
+
|
304
|
+
return false
|
305
|
+
end
|
306
|
+
|
307
|
+
def get_sales(filter = {}, page = 0, items = 10)
|
308
|
+
resource = ['reports', 'sales']
|
309
|
+
|
310
|
+
query = {'page' => page, 'items' => items}
|
311
|
+
|
312
|
+
if !filter['date'].blank?
|
313
|
+
query['date'] = filter['date']
|
314
|
+
end
|
315
|
+
|
316
|
+
if !filter['modifieddate'].blank?
|
317
|
+
query['modifieddate'] = filter['modifieddate']
|
318
|
+
end
|
319
|
+
|
320
|
+
if !filter['clickdate'].blank?
|
321
|
+
query['clickdate'] = filter['clickdate']
|
322
|
+
end
|
323
|
+
|
324
|
+
@rest_action = 'GET'
|
325
|
+
enable_api_security
|
326
|
+
|
327
|
+
if result = send_request(resource, query)
|
328
|
+
return result
|
329
|
+
end
|
330
|
+
|
331
|
+
return false
|
332
|
+
end
|
333
|
+
|
334
|
+
def get_leads(filter = {}, page = 0, items = 10)
|
335
|
+
resource = ['reports', 'leads']
|
336
|
+
|
337
|
+
query = {'page' => page, 'items' => items}
|
338
|
+
|
339
|
+
if !filter['date'].blank?
|
340
|
+
query['date'] = filter['date'];
|
341
|
+
end
|
342
|
+
|
343
|
+
if !filter['modifieddate'].blank?
|
344
|
+
query['modifieddate'] = filter['modifieddate']
|
345
|
+
end
|
346
|
+
|
347
|
+
if !filter['clickdate'].blank?
|
348
|
+
query['clickdate'] = filter['clickdate']
|
349
|
+
end
|
350
|
+
|
351
|
+
@rest_action = 'GET'
|
352
|
+
enable_api_security
|
353
|
+
|
354
|
+
if result = send_request(resource, query)
|
355
|
+
return result
|
356
|
+
end
|
357
|
+
|
358
|
+
return false
|
359
|
+
end
|
360
|
+
|
361
|
+
def get_payments(page = 0, items = 10)
|
362
|
+
resource = ['payments']
|
363
|
+
|
364
|
+
query = {'page' => page, 'items' => items}
|
365
|
+
|
366
|
+
@rest_action = 'GET'
|
367
|
+
enable_api_security
|
368
|
+
|
369
|
+
if result = send_request(resource, query)
|
370
|
+
return result
|
371
|
+
end
|
372
|
+
|
373
|
+
return false
|
374
|
+
end
|
375
|
+
|
376
|
+
def get_payment(payment_id)
|
377
|
+
resource = ['payments', 'payment', payment_id]
|
378
|
+
|
379
|
+
@rest_action = 'GET'
|
380
|
+
enable_api_security
|
381
|
+
|
382
|
+
if result = send_request(resource)
|
383
|
+
return result
|
384
|
+
end
|
385
|
+
|
386
|
+
return false
|
387
|
+
end
|
388
|
+
|
389
|
+
def get_balances
|
390
|
+
resource = ['payments', 'balances']
|
391
|
+
|
392
|
+
@rest_action = 'GET'
|
393
|
+
enable_api_security
|
394
|
+
|
395
|
+
if result = send_request(resource)
|
396
|
+
return result
|
397
|
+
end
|
398
|
+
|
399
|
+
return false
|
400
|
+
end
|
401
|
+
|
402
|
+
def get_balance(currency_code)
|
403
|
+
resource = ['payments', 'balances', 'balance', currency_code]
|
404
|
+
|
405
|
+
@rest_action = 'GET'
|
406
|
+
enable_api_security
|
407
|
+
|
408
|
+
if result = send_request(resource)
|
409
|
+
return result
|
410
|
+
end
|
411
|
+
|
412
|
+
return false
|
413
|
+
end
|
414
|
+
|
415
|
+
def get_accounts
|
416
|
+
resource = ['payments', 'accounts']
|
417
|
+
|
418
|
+
@rest_action = 'GET'
|
419
|
+
enable_api_security
|
420
|
+
|
421
|
+
if result = send_request(resource)
|
422
|
+
return result
|
423
|
+
end
|
424
|
+
|
425
|
+
return false
|
426
|
+
end
|
427
|
+
|
428
|
+
def get_account(account_id)
|
429
|
+
resource = ['payments', 'accounts', 'account', account_id.to_s]
|
430
|
+
|
431
|
+
@rest_action = 'GET'
|
432
|
+
enable_api_security
|
433
|
+
|
434
|
+
if result = send_request(resource)
|
435
|
+
return result
|
436
|
+
end
|
437
|
+
|
438
|
+
return false
|
439
|
+
end
|
440
|
+
|
441
|
+
def get_profile
|
442
|
+
resource = ['profiles']
|
443
|
+
|
444
|
+
@rest_action = 'GET'
|
445
|
+
enable_api_security
|
446
|
+
|
447
|
+
result = send_request(resource, false)
|
448
|
+
|
449
|
+
return result
|
450
|
+
end
|
451
|
+
|
452
|
+
# def update_profile(profile_item)#TODO test
|
453
|
+
# resource = ['profiles']
|
454
|
+
#
|
455
|
+
# @rest_action = 'PUT'
|
456
|
+
# enable_api_security
|
457
|
+
#
|
458
|
+
# body = serialize('profileItem', profile_item)
|
459
|
+
#
|
460
|
+
# if send_request(resource, false, profile_item)
|
461
|
+
# return true
|
462
|
+
# end
|
463
|
+
#
|
464
|
+
# return false
|
465
|
+
# end
|
466
|
+
|
467
|
+
def get_timestamp
|
468
|
+
timestamp = Time.now.gmtime
|
469
|
+
timestamp = timestamp.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
470
|
+
timestamp.to_s
|
471
|
+
end
|
472
|
+
|
473
|
+
def enable_raw_data
|
474
|
+
@raw_data_disabled = true
|
475
|
+
end
|
476
|
+
|
477
|
+
def disable_raw_data
|
478
|
+
@raw_data_disabled = false
|
479
|
+
end
|
480
|
+
|
481
|
+
private
|
482
|
+
|
483
|
+
def send_request(resource, query = {}, body = false)
|
484
|
+
version = false
|
485
|
+
uri_path = "/" + resource.join("/")
|
486
|
+
timestamp = get_timestamp
|
487
|
+
|
488
|
+
if @api_security
|
489
|
+
shash = build_signature(uri_path, timestamp)
|
490
|
+
authorization = "ZXWS " + @application_id + ":" + shash
|
491
|
+
else
|
492
|
+
authorization = "ZXWS " + @application_id
|
493
|
+
end
|
494
|
+
|
495
|
+
if @version
|
496
|
+
version = "/" + @version
|
497
|
+
else
|
498
|
+
version = ""
|
499
|
+
end
|
500
|
+
|
501
|
+
request_url = @url + version + uri_path
|
502
|
+
|
503
|
+
url = URI.parse(request_url)
|
504
|
+
path = url.path
|
505
|
+
path = path + '?' + query.to_query if query.is_a?(Hash) && !query.empty?
|
506
|
+
|
507
|
+
case @rest_action
|
508
|
+
when 'GET'
|
509
|
+
req = Net::HTTP::Get.new(path)
|
510
|
+
when 'PUT'
|
511
|
+
req = Net::HTTP::Put.new(path)
|
512
|
+
when 'POST'
|
513
|
+
req = Net::HTTP::Post.new(path)
|
514
|
+
when 'DELETE'
|
515
|
+
req = Net::HTTP::Delete.new(path)
|
516
|
+
end
|
517
|
+
|
518
|
+
req.add_field("authorization", authorization)
|
519
|
+
req.add_field("date", timestamp)
|
520
|
+
req.add_field("user-agent", "zanox PHP API Client")
|
521
|
+
req.add_field("content-type" , @content_type)
|
522
|
+
req.add_field("host" , "api.zanox.com")
|
523
|
+
|
524
|
+
res = Net::HTTP.new(url.host, url.port).start do |http|
|
525
|
+
http.request(req)
|
526
|
+
end
|
527
|
+
|
528
|
+
if res.code == '200'
|
529
|
+
return res.body
|
530
|
+
end
|
531
|
+
|
532
|
+
@last_error_msg = res.message
|
533
|
+
|
534
|
+
return false
|
535
|
+
end
|
536
|
+
|
537
|
+
def build_signature(uri, timestamp)
|
538
|
+
sign = @rest_action + uri + timestamp
|
539
|
+
if ( hmac = get_hmac_signature(sign) )
|
540
|
+
return hmac
|
541
|
+
end
|
542
|
+
|
543
|
+
return false
|
544
|
+
end
|
545
|
+
|
546
|
+
# def serialize#TODO implement
|
547
|
+
#
|
548
|
+
# end
|
549
|
+
|
550
|
+
end
|
551
|
+
|
552
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: zanox
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.0
|
7
|
+
date: 2009-07-13 00:00:00 +02:00
|
8
|
+
summary: Ruby wrapper around Zanox API.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email:
|
12
|
+
homepage: http://wiki.zanox.com/
|
13
|
+
rubyforge_project:
|
14
|
+
description: Ruby Client Library.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Chi-Dong Ly
|
31
|
+
files:
|
32
|
+
- README.txt
|
33
|
+
- License.txt
|
34
|
+
- lib/zanox.rb
|
35
|
+
- lib/zanox/zanox_base.rb
|
36
|
+
- lib/zanox/zanox_xml.rb
|
37
|
+
- lib/zanox/zanox_json.rb
|
38
|
+
- lib/zanox/zanox_soap.rb
|
39
|
+
test_files: []
|
40
|
+
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
executables: []
|
46
|
+
|
47
|
+
extensions: []
|
48
|
+
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
dependencies:
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: ruby-hmac
|
54
|
+
version_requirement:
|
55
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.3.2
|
60
|
+
version:
|