zanox 0.1.0 → 0.2.0
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.
- data/README.textile +6 -0
- data/Rakefile +72 -0
- data/lib/zanox.rb +261 -23
- data/spec/zanox_specs.rb +55 -0
- data/test/zanox_tests.rb +12 -0
- data/zanox.gemspec +35 -0
- metadata +83 -48
- data/License.txt +0 -20
- data/README.txt +0 -82
- data/lib/zanox/zanox_base.rb +0 -48
- data/lib/zanox/zanox_json.rb +0 -19
- data/lib/zanox/zanox_soap.rb +0 -581
- data/lib/zanox/zanox_xml.rb +0 -552
metadata
CHANGED
@@ -1,60 +1,95 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: zanox
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
-
|
11
|
-
|
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:
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
25
10
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
11
|
authors:
|
30
|
-
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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: []
|
12
|
+
- Krispin Schulz
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
50
16
|
|
17
|
+
date: 2010-05-07 00:00:00 +02:00
|
18
|
+
default_executable:
|
51
19
|
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: soap4r
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 5
|
30
|
+
- 8
|
31
|
+
version: 1.5.8
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
52
34
|
- !ruby/object:Gem::Dependency
|
53
35
|
name: ruby-hmac
|
54
|
-
|
55
|
-
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
56
38
|
requirements:
|
57
39
|
- - ">="
|
58
40
|
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 4
|
44
|
+
- 0
|
45
|
+
version: 0.4.0
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
description: The easy way to the zanox web services.
|
49
|
+
email: krispinone@googlemail.com
|
50
|
+
executables: []
|
51
|
+
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files:
|
55
|
+
- README.textile
|
56
|
+
files:
|
57
|
+
- Rakefile
|
58
|
+
- zanox.gemspec
|
59
|
+
- README.textile
|
60
|
+
- lib/zanox.rb
|
61
|
+
- test/zanox_tests.rb
|
62
|
+
- spec/zanox_specs.rb
|
63
|
+
has_rdoc: true
|
64
|
+
homepage: http://kr1sp1n.com/
|
65
|
+
licenses: []
|
66
|
+
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options:
|
69
|
+
- --main
|
70
|
+
- README.textile
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.3.6
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: One gem to rule the zanox web services.
|
94
|
+
test_files:
|
95
|
+
- test/zanox_tests.rb
|
data/License.txt
DELETED
@@ -1,20 +0,0 @@
|
|
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
DELETED
@@ -1,82 +0,0 @@
|
|
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/zanox_base.rb
DELETED
@@ -1,48 +0,0 @@
|
|
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
|
data/lib/zanox/zanox_json.rb
DELETED
@@ -1,19 +0,0 @@
|
|
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
|
data/lib/zanox/zanox_soap.rb
DELETED
@@ -1,581 +0,0 @@
|
|
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
|