epom 0.3.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/epom/analytic.rb +27 -0
- data/lib/epom/campaign.rb +5 -1
- data/lib/epom/epom_element.rb +7 -1
- data/lib/epom/version.rb +1 -1
- data/test/epom/analytic_test.rb +26 -0
- data/test/epom/campaign_test.rb +366 -20
- data/test/test_helper.rb +1 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21b944bfdb65f1df249b459bd138aaa74065882c
|
4
|
+
data.tar.gz: 1140a8e3f043eb92f19878d98222345eb38398e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8de4951251283334aaaf9b9fc236915510699b6e46dc71cb8cfa59b34ef1479f394a6072d5130f227e72fc90527ceab6e1b9c54a46b8fbc81c58a62166cf9fc
|
7
|
+
data.tar.gz: 1553904d2cd5b10cfed9405400e2bdd90b6c2e3ce234997d5ba75bfbd7cccea5770d4247a9f965debf80274cab942faa96b62d573a1ae800bb4f720dc6984a28
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'epom/epom_element'
|
2
|
+
|
3
|
+
module Epom
|
4
|
+
class Analytic < EpomElement
|
5
|
+
|
6
|
+
def self.extended_methods
|
7
|
+
{
|
8
|
+
:analytics => {
|
9
|
+
:url => '/rest-api/analytics/FORMAT/LOGIN/HASH/TIMESTAMP.do',
|
10
|
+
:url_parameters => [:format, :login, :hash, :timestamp],
|
11
|
+
:body_parameters => [:customFrom, :customTo, :hourFrom, :hourTo, :groupRange, :displayIds, :statisticType, :range, :groupBy, :filterBy, :eqStr, :eqLong],
|
12
|
+
:method => :get,
|
13
|
+
:format => nil
|
14
|
+
}
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.replace_params_in_url(url, url_params)
|
19
|
+
url.gsub!('FORMAT', url_params[:format]) if url.include?('FORMAT')
|
20
|
+
url.gsub!('LOGIN', url_params[:login]) if url.include?('LOGIN')
|
21
|
+
url.gsub!('HASH', url_params[:hash]) if url.include?('HASH')
|
22
|
+
url.gsub!('TIMESTAMP', url_params[:timestamp].to_s) if url.include?('TIMESTAMP')
|
23
|
+
url
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/epom/campaign.rb
CHANGED
@@ -444,6 +444,10 @@ module Epom
|
|
444
444
|
:body_parameters => [:name, :clickToConversionTimeFrame, :clickToConversionTimeFramePeriodType, :viewToConversionTimeFrame, :viewToConversionTimeFramePeriodType, :hash, :timestamp, :username],
|
445
445
|
:method => :post
|
446
446
|
},
|
447
|
+
|
448
|
+
###########################
|
449
|
+
# Campaign Pricing API
|
450
|
+
###########################
|
447
451
|
:disable_campaign_country_pricing => {
|
448
452
|
:url => '/rest-api/campaigns/CAMPAIGN_ID/pricing/COUNTRY_CODE.do',
|
449
453
|
:url_parameters => [:campaignId, :countryCode],
|
@@ -489,7 +493,7 @@ module Epom
|
|
489
493
|
:update_campaign_pricing => {
|
490
494
|
:url => '/rest-api/campaign/CAMPAIGN_ID/pricing.do',
|
491
495
|
:url_parameters => [:campaignId],
|
492
|
-
:body_parameters => [:hash, :timestamp, :username],
|
496
|
+
:body_parameters => [:price, :hash, :timestamp, :username],
|
493
497
|
:method => :post
|
494
498
|
},
|
495
499
|
}
|
data/lib/epom/epom_element.rb
CHANGED
@@ -4,7 +4,6 @@ module Epom
|
|
4
4
|
include HTTMultiParty
|
5
5
|
base_uri 'https://n29.epom.com/'
|
6
6
|
default_params :output => 'json'
|
7
|
-
format :json
|
8
7
|
debug_output $stderr
|
9
8
|
|
10
9
|
def self.extended_methods
|
@@ -33,6 +32,13 @@ module Epom
|
|
33
32
|
default_options[:headers] = {}
|
34
33
|
end
|
35
34
|
|
35
|
+
if signature.has_key?(:format)
|
36
|
+
format signature[:format]
|
37
|
+
else
|
38
|
+
format :json
|
39
|
+
end
|
40
|
+
|
41
|
+
|
36
42
|
if params_validation(url_params, url_params_signature) and params_validation(body_params, body_params_signature)
|
37
43
|
http_proxy ENV['proxy_address'], ENV['proxy_port'], ENV['proxy_user'], ENV['proxy_password']
|
38
44
|
response = send(method, url, :query => body_params)
|
data/lib/epom/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'epom/analytic'
|
3
|
+
|
4
|
+
class AnalyticTest < ActiveSupport::TestCase
|
5
|
+
test "truth" do
|
6
|
+
assert_kind_of Class, Epom::Analytic
|
7
|
+
end
|
8
|
+
|
9
|
+
test "analytics" do
|
10
|
+
timestamp = Time.now.to_i * 1000
|
11
|
+
url_params = {
|
12
|
+
:format => 'CSV',
|
13
|
+
:login => ENV['username'],
|
14
|
+
:timestamp => timestamp,
|
15
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp)
|
16
|
+
}
|
17
|
+
body_params = {
|
18
|
+
:displayIds => true,
|
19
|
+
:range => 'CURRENT_MONTH',
|
20
|
+
:groupBy => 'ADVERTISER,CAMPAIGN,BANNER,SITE,ZONE,PLACEMENT',
|
21
|
+
}
|
22
|
+
|
23
|
+
response = Epom::Analytic.analytics(url_params, body_params)
|
24
|
+
assert_not_instance_of Fixnum, response
|
25
|
+
end
|
26
|
+
end
|
data/test/epom/campaign_test.rb
CHANGED
@@ -6,10 +6,51 @@ class CampaignTest < ActiveSupport::TestCase
|
|
6
6
|
assert_kind_of Class, Epom::Campaign
|
7
7
|
end
|
8
8
|
|
9
|
-
test "
|
9
|
+
test "create_campaign" do
|
10
|
+
timestamp = Time.now.to_i * 1000
|
11
|
+
body_params = {
|
12
|
+
:advertiserId => ENV['advertiser_id'],
|
13
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
14
|
+
:timestamp => timestamp,
|
15
|
+
:username => ENV['username'],
|
16
|
+
:name => "campaign #{timestamp}",
|
17
|
+
:description => "description for campaign #{timestamp}",
|
18
|
+
:active => true}
|
19
|
+
|
20
|
+
response = Epom::Campaign.create_campaign({}, body_params)
|
21
|
+
assert_instance_of Hash, response
|
22
|
+
assert_instance_of Fixnum, response['id']
|
23
|
+
assert_instance_of String, response['name']
|
24
|
+
end
|
25
|
+
|
26
|
+
test "update_campaign" do
|
10
27
|
timestamp = Time.now.to_i * 1000
|
11
28
|
url_params = {
|
12
|
-
:campaignId => ENV['campaign_id']
|
29
|
+
:campaignId => ENV['campaign_id']
|
30
|
+
}
|
31
|
+
body_params = {
|
32
|
+
:advertiserId => ENV['advertiser_id'],
|
33
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
34
|
+
:timestamp => timestamp,
|
35
|
+
:username => ENV['username'],
|
36
|
+
:name => "campaign #{timestamp}",
|
37
|
+
:description => "description for campaign #{timestamp}",
|
38
|
+
:active => true}
|
39
|
+
|
40
|
+
response = Epom::Campaign.update_campaign(url_params, body_params)
|
41
|
+
assert_instance_of Hash, response
|
42
|
+
assert response['success']
|
43
|
+
|
44
|
+
campaign = test_get_campaign()
|
45
|
+
assert_instance_of Hash, campaign
|
46
|
+
assert_equal ENV['campaign_id'], campaign['id'].to_s
|
47
|
+
assert_equal "campaign #{timestamp}", campaign['name']
|
48
|
+
end
|
49
|
+
|
50
|
+
test "get_click_capping" do
|
51
|
+
timestamp = Time.now.to_i * 1000
|
52
|
+
url_params = {
|
53
|
+
:campaignId => ENV['campaign_id']
|
13
54
|
}
|
14
55
|
body_params = {
|
15
56
|
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
@@ -17,12 +58,217 @@ class CampaignTest < ActiveSupport::TestCase
|
|
17
58
|
:username => ENV['username'],
|
18
59
|
}
|
19
60
|
|
20
|
-
response = Epom::Campaign.
|
61
|
+
response = Epom::Campaign.get_click_capping(url_params, body_params)
|
21
62
|
assert_instance_of Array, response
|
22
63
|
if response.count > 0
|
23
64
|
first = response[0]
|
24
|
-
assert_instance_of
|
25
|
-
|
65
|
+
assert_instance_of Hash, first
|
66
|
+
assert_instance_of Fixnum, first['id']
|
67
|
+
assert_instance_of Fixnum, first['amount']
|
68
|
+
assert_instance_of String, first['periodType']
|
69
|
+
assert_instance_of Fixnum, first['period']
|
70
|
+
end
|
71
|
+
response
|
72
|
+
end
|
73
|
+
|
74
|
+
test "set_click_capping" do
|
75
|
+
timestamp = Time.now.to_i * 1000
|
76
|
+
url_params = {
|
77
|
+
:campaignId => ENV['campaign_id']
|
78
|
+
}
|
79
|
+
body_params = {
|
80
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
81
|
+
:timestamp => timestamp,
|
82
|
+
:username => ENV['username'],
|
83
|
+
:amount => [1,2,3,4,5,6,7].sample,
|
84
|
+
:evenDistribution => true,
|
85
|
+
:periodType => 'HOUR',
|
86
|
+
:period => 2
|
87
|
+
}
|
88
|
+
|
89
|
+
response = Epom::Campaign.set_click_capping(url_params, body_params)
|
90
|
+
|
91
|
+
click_cappings = test_get_click_capping()
|
92
|
+
click_capping = click_cappings.find { |cc| cc['amount'] == body_params[:amount] }
|
93
|
+
assert_instance_of Hash, click_capping
|
94
|
+
assert_instance_of Fixnum, click_capping['id']
|
95
|
+
assert_equal true, click_capping['evenDistribution']
|
96
|
+
assert_equal 'HOUR', click_capping['periodType']
|
97
|
+
assert_equal 2, click_capping['period']
|
98
|
+
end
|
99
|
+
|
100
|
+
test "get_limits" do
|
101
|
+
timestamp = Time.now.to_i * 1000
|
102
|
+
url_params = {
|
103
|
+
:campaignId => ENV['campaign_id'],
|
104
|
+
}
|
105
|
+
body_params = {
|
106
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
107
|
+
:timestamp => timestamp,
|
108
|
+
:username => ENV['username'],
|
109
|
+
}
|
110
|
+
|
111
|
+
response = Epom::Campaign.get_limits(url_params, body_params)
|
112
|
+
assert_instance_of Hash, response
|
113
|
+
response
|
114
|
+
end
|
115
|
+
|
116
|
+
test "set_limits" do
|
117
|
+
timestamp = Time.now.to_i * 1000
|
118
|
+
url_params = {
|
119
|
+
:campaignId => ENV['campaign_id'],
|
120
|
+
}
|
121
|
+
body_params = {
|
122
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
123
|
+
:timestamp => timestamp,
|
124
|
+
:username => ENV['username'],
|
125
|
+
:totalImpressionsLimit => 100,
|
126
|
+
:dailyImpressionsLimit => 20,
|
127
|
+
:totalClicksLimit => 50,
|
128
|
+
:dailyClicksLimit => 10,
|
129
|
+
:totalBudgetLimit => 50,
|
130
|
+
:dailyBudgetLimit => 10,
|
131
|
+
:startDate => DateTime.now.strftime('%Y-%m-%d-%H-%M'),
|
132
|
+
:endDate => Date.tomorrow.strftime('%Y-%m-%d-%H-%M'),
|
133
|
+
}
|
134
|
+
|
135
|
+
response = Epom::Campaign.set_limits(url_params, body_params)
|
136
|
+
|
137
|
+
limit = test_get_limits()
|
138
|
+
assert_instance_of Hash, limit
|
139
|
+
assert_equal body_params[:totalImpressionsLimit], limit['totalImpressionsLimit']
|
140
|
+
assert_equal body_params[:dailyImpressionsLimit], limit['dailyImpressionsLimit']
|
141
|
+
assert_equal body_params[:totalClicksLimit], limit['totalClicksLimit']
|
142
|
+
assert_equal body_params[:dailyClicksLimit], limit['dailyClicksLimit']
|
143
|
+
assert_equal body_params[:totalBudgetLimit], limit['totalBudgetLimit']
|
144
|
+
assert_equal body_params[:dailyBudgetLimit], limit['dailyBudgetLimit']
|
145
|
+
assert_equal body_params[:startDate], limit['startDate']
|
146
|
+
assert_equal body_params[:endDate], limit['endDate']
|
147
|
+
end
|
148
|
+
|
149
|
+
test "create_cookie_value_target" do
|
150
|
+
timestamp = Time.now.to_i * 1000
|
151
|
+
url_params = {
|
152
|
+
:campaignId => ENV['campaign_id'],
|
153
|
+
}
|
154
|
+
body_params = {
|
155
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
156
|
+
:timestamp => timestamp,
|
157
|
+
:username => ENV['username'],
|
158
|
+
:cookieName => 'age',
|
159
|
+
:cookieValue => '20',
|
160
|
+
:rule => 'INCLUDE'
|
161
|
+
}
|
162
|
+
|
163
|
+
response = Epom::Campaign.create_cookie_value_target(url_params, body_params)
|
164
|
+
assert_instance_of Hash, response
|
165
|
+
assert_instance_of Fixnum, response['id']
|
166
|
+
assert_equal body_params[:cookieName], response['cookieName']
|
167
|
+
assert_equal body_params[:cookieValue], response['cookieValue']
|
168
|
+
end
|
169
|
+
|
170
|
+
test "create_country_target" do
|
171
|
+
timestamp = Time.now.to_i * 1000
|
172
|
+
url_params = {
|
173
|
+
:campaignId => ENV['campaign_id'],
|
174
|
+
}
|
175
|
+
body_params = {
|
176
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
177
|
+
:timestamp => timestamp,
|
178
|
+
:username => ENV['username'],
|
179
|
+
:countryCode => ENV['country_code'],
|
180
|
+
:rule => 'INCLUDE'
|
181
|
+
}
|
182
|
+
|
183
|
+
response = Epom::Campaign.create_country_target(url_params, body_params)
|
184
|
+
assert_instance_of Hash, response
|
185
|
+
assert_instance_of Fixnum, response['id']
|
186
|
+
assert_equal 'COUNTRY', response['type']
|
187
|
+
end
|
188
|
+
|
189
|
+
test "create_custom_parameter_target" do
|
190
|
+
timestamp = Time.now.to_i * 1000
|
191
|
+
url_params = {
|
192
|
+
:campaignId => ENV['campaign_id'],
|
193
|
+
}
|
194
|
+
body_params = {
|
195
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
196
|
+
:timestamp => timestamp,
|
197
|
+
:username => ENV['username'],
|
198
|
+
:expression => "($p1==1 || $p1=='a') && ($p2>=12 && $p2<=22)",
|
199
|
+
:rule => 'INCLUDE'
|
200
|
+
}
|
201
|
+
|
202
|
+
response = Epom::Campaign.create_custom_parameter_target(url_params, body_params)
|
203
|
+
assert_instance_of Hash, response
|
204
|
+
assert_instance_of Fixnum, response['id']
|
205
|
+
assert_equal 'CUSTOM', response['type']
|
206
|
+
end
|
207
|
+
|
208
|
+
test "create_language_target" do
|
209
|
+
timestamp = Time.now.to_i * 1000
|
210
|
+
url_params = {
|
211
|
+
:campaignId => ENV['campaign_id'],
|
212
|
+
}
|
213
|
+
body_params = {
|
214
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
215
|
+
:timestamp => timestamp,
|
216
|
+
:username => ENV['username'],
|
217
|
+
:languageCode => 'en',
|
218
|
+
:rule => 'INCLUDE'
|
219
|
+
}
|
220
|
+
|
221
|
+
response = Epom::Campaign.create_language_target(url_params, body_params)
|
222
|
+
assert_instance_of Hash, response
|
223
|
+
assert_instance_of Fixnum, response['id']
|
224
|
+
assert_equal 'LANGUAGE', response['type']
|
225
|
+
end
|
226
|
+
|
227
|
+
test "disable_targeting" do
|
228
|
+
timestamp = Time.now.to_i * 1000
|
229
|
+
url_params = {
|
230
|
+
:campaignId => ENV['campaign_id'],
|
231
|
+
}
|
232
|
+
body_params = {
|
233
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
234
|
+
:timestamp => timestamp,
|
235
|
+
:username => ENV['username'],
|
236
|
+
}
|
237
|
+
|
238
|
+
response = Epom::Campaign.disable_targeting(url_params, body_params)
|
239
|
+
assert_not_instance_of Fixnum, response
|
240
|
+
end
|
241
|
+
|
242
|
+
test "enable_targeting" do
|
243
|
+
timestamp = Time.now.to_i * 1000
|
244
|
+
url_params = {
|
245
|
+
:campaignId => ENV['campaign_id'],
|
246
|
+
}
|
247
|
+
body_params = {
|
248
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
249
|
+
:timestamp => timestamp,
|
250
|
+
:username => ENV['username'],
|
251
|
+
}
|
252
|
+
|
253
|
+
response = Epom::Campaign.enable_targeting(url_params, body_params)
|
254
|
+
assert_not_instance_of Fixnum, response
|
255
|
+
end
|
256
|
+
|
257
|
+
test "get_targeting" do
|
258
|
+
timestamp = Time.now.to_i * 1000
|
259
|
+
url_params = {
|
260
|
+
:campaignId => ENV['campaign_id'],
|
261
|
+
:targetId => '3929'
|
262
|
+
}
|
263
|
+
body_params = {
|
264
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
265
|
+
:timestamp => timestamp,
|
266
|
+
:username => ENV['username'],
|
267
|
+
}
|
268
|
+
|
269
|
+
response = Epom::Campaign.get_targeting(url_params, body_params)
|
270
|
+
assert_instance_of Hash, response
|
271
|
+
assert_instance_of Fixnum, response['id']
|
26
272
|
end
|
27
273
|
|
28
274
|
test "get_targetings" do
|
@@ -42,30 +288,92 @@ class CampaignTest < ActiveSupport::TestCase
|
|
42
288
|
first = response[0]
|
43
289
|
assert_instance_of Fixnum, first['id']
|
44
290
|
end
|
45
|
-
end
|
291
|
+
end
|
46
292
|
|
47
|
-
test "
|
48
|
-
|
293
|
+
test "get_campaign" do
|
294
|
+
timestamp = Time.now.to_i * 1000
|
295
|
+
url_params = {
|
296
|
+
:campaignId => ENV['campaign_id']
|
297
|
+
}
|
49
298
|
body_params = {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
:active => true}
|
57
|
-
|
58
|
-
response = Epom::Campaign.create_campaign({}, body_params)
|
299
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
300
|
+
:timestamp => timestamp,
|
301
|
+
:username => ENV['username'],
|
302
|
+
}
|
303
|
+
|
304
|
+
response = Epom::Campaign.get_campaign(url_params, body_params)
|
59
305
|
assert_instance_of Hash, response
|
60
306
|
assert_instance_of Fixnum, response['id']
|
61
307
|
assert_instance_of String, response['name']
|
308
|
+
response
|
309
|
+
end
|
310
|
+
|
311
|
+
##########################
|
312
|
+
## Campaign Adjusted CPM API
|
313
|
+
##########################
|
314
|
+
|
315
|
+
test "add_fixed_cpm_country_pricing" do
|
316
|
+
timestamp = Time.now.to_i * 1000
|
317
|
+
url_params = {
|
318
|
+
:campaignId => ENV['campaign_id']
|
319
|
+
}
|
320
|
+
body_params = {
|
321
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
322
|
+
:timestamp => timestamp,
|
323
|
+
:username => ENV['username'],
|
324
|
+
:countryCode => ENV['country_code'],
|
325
|
+
:value => '2.5',
|
326
|
+
:date => DateTime.now.strftime('%Y-%m-%d-%H-%M')
|
327
|
+
}
|
328
|
+
|
329
|
+
response = Epom::Campaign.add_fixed_cpm_country_pricing(url_params, body_params)
|
330
|
+
assert_instance_of Hash, response
|
331
|
+
assert_instance_of Fixnum, response['id']
|
332
|
+
assert response['success']
|
333
|
+
end
|
334
|
+
|
335
|
+
test "adjusted_cpm_list" do
|
336
|
+
timestamp = Time.now.to_i * 1000
|
337
|
+
url_params = {
|
338
|
+
:campaignId => ENV['campaign_id']
|
339
|
+
}
|
340
|
+
body_params = {
|
341
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
342
|
+
:timestamp => timestamp,
|
343
|
+
:username => ENV['username'],
|
344
|
+
}
|
345
|
+
|
346
|
+
# PENDING
|
347
|
+
# response = Epom::Campaign.adjusted_cpm_list(url_params, body_params)
|
348
|
+
end
|
349
|
+
|
350
|
+
##########################
|
351
|
+
## Campaign Action Management API
|
352
|
+
##########################
|
353
|
+
|
354
|
+
test "get_actions" do
|
355
|
+
timestamp = Time.now.to_i * 1000
|
356
|
+
url_params = {
|
357
|
+
:campaignId => ENV['campaign_id'],
|
358
|
+
}
|
359
|
+
body_params = {
|
360
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
361
|
+
:timestamp => timestamp,
|
362
|
+
:username => ENV['username'],
|
363
|
+
}
|
364
|
+
|
365
|
+
response = Epom::Campaign.get_actions(url_params, body_params)
|
366
|
+
assert_instance_of Array, response
|
367
|
+
if response.count > 0
|
368
|
+
first = response[0]
|
369
|
+
assert_instance_of String, first['key']
|
370
|
+
end
|
62
371
|
end
|
63
372
|
|
64
|
-
test "
|
373
|
+
test "get_campaign_pricing" do
|
65
374
|
timestamp = Time.now.to_i * 1000
|
66
375
|
url_params = {
|
67
376
|
:campaignId => ENV['campaign_id'],
|
68
|
-
:targetId => '3929'
|
69
377
|
}
|
70
378
|
body_params = {
|
71
379
|
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
@@ -73,9 +381,47 @@ class CampaignTest < ActiveSupport::TestCase
|
|
73
381
|
:username => ENV['username'],
|
74
382
|
}
|
75
383
|
|
76
|
-
response = Epom::Campaign.
|
384
|
+
response = Epom::Campaign.get_campaign_pricing(url_params, body_params)
|
77
385
|
assert_instance_of Hash, response
|
78
386
|
assert_instance_of Fixnum, response['id']
|
387
|
+
assert_instance_of String, response['paymentModel']
|
388
|
+
response
|
389
|
+
end
|
390
|
+
|
391
|
+
test "update_campaign_country_pricing" do
|
392
|
+
timestamp = Time.now.to_i * 1000
|
393
|
+
url_params = {
|
394
|
+
:campaignId => ENV['campaign_id'],
|
395
|
+
:countryCode => ENV['country_code']
|
396
|
+
}
|
397
|
+
body_params = {
|
398
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
399
|
+
:timestamp => timestamp,
|
400
|
+
:username => ENV['username'],
|
401
|
+
:price => [1.1, 2.3, 3.1].sample
|
402
|
+
}
|
403
|
+
|
404
|
+
response = Epom::Campaign.update_campaign_country_pricing(url_params, body_params)
|
405
|
+
assert_not_instance_of Fixnum, response
|
406
|
+
end
|
407
|
+
|
408
|
+
test "update_campaign_pricing" do
|
409
|
+
timestamp = Time.now.to_i * 1000
|
410
|
+
url_params = {
|
411
|
+
:campaignId => ENV['campaign_id'],
|
412
|
+
}
|
413
|
+
body_params = {
|
414
|
+
:hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
|
415
|
+
:timestamp => timestamp,
|
416
|
+
:username => ENV['username'],
|
417
|
+
:price => 2.9
|
418
|
+
}
|
419
|
+
|
420
|
+
response = Epom::Campaign.update_campaign_pricing(url_params, body_params)
|
421
|
+
assert_not_instance_of Fixnum, response
|
422
|
+
|
423
|
+
pricing = test_get_campaign_pricing()
|
424
|
+
assert_equal 2.9, body_params[:price]
|
79
425
|
end
|
80
426
|
|
81
427
|
define_get_tests_auto(Epom::Campaign)
|
data/test/test_helper.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
1
|
require "codeclimate-test-reporter"
|
4
2
|
CodeClimate::TestReporter.start
|
5
3
|
|
6
4
|
# Configure Rails Environment
|
7
5
|
ENV["RAILS_ENV"] = "test"
|
8
6
|
|
7
|
+
require 'yaml'
|
9
8
|
env_file = File.join(Pathname.new(__FILE__).parent.parent, 'config', 'application.yml')
|
10
9
|
YAML.load(File.open(env_file)).each do |key, value|
|
11
10
|
ENV[key.to_s] = value.to_s
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Quintero
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-06-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/epom.rb
|
108
108
|
- lib/epom/ad_unit_size.rb
|
109
109
|
- lib/epom/advertiser.rb
|
110
|
+
- lib/epom/analytic.rb
|
110
111
|
- lib/epom/auth.rb
|
111
112
|
- lib/epom/banner.rb
|
112
113
|
- lib/epom/banner_type.rb
|
@@ -160,6 +161,7 @@ files:
|
|
160
161
|
- test/dummy/public/500.html
|
161
162
|
- test/dummy/public/favicon.ico
|
162
163
|
- test/epom/advertiser_test.rb
|
164
|
+
- test/epom/analytic_test.rb
|
163
165
|
- test/epom/auth_test.rb
|
164
166
|
- test/epom/banner_test.rb
|
165
167
|
- test/epom/campaign_test.rb
|
@@ -208,6 +210,7 @@ test_files:
|
|
208
210
|
- test/epom/campaign_test.rb
|
209
211
|
- test/epom/banner_test.rb
|
210
212
|
- test/epom/auth_test.rb
|
213
|
+
- test/epom/analytic_test.rb
|
211
214
|
- test/epom/advertiser_test.rb
|
212
215
|
- test/dummy/config.ru
|
213
216
|
- test/dummy/Rakefile
|