epom 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +28 -0
  5. data/config/application.yml +41 -0
  6. data/lib/epom.rb +22 -0
  7. data/lib/epom/ad_unit_size.rb +15 -0
  8. data/lib/epom/advertiser.rb +45 -0
  9. data/lib/epom/auth.rb +31 -0
  10. data/lib/epom/banner.rb +525 -0
  11. data/lib/epom/banner_type.rb +15 -0
  12. data/lib/epom/campaign.rb +508 -0
  13. data/lib/epom/day_of_week.rb +11 -0
  14. data/lib/epom/epom_element.rb +61 -0
  15. data/lib/epom/limit_counters.rb +10 -0
  16. data/lib/epom/payment_model.rb +9 -0
  17. data/lib/epom/period_type.rb +9 -0
  18. data/lib/epom/placement.rb +56 -0
  19. data/lib/epom/placement_type.rb +7 -0
  20. data/lib/epom/publisher.rb +6 -0
  21. data/lib/epom/relation.rb +9 -0
  22. data/lib/epom/site.rb +84 -0
  23. data/lib/epom/version.rb +3 -0
  24. data/lib/epom/zone.rb +38 -0
  25. data/lib/tasks/epom_tasks.rake +4 -0
  26. data/test/IMG_5457-128x128.JPG +0 -0
  27. data/test/dummy/README.rdoc +28 -0
  28. data/test/dummy/Rakefile +6 -0
  29. data/test/dummy/app/assets/javascripts/application.js +13 -0
  30. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  31. data/test/dummy/app/controllers/application_controller.rb +5 -0
  32. data/test/dummy/app/helpers/application_helper.rb +2 -0
  33. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  34. data/test/dummy/bin/bundle +3 -0
  35. data/test/dummy/bin/rails +4 -0
  36. data/test/dummy/bin/rake +4 -0
  37. data/test/dummy/bin/setup +29 -0
  38. data/test/dummy/config.ru +4 -0
  39. data/test/dummy/config/application.rb +26 -0
  40. data/test/dummy/config/boot.rb +5 -0
  41. data/test/dummy/config/database.yml +25 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/development.rb +41 -0
  44. data/test/dummy/config/environments/production.rb +79 -0
  45. data/test/dummy/config/environments/test.rb +42 -0
  46. data/test/dummy/config/initializers/assets.rb +11 -0
  47. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  48. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  49. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/test/dummy/config/initializers/inflections.rb +16 -0
  51. data/test/dummy/config/initializers/mime_types.rb +4 -0
  52. data/test/dummy/config/initializers/session_store.rb +3 -0
  53. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  54. data/test/dummy/config/locales/en.yml +23 -0
  55. data/test/dummy/config/routes.rb +56 -0
  56. data/test/dummy/config/secrets.yml +22 -0
  57. data/test/dummy/db/development.sqlite3 +0 -0
  58. data/test/dummy/db/schema.rb +16 -0
  59. data/test/dummy/db/test.sqlite3 +0 -0
  60. data/test/dummy/log/development.log +4 -0
  61. data/test/dummy/log/test.log +17350 -0
  62. data/test/dummy/public/404.html +67 -0
  63. data/test/dummy/public/422.html +67 -0
  64. data/test/dummy/public/500.html +66 -0
  65. data/test/dummy/public/favicon.ico +0 -0
  66. data/test/epom/advertiser_test.rb +85 -0
  67. data/test/epom/auth_test.rb +50 -0
  68. data/test/epom/banner_test.rb +194 -0
  69. data/test/epom/campaign_test.rb +65 -0
  70. data/test/epom/placement_test.rb +53 -0
  71. data/test/epom/site_test.rb +136 -0
  72. data/test/epom/zone_test.rb +67 -0
  73. data/test/epom_test.rb +38 -0
  74. data/test/logo-128x128.png +0 -0
  75. data/test/test.php +51 -0
  76. data/test/test.rb +21 -0
  77. data/test/test_helper.rb +55 -0
  78. metadata +256 -0
@@ -0,0 +1,11 @@
1
+ module Epom
2
+ class DayOfWeek
3
+ MONDAY = 'MONDAY'
4
+ TUESDAY = 'TUESDAY'
5
+ WEDNESDAY = 'WEDNESDAY'
6
+ THURSDAY = 'THURSDAY'
7
+ FRIDAY = 'FRIDAY'
8
+ SATURDAY = 'SATURDAY'
9
+ SUNDAY = 'SUNDAY'
10
+ end
11
+ end
@@ -0,0 +1,61 @@
1
+ module Epom
2
+ class EpomElement
3
+
4
+ include HTTMultiParty
5
+ base_uri 'https://n29.epom.com/'
6
+ default_params :output => 'json'
7
+ format :json
8
+ debug_output $stderr
9
+
10
+ def self.extended_methods
11
+ { }
12
+ end
13
+
14
+ def self.params_validation(params, params_signature)
15
+ return true if params_signature.nil? or params_signature.count.zero?
16
+ return true if params.keys.all? {|key| params_signature.include?(key)}
17
+ puts "invalid params: #{params.keys.select{|key| not params_signature.include?(key)}}"
18
+ return false
19
+ end
20
+
21
+ def self.generic_method(method_name, url_params, body_params)
22
+ signature = extended_methods[method_name]
23
+ url_params_signature = signature[:url_parameters]
24
+ body_params_signature = signature[:body_parameters]
25
+ url_signature = signature[:url]
26
+
27
+ url = replace_params_in_url(url_signature, url_params)
28
+ method = signature[:method]
29
+
30
+ if signature[:headers]
31
+ headers signature[:headers]
32
+ else
33
+ default_options[:headers] = {}
34
+ end
35
+
36
+ if params_validation(url_params, url_params_signature) and params_validation(body_params, body_params_signature)
37
+ http_proxy ENV['proxy_address'], ENV['proxy_port'], ENV['proxy_user'], ENV['proxy_password']
38
+ response = send(method, url, :query => body_params)
39
+ if response.success?
40
+ return response.parsed_response
41
+ else
42
+ response.code
43
+ end
44
+ else
45
+ raise ArgumentError, 'Error in params_validation method'
46
+ end
47
+ end
48
+
49
+ def self.replace_params_in_url(url, url_params)
50
+ url
51
+ end
52
+
53
+ def self.method_missing(name, *args)
54
+ if self.extended_methods.keys.include?(name.to_sym)
55
+ self.generic_method(name, *args)
56
+ else
57
+ super
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,10 @@
1
+ module Epom
2
+ class LimitCounter
3
+ TOTAL_IMPRESSIONS = 'TOTAL_IMPRESSIONS'
4
+ TOTAL_CLICKS = 'TOTAL_CLICKS'
5
+ TOTAL_REVENUE = 'TOTAL_REVENUE'
6
+ DAILY_IMPRESSIONS = 'DAILY_IMPRESSIONS'
7
+ DAILY_CLICKS = 'DAILY_CLICKS'
8
+ DAILY_REVENUE = 'DAILY_REVENUE'
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module Epom
2
+ class PaymentModel
3
+ CPM = 'CPM'
4
+ CPC = 'CPC'
5
+ CPA = 'CPA'
6
+ FIXED_CPM = 'FIXED_CPM'
7
+ FIXED_CPC = ''
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Epom
2
+ class PeriodType
3
+ HOUR = 'HOUR'
4
+ DAY = 'DAY'
5
+ WEEK = 'WEEK'
6
+ MONTH = 'MONTH'
7
+ YEAR = 'YEAR'
8
+ end
9
+ end
@@ -0,0 +1,56 @@
1
+ require 'epom/epom_element'
2
+ require 'epom/placement_type'
3
+ require 'epom/ad_unit_size'
4
+
5
+ module Epom
6
+ class Placement < EpomElement
7
+
8
+ def self.extended_methods
9
+ {
10
+ :delete_placement => {
11
+ :url => '/rest-api/placements/PLACEMENT_ID/delete.do',
12
+ :url_parameters => [:placementId],
13
+ :body_parameters => [:hash, :timestamp, :username],
14
+ :method => :post
15
+ },
16
+ :get_placement_summary => {
17
+ :url => '/rest-api/placements/summary.do',
18
+ :body_parameters => [:placementIds, :publishingCategories, :hash, :timestamp, :username],
19
+ :method => :get
20
+ },
21
+ :update_mobile_placement => {
22
+ :url => '/rest-api/placements/update/mobile.do',
23
+ :body_parameters => [:id, :zoneId, :type, :name, :description, :defaultCode, :hash, :timestamp, :username],
24
+ :method => :post
25
+ },
26
+ :update_non_standard_placement => {
27
+ :url => '/rest-api/placements/update/non-standard.do',
28
+ :body_parameters => [:id, :zoneId, :type, :name, :description, :hash, :timestamp, :username],
29
+ :method => :post
30
+ },
31
+ :create_non_standard_placement => {
32
+ :url => '/rest-api/placements/update/non-standard.do',
33
+ :body_parameters => [:zoneId, :type, :name, :description, :hash, :timestamp, :username],
34
+ :method => :post
35
+ },
36
+ :update_standard_placement => {
37
+ :url => '/rest-api/placements/update/standard.do',
38
+ :body_parameters => [:id, :zoneId, :type, :name, :description, :adUnit, :height, :width, :allowVariableBannerSizes, :defaultCode, :rotateInterval, :hash, :timestamp, :username],
39
+ :method => :post
40
+ },
41
+ :create_standard_placement => {
42
+ :url => '/rest-api/placements/update/standard.do',
43
+ :body_parameters => [:zoneId, :type, :name, :description, :adUnitId, :size, 'size.height', 'size.width', :allowVariableBannerSizes, :defaultCode, :rotateInterval, :hash, :timestamp, :username],
44
+ :method => :post
45
+ }
46
+
47
+
48
+ }
49
+ end
50
+
51
+ def self.replace_params_in_url(url, url_params)
52
+ url.gsub!('PLACEMENT_ID', url_params[:placementId]) if url.include?('PLACEMENT_ID')
53
+ url
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,7 @@
1
+ module Epom
2
+ class PlacementType
3
+ SITE_PLACEMENT = 'SITE_PLACEMENT'
4
+ NON_STANDARD_SITE_PLACEMENT = 'NON_STANDARD_SITE_PLACEMENT'
5
+ MOBILE_SITE_PLACEMENT = 'MOBILE_SITE_PLACEMENT'
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ require 'epom/epom_element'
2
+
3
+ module Epom
4
+ class Publisher < EpomElement
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ module Epom
2
+ class Relation
3
+ LOWER = 'LOWER'
4
+ GREATER = 'GREATER'
5
+ LOWER_EQUAL = 'LOWER_EQUAL'
6
+ GREATER_EQUAL = 'GREATER_EQUAL'
7
+ EQUAL = 'EQUAL'
8
+ end
9
+ end
data/lib/epom/site.rb ADDED
@@ -0,0 +1,84 @@
1
+ require 'epom/epom_element'
2
+
3
+ module Epom
4
+ class Site < EpomElement
5
+ def self.extended_methods
6
+ {
7
+ :delete_site => {
8
+ :url => '/rest-api/sites/SITE_ID/delete.do',
9
+ :url_parameters => [:siteId],
10
+ :body_parameters => [:hash, :timestamp, :username],
11
+ :method => :post
12
+ },
13
+ :delete_site_cpm_threshold => {
14
+ :url => '/rest-api/sites/SITE_ID/cpm-thresholds/delete.do',
15
+ :url_parameters => [:siteId],
16
+ :body_parameters => [:hash, :timestamp, :username],
17
+ :method => :post
18
+ },
19
+ :get_site_cpm_threshold_summary => {
20
+ :url => '/rest-api/sites/SITE_ID/cpm-thresholds.do',
21
+ :url_parameters => [:siteId],
22
+ :body_parameters => [:hash, :timestamp, :username],
23
+ :method => :get
24
+ },
25
+ :get_site_pricing => {
26
+ :url => '/rest-api/sites/SITE_ID/pricing.do',
27
+ :url_parameters => [:siteId],
28
+ :body_parameters => [:hash, :timestamp, :username],
29
+ :method => :get
30
+ },
31
+ :get_sites => {
32
+ :url => '/rest-api/sites.do',
33
+ :body_parameters => [:publishingCategories, :hash, :timestamp, :username],
34
+ :method => :get
35
+ },
36
+ :get_sites_zones => {
37
+ :url => '/rest-api/sites/SITE_ID/zones.do',
38
+ :url_parameters => [:siteId],
39
+ :body_parameters => [:hash, :timestamp, :username],
40
+ :method => :get
41
+ },
42
+ :set_site_cpm_thresholds => {
43
+ :url => '/rest-api/sites/SITE_ID/cpm-thresholds.do',
44
+ :url_parameters => [:siteId],
45
+ :body_parameters => [:cpmThreshold, :siteCountryCPMThresholds, :hash, :timestamp, :username],
46
+ :method => :post
47
+ },
48
+ :set_site_pricing => {
49
+ :url => '/rest-api/sites/SITE_ID/pricing.do?username=USERNAME&timestamp=TIMESTAMP&hash=HASH',
50
+ :url_parameters => [:siteId, :hash, :timestamp, :username],
51
+ :body_parameters => [],
52
+ :method => :post,
53
+ :headers => {'Content-type' => 'application/json'}
54
+ },
55
+ :set_placement_pricing => {
56
+ :url => '/rest-api/placements/PLACEMENT_ID/pricing.do?username=USERNAME&timestamp=TIMESTAMP&hash=HASH',
57
+ :url_parameters => [:placementId, :hash, :timestamp, :username],
58
+ :body_parameters => [],
59
+ :method => :post,
60
+ :headers => {'Content-type' => 'application/json'}
61
+ },
62
+ :update_site => {
63
+ :url => '/rest-api/sites/update.do',
64
+ :body_parameters => [:id, :createDefaultZone, :name, :url, :description, :email, :allowPlacementBannersLinkingChange, :categoryId, :revenueShare, :impressionsByMonth, :visitorsByMonth, :hash, :timestamp, :username ],
65
+ :method => :post
66
+ },
67
+ :create_site => {
68
+ :url => '/rest-api/sites/update.do',
69
+ :body_parameters => [:createDefaultZone, :name, :url, :description, :email, :allowPlacementBannersLinkingChange, :categoryId, :revenueShare, :impressionsByMonth, :visitorsByMonth, :hash, :timestamp, :username ],
70
+ :method => :post
71
+ },
72
+ }
73
+ end
74
+
75
+ def self.replace_params_in_url(url, url_params)
76
+ url.gsub!('USERNAME', url_params[:username].to_s) if url.include?('USERNAME')
77
+ url.gsub!('TIMESTAMP', url_params[:timestamp].to_s) if url.include?('TIMESTAMP')
78
+ url.gsub!('HASH', url_params[:hash].to_s) if url.include?('HASH')
79
+ url.gsub!('SITE_ID', url_params[:siteId].to_s) if url.include?('SITE_ID')
80
+ url.gsub!('PLACEMENT_ID', url_params[:placementId].to_s) if url.include?('PLACEMENT_ID')
81
+ url
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,3 @@
1
+ module Epom
2
+ VERSION = '0.1.0'
3
+ end
data/lib/epom/zone.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'epom/epom_element'
2
+
3
+ module Epom
4
+ class Zone < EpomElement
5
+
6
+ def self.extended_methods
7
+ {
8
+ :delete_zone => {
9
+ :url => '/rest-api/zones/ZONE_ID/delete.do',
10
+ :url_parameters => [:zoneId],
11
+ :body_parameters => [:hash, :timestamp, :username],
12
+ :method => :post
13
+ },
14
+ :get_zone_placement => {
15
+ :url => '/rest-api/zones/ZONE_ID/placements.do',
16
+ :url_parameters => [:zoneId],
17
+ :body_parameters => [:hash, :timestamp, :username],
18
+ :method => :get
19
+ },
20
+ :update_zone => {
21
+ :url => '/rest-api/zones/update.do',
22
+ :body_parameters => [:zoneId, :siteId, :description, :name, :hash, :timestamp, :username],
23
+ :method => :post
24
+ },
25
+ :create_zone => {
26
+ :url => '/rest-api/zones/update.do',
27
+ :body_parameters => [:siteId, :description, :name, :hash, :timestamp, :username],
28
+ :method => :post
29
+ }
30
+ }
31
+ end
32
+
33
+ def self.replace_params_in_url(url, url_params)
34
+ url.gsub!('ZONE_ID', url_params[:zoneId]) if url.include?('ZONE_ID')
35
+ url
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :epom do
3
+ # # Task goes here
4
+ # end
Binary file
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run