epom 0.8.5 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48d70eceeb6af7f147e126872b515530f8f92965
4
- data.tar.gz: 411f5af5df623efb9441922fbe5fbf0e77ef42e5
3
+ metadata.gz: ce37fe9a3f11f93ba8706f60270a9b047c18e0bd
4
+ data.tar.gz: 89bd4e659ea2b2308139bd6c1a6b9f8f0c20b67e
5
5
  SHA512:
6
- metadata.gz: 2e425d08441227c6726223680ffe8523529f3a948934e64bb40e81c43ad17cde8fc6b8feff4875ef9a8b33344e05fdc7f904be44c06791f8c96addca8f98de9d
7
- data.tar.gz: a97e1e7fe209f8c61cf2bf186bafaa390fd00d9062c177239b3af0776df087caef8faf77193f5ecef1493bad5f2959063e440e9f633d6fe27a006c56fac5cb8d
6
+ metadata.gz: f8d5cb4a87081dae73fe4c6f93d7a0adce064859dd33efe882e2117d44bb6c33164b2cc225d17f209eee729000058aa98d06ac3380cc879bea34cc3a44840fc9
7
+ data.tar.gz: 8b2856197f2a32b3fd4d1d48469f8054787c4f342dd7edf2abcf64fafb46582144123a7eea19fd79de0ac25f52c5df930780c62ab56a2ab56aa1d760552114f3
@@ -13,6 +13,8 @@ require 'epom/publisher'
13
13
  require 'epom/site'
14
14
  require 'epom/zone'
15
15
 
16
+ require 'epom/config'
17
+
16
18
  module Epom
17
19
 
18
20
  def self.create_hash(*args)
@@ -397,13 +397,13 @@ module Epom
397
397
  :method => :put
398
398
  },
399
399
  :adjusted_cpm_country_trigger => {
400
- :url => '/rest-api/campaign/CAMPAIGN_ID/adjustedCpm/value.do',
400
+ :url => '/rest-api/campaign/CAMPAIGN_ID/adjustedCpm.do',
401
401
  :url_parameters => [:campaignId],
402
402
  :body_parameters => [:enable, :hash, :timestamp, :username],
403
403
  :method => :post
404
404
  },
405
405
  :adjusted_cpm_list => {
406
- :url => '/rest-api/campaign/CAMPAIGN_ID/adjustedCpm/value.do',
406
+ :url => '/rest-api/campaign/CAMPAIGN_ID/adjustedCpm/values.do',
407
407
  :url_parameters => [:campaignId],
408
408
  :body_parameters => [:hash, :timestamp, :username],
409
409
  :method => :get
@@ -0,0 +1,38 @@
1
+ require 'active_support/configurable'
2
+
3
+ module Epom
4
+ # Configures global settings for Epom
5
+ # Epom.configure do |config|
6
+ # config.epom_server = 'https://n29.epom.com/'
7
+ # end
8
+ def self.configure(&block)
9
+ yield @config ||= Epom::Configuration.new
10
+ end
11
+
12
+ # Global settings for Epom
13
+ def self.config
14
+ @config
15
+ end
16
+
17
+ # need a Class for 3.0
18
+ class Configuration #:nodoc:
19
+ include ActiveSupport::Configurable
20
+ config_accessor :public_key
21
+ config_accessor :private_key
22
+ config_accessor :epom_server
23
+
24
+ def param_name
25
+ config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
26
+ end
27
+
28
+ # define param_name writer (copied from AS::Configurable)
29
+ writer, line = 'def param_name=(value); config.param_name = value; end', __LINE__
30
+ singleton_class.class_eval writer, __FILE__, line
31
+ class_eval writer, __FILE__, line
32
+ end
33
+
34
+ # this is ugly. why can't we pass the default value to config_accessor...?
35
+ configure do |config|
36
+ config.epom_server = 'https://n29.epom.com/'
37
+ end
38
+ end
@@ -2,7 +2,6 @@ module Epom
2
2
  class EpomElement
3
3
 
4
4
  include HTTMultiParty
5
- base_uri 'https://n29.epom.com/'
6
5
  default_params :output => 'json'
7
6
  debug_output $stderr
8
7
 
@@ -59,6 +58,7 @@ module Epom
59
58
 
60
59
  if params_validation(url_params, url_params_signature) and params_validation(body_params, body_params_signature)
61
60
  http_proxy ENV['proxy_address'], ENV['proxy_port'], ENV['proxy_user'], ENV['proxy_password']
61
+ base_uri Epom.config.epom_server
62
62
  response = send(method, url, :query => body_params)
63
63
  if response.success?
64
64
  return response.parsed_response
@@ -33,6 +33,11 @@ module Epom
33
33
  :body_parameters => [:publishingCategories, :hash, :timestamp, :username],
34
34
  :method => :get
35
35
  },
36
+ :get_sites_tree => {
37
+ :url => '/rest-api/sites-tree.do',
38
+ :body_parameters => [:publishingCategories, :hash, :timestamp, :username],
39
+ :method => :get
40
+ },
36
41
  :get_sites_zones => {
37
42
  :url => '/rest-api/sites/SITE_ID/zones.do',
38
43
  :url_parameters => [:siteId],
@@ -59,6 +64,12 @@ module Epom
59
64
  :method => :post,
60
65
  :headers => {'Content-type' => 'application/json'}
61
66
  },
67
+ :update_country_pricing => {
68
+ :url => '/rest-api/sites/SITE_ID/pricing/COUNTRY_CODE.do',
69
+ :url_parameters => [:siteId, :countryCode],
70
+ :body_parameters => [:price, :actionId, :hash, :timestamp, :username ],
71
+ :method => :post
72
+ },
62
73
  :update_site => {
63
74
  :url => '/rest-api/sites/update.do',
64
75
  :body_parameters => [:id, :createDefaultZone, :name, :url, :description, :email, :allowPlacementBannersLinkingChange, :categoryId, :revenueShare, :impressionsByMonth, :visitorsByMonth, :hash, :timestamp, :username ],
@@ -78,6 +89,7 @@ module Epom
78
89
  url.gsub!('HASH', url_params[:hash].to_s) if url.include?('HASH')
79
90
  url.gsub!('SITE_ID', url_params[:siteId].to_s) if url.include?('SITE_ID')
80
91
  url.gsub!('PLACEMENT_ID', url_params[:placementId].to_s) if url.include?('PLACEMENT_ID')
92
+ url.gsub!('COUNTRY_CODE', url_params[:countryCode].to_s) if url.include?('COUNTRY_CODE')
81
93
  url
82
94
  end
83
95
  end
@@ -1,3 +1,3 @@
1
1
  module Epom
2
- VERSION = '0.8.5'
3
- end
2
+ VERSION = '0.9'
3
+ end
File without changes
@@ -0,0 +1,9 @@
1
+ module Epom
2
+ class ConfigGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def copy_epom_file
6
+ template 'epom.rb', 'config/initializers/epom.rb'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ Epom.configure do |config|
2
+ config.public_key = 'public_key'
3
+ config.private_key = 'private_key'
4
+ config.epom_server = 'https://n29.epom.com/'
5
+ end
@@ -0,0 +1,5 @@
1
+ Epom.configure do |config|
2
+ config.public_key = 'public_key'
3
+ config.private_key = 'private_key'
4
+ config.epom_server = 'https://n29.epom.com/'
5
+ end
@@ -18,6 +18,7 @@ class AnalyticTest < ActiveSupport::TestCase
18
18
  :displayIds => true,
19
19
  :range => 'CURRENT_MONTH',
20
20
  :groupBy => 'ADVERTISER,CAMPAIGN,BANNER,SITE,ZONE,PLACEMENT',
21
+ # :eqLong => {'ADVERTISER' => ENV['advertiser_id'], 'SITE' => ENV['site_id']}
21
22
  }
22
23
 
23
24
  response = Epom::Analytic.analytics(url_params, body_params)
@@ -500,5 +500,16 @@ class BannerTest < ActiveSupport::TestCase
500
500
  end
501
501
  end
502
502
 
503
+ test "get_device_values" do
504
+ timestamp = Time.now.to_i * 1000
505
+ url_params = {
506
+ :bannerId => ENV['banner_id'],
507
+ }
508
+ body_params = {}
509
+
510
+ response = Epom::Banner.get_device_values(url_params, body_params)
511
+ # assert_not_instance_of Fixnum, response
512
+ end
513
+
503
514
  define_get_tests_auto(Epom::Banner)
504
515
  end
@@ -343,8 +343,14 @@ class CampaignTest < ActiveSupport::TestCase
343
343
  :username => ENV['username'],
344
344
  }
345
345
 
346
- # PENDING
347
- # response = Epom::Campaign.adjusted_cpm_list(url_params, body_params)
346
+ response = Epom::Campaign.adjusted_cpm_list(url_params, body_params)
347
+ assert_instance_of Array, response
348
+ if response.count > 0
349
+ first = response[0]
350
+ assert_instance_of Fixnum, first['id']
351
+ assert_instance_of Float, first['value']
352
+ assert_instance_of String, first['country']
353
+ end
348
354
  end
349
355
 
350
356
  ##########################
@@ -424,5 +430,16 @@ class CampaignTest < ActiveSupport::TestCase
424
430
  assert_equal 2.9, body_params[:price]
425
431
  end
426
432
 
433
+ test "get_device_values" do
434
+ timestamp = Time.now.to_i * 1000
435
+ url_params = {
436
+ :campaignId => ENV['campaign_id'],
437
+ }
438
+ body_params = {}
439
+
440
+ response = Epom::Campaign.get_device_values(url_params, body_params)
441
+ # assert_not_instance_of Fixnum, response
442
+ end
443
+
427
444
  define_get_tests_auto(Epom::Campaign)
428
445
  end
@@ -41,7 +41,6 @@ class SiteTest < ActiveSupport::TestCase
41
41
  if response.count > 0
42
42
  first = response.first
43
43
  assert_instance_of Hash, first
44
- assert_instance_of Float, first['cpmThreshold']
45
44
  end
46
45
  end
47
46
 
@@ -111,6 +110,34 @@ class SiteTest < ActiveSupport::TestCase
111
110
  assert response['success']
112
111
  end
113
112
 
113
+ test "get_sites_tree" do
114
+ timestamp = Time.now.to_i * 1000
115
+ url_params = {}
116
+ body_params = {}
117
+
118
+ response = Epom::Site.get_sites_tree(url_params, body_params)
119
+ assert_instance_of Array, response
120
+ if response.count > 0
121
+ first = response[0]
122
+ assert_instance_of Hash, first
123
+ assert_instance_of Fixnum, first['id']
124
+ assert_instance_of String, first['name']
125
+ assert_instance_of Array, first['zones']
126
+ if first['zones'].count > 0
127
+ first = first['zones'][0]
128
+ assert_instance_of Hash, first
129
+ assert_instance_of Fixnum, first['id']
130
+ assert_instance_of Array, first['placements']
131
+ if first['placements'].count > 0
132
+ first = first['placements'][0]
133
+ assert_instance_of Hash, first
134
+ assert_instance_of Fixnum, first['id']
135
+ assert_instance_of String, first['name']
136
+ end
137
+ end
138
+ end
139
+ end
140
+
114
141
  test "get_sites_zones" do
115
142
  timestamp = Time.now.to_i * 1000
116
143
  body_params = {
@@ -131,5 +158,19 @@ class SiteTest < ActiveSupport::TestCase
131
158
  end
132
159
  end
133
160
 
161
+ # ***** INCOMPATIBLE WITH set_site_pricing TEST *****
162
+ # test 'update_country_pricing' do
163
+ # url_params = {
164
+ # :siteId => ENV['site_id'],
165
+ # :countryCode => ENV['country_code']
166
+ # }
167
+ # body_params = {
168
+ # :price => 2.33
169
+ # }
170
+
171
+ # response = Epom::Site.update_country_pricing(url_params, body_params)
172
+ # assert_not_instance_of Fixnum, response
173
+ # end
174
+
134
175
  define_get_tests_auto(Epom::Site)
135
176
  end
@@ -56,3 +56,11 @@ def define_get_tests_auto(klass)
56
56
  end
57
57
  end
58
58
  end
59
+
60
+ Epom.configure do |config|
61
+ config.public_key = ENV['public_key']
62
+ config.private_key = ENV['private_key']
63
+ config.epom_server = ENV['epom_server']
64
+ end
65
+
66
+ Epom::EpomElement.login(ENV['username'], ENV['password'])
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.8.5
4
+ version: '0.9'
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-06-08 00:00:00.000000000 Z
13
+ date: 2015-06-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -114,6 +114,7 @@ files:
114
114
  - lib/epom/banner_type.rb
115
115
  - lib/epom/campaign.rb
116
116
  - lib/epom/category.rb
117
+ - lib/epom/config.rb
117
118
  - lib/epom/day_of_week.rb
118
119
  - lib/epom/epom_element.rb
119
120
  - lib/epom/limit_counters.rb
@@ -126,8 +127,10 @@ files:
126
127
  - lib/epom/site.rb
127
128
  - lib/epom/version.rb
128
129
  - lib/epom/zone.rb
130
+ - lib/generators/epom/config/USAGE
131
+ - lib/generators/epom/config/config_generator.rb
132
+ - lib/generators/epom/config/templates/epom.rb
129
133
  - lib/tasks/epom_tasks.rake
130
- - test/IMG_5457-128x128.JPG
131
134
  - test/dummy/README.rdoc
132
135
  - test/dummy/Rakefile
133
136
  - test/dummy/app/assets/javascripts/application.js
@@ -150,6 +153,7 @@ files:
150
153
  - test/dummy/config/initializers/assets.rb
151
154
  - test/dummy/config/initializers/backtrace_silencers.rb
152
155
  - test/dummy/config/initializers/cookies_serializer.rb
156
+ - test/dummy/config/initializers/epom.rb
153
157
  - test/dummy/config/initializers/filter_parameter_logging.rb
154
158
  - test/dummy/config/initializers/inflections.rb
155
159
  - test/dummy/config/initializers/mime_types.rb
@@ -173,9 +177,6 @@ files:
173
177
  - test/epom/site_test.rb
174
178
  - test/epom/zone_test.rb
175
179
  - test/epom_test.rb
176
- - test/logo-128x128.png
177
- - test/test.php
178
- - test/test.rb
179
180
  - test/test_helper.rb
180
181
  homepage: https://github.com/kewelta/epom
181
182
  licenses:
@@ -203,11 +204,7 @@ specification_version: 4
203
204
  summary: Epom gem.
204
205
  test_files:
205
206
  - test/test_helper.rb
206
- - test/test.rb
207
- - test/test.php
208
- - test/logo-128x128.png
209
207
  - test/epom_test.rb
210
- - test/IMG_5457-128x128.JPG
211
208
  - test/epom/zone_test.rb
212
209
  - test/epom/site_test.rb
213
210
  - test/epom/placement_test.rb
@@ -237,6 +234,7 @@ test_files:
237
234
  - test/dummy/config/initializers/mime_types.rb
238
235
  - test/dummy/config/initializers/inflections.rb
239
236
  - test/dummy/config/initializers/filter_parameter_logging.rb
237
+ - test/dummy/config/initializers/epom.rb
240
238
  - test/dummy/config/initializers/cookies_serializer.rb
241
239
  - test/dummy/config/initializers/backtrace_silencers.rb
242
240
  - test/dummy/config/initializers/assets.rb
Binary file
Binary file
@@ -1,51 +0,0 @@
1
- <?php
2
- define("DEBUG",false);
3
-
4
- $username = "kewelta";
5
- $password = "kewelta";
6
- $timestamp = round(microtime(true) * 1000);
7
- $hash = md5(md5($password).$timestamp);
8
-
9
- $url = "https://n29.epom.com/rest-api/banner/create.do";
10
- /*Getting the full path to your file*/
11
- $file_name_with_full_path = realpath('300x250.gif');
12
- /*Specifying MIME type of the file*/
13
- $filetype = "image/gif";
14
-
15
- $post_data = array(
16
- "hash" => $hash,
17
- "timestamp" => $timestamp,
18
- "username" => $username,
19
- "placementType" => "SITE_PLACEMENT",
20
- "campaignId" => "1261",
21
- "active" => "true",
22
- "name" => "test_banner_1",
23
- "weight" => "1",
24
- "bannerType" => "LOCAL_FILE",
25
- "imageBannerLink" => "http://qwe.com",
26
- "imageFile" => "@$file_name_with_full_path;type=$filetype",
27
- "url" => "http://qwe.com",
28
- "adUnitId" => "1"
29
- );
30
-
31
- $options = array(
32
- CURLOPT_URL => $url,
33
- CURLOPT_SSL_VERIFYPEER => false,
34
- CURLOPT_POST => true,
35
- CURLOPT_POSTFIELDS => $post_data,
36
- CURLOPT_HTTPHEADER => array("Content-type: multipart/form-data"),
37
- CURLOPT_RETURNTRANSFER => true
38
- );
39
-
40
- $curl = curl_init();
41
-
42
- curl_setopt_array($curl,$options);
43
-
44
- echo curl_exec($curl);
45
-
46
- if(DEBUG){
47
- echo "\n\n";
48
- echo $url;
49
- print_r($post_data);
50
- }
51
- ?>
@@ -1,21 +0,0 @@
1
- require 'pathname'
2
- require 'yaml'
3
-
4
- env_file = File.join(Pathname.new(__FILE__).parent.parent, 'config', 'application.yml')
5
- YAML.load(File.open(env_file)).each do |key, value|
6
- ENV[key.to_s] = value.to_s
7
- end if File.exists?(env_file)
8
-
9
- require 'epom'
10
-
11
- timestamp = Time.now.to_i * 1000
12
- body_params = {
13
- :hash => Epom.create_hash(Epom.create_hash(ENV['password']), timestamp),
14
- :timestamp => timestamp,
15
- :username => ENV['username'],
16
- }
17
- url_params = {}
18
-
19
- response = Epom::Site.get_sites(url_params, body_params)
20
-
21
- puts response