jjp-openx 1.1.4 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -22,3 +22,46 @@
22
22
  === 1.1.2 / 2009-11-19
23
23
 
24
24
  * Documentation updates and patch to enable banner support on the OpenX Server
25
+
26
+ === 1.1.4 / 2010-04-17
27
+
28
+ * Fork of 1.1.2
29
+
30
+ * Added statistic methods for Banner:
31
+
32
+ * renamed statistics method into daily_statistics, left statistics method as an alias for daily_statistics
33
+ * daily_statistics(start_on = Date.today, end_on = Date.today) - Daily stats for the Banner
34
+ * publisher_statistics(start_on = Date.today, end_on = Date.today) - Banner stats by Publisher
35
+ * zone_statistics(start_on = Date.today, end_on = Date.today) - Banner stats by Zone
36
+
37
+ === 1.1.5 / 2010-05-18
38
+
39
+ * Created generic statistics method:
40
+
41
+ * get_statistics(service_method, start_on = Date.today, end_on = Date.today, local_time_zone = true) in sepearate module OpenX::Services::Statistics in file statistics.rb
42
+ * included statistics module in all stats objects: Agency, Advertiser, Campaign, Banner, Publisher, Zone.
43
+ * all existing statistics methods are now calling get_statistics.
44
+
45
+ * Added to statistics methods localTZ parameter default to true. This way OpenX will return stats for the period of time with offset according to the local time zone. If that parameter is false it will give numbers for UTC. The localTZ implementation based only on that post http://forum.openx.org/index.php?s=18f1d84f86e32297083f87f8d9eb4fda&showtopic=503433151
46
+
47
+ * statistics
48
+ * daily_statistics
49
+ * publisher_statistics
50
+ * zone_statistics
51
+
52
+ * Added statistics methods for other objects as well
53
+
54
+ * Agency
55
+ * Advertiser
56
+ * Campaign
57
+ * Banner
58
+ * Publisher
59
+
60
+ * daily_statistics
61
+ * banner_statistics
62
+
63
+ * Zone
64
+
65
+ === 1.1.6 / 2010-05-18
66
+
67
+ * lib/openx/services/statistic.rb file was missing on github while building gemspec, so the version 1.1.5 is actually broken.
data/README.rdoc CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  == Description
7
7
 
8
- A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/
8
+ A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/ . It also works with v2 of OpenX API, especially that it now can pass localTZ to the OpenX API which will give back the correct statistics for the local time zone.
9
9
 
10
10
  == Synopsis
11
11
 
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ begin
8
8
  Jeweler::Tasks.new do |gemspec|
9
9
  gemspec.name = "jjp-openx"
10
10
  gemspec.summary = "A Ruby interface to the OpenX XML-RPC API with more OpenX APIs used"
11
- gemspec.description = "A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/"
11
+ gemspec.description = "A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/ . It also works with v2 of OpenX API, especially that it now can pass localTZ to the OpenX API which will give back the correct statistics for the local time zone."
12
12
  gemspec.email = "jacobjp@mac.com"
13
13
  gemspec.homepage = "http://github.com/DoppioJP/openx"
14
14
  gemspec.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc", "DoppioJP"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.4
1
+ 1.1.6
data/jjp-openx.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jjp-openx}
8
- s.version = "1.1.4"
8
+ s.version = "1.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Patterson", "Andy Smith", "TouchLocal Plc", "DoppioJP"]
12
- s.date = %q{2010-04-18}
13
- s.description = %q{A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/}
12
+ s.date = %q{2010-05-19}
13
+ s.description = %q{A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/ . It also works with v2 of OpenX API, especially that it now can pass localTZ to the OpenX API which will give back the correct statistics for the local time zone.}
14
14
  s.email = %q{jacobjp@mac.com}
15
15
  s.extra_rdoc_files = [
16
16
  "README.rdoc"
@@ -34,6 +34,7 @@ Gem::Specification.new do |s|
34
34
  "lib/openx/services/campaign.rb",
35
35
  "lib/openx/services/publisher.rb",
36
36
  "lib/openx/services/session.rb",
37
+ "lib/openx/services/statistics.rb",
37
38
  "lib/openx/services/zone.rb",
38
39
  "lib/openx/xmlrpc_client.rb",
39
40
  "php/openx-2.8.1-keywords.diff",
@@ -1,14 +1,27 @@
1
1
  module OpenX
2
2
  class Invocation
3
3
  class << self
4
+ # Whatever
5
+ # banner = OpenX::Invocation.view("Plumber")
4
6
  #
5
- # banner = OpenX::Invocation.view("Plumber")
7
+ # banners = OpenX::Invocation.view("Plumber", :count => 2, :exclude_by_campaignid => true) ;nil
6
8
  #
7
- # banners = OpenX::Invocation.view("Plumber", :count => 2, :exclude_by_campaignid => true) ;nil
8
- # banners.each do |banner|
9
- # puts "Banner #{banner['bannerid']}"
10
- # end; nil
9
+ # banners.each do |banner|
10
+ # puts "Banner #{banner['bannerid']}"
11
+ # end; nil
11
12
  #
13
+ #
14
+ # Defaults
15
+ # :count => 1,
16
+ # :campaignid => 0,
17
+ # :target => '',
18
+ # :source => '',
19
+ # :with_text => false,
20
+ # :exclusions => [],
21
+ # :inclusions => [],
22
+ # :exclude_by_campaignid => false,
23
+ # :exclude_by_bannerid => false
24
+ #
12
25
  def view(what, params = {})
13
26
  defaults = {
14
27
  :count => 1,
@@ -1,6 +1,10 @@
1
1
  module OpenX
2
2
  module Services
3
3
  class Advertiser < Base
4
+
5
+ require 'openx/services/statistics'
6
+ include OpenX::Services::Statistics
7
+
4
8
  openx_accessor :name => :advertiserName,
5
9
  :contact_name => :contactName,
6
10
  :email => :emailAddress,
@@ -1,6 +1,10 @@
1
1
  module OpenX
2
2
  module Services
3
3
  class Agency < Base
4
+
5
+ require 'openx/services/statistics'
6
+ include OpenX::Services::Statistics
7
+
4
8
  # Translate our property names to OpenX property names
5
9
  openx_accessor :name => :agencyName,
6
10
  :contact_name => :contactName,
@@ -3,6 +3,10 @@ require 'date'
3
3
  module OpenX
4
4
  module Services
5
5
  class Banner < Base
6
+
7
+ require 'openx/services/statistics'
8
+ include OpenX::Services::Statistics
9
+
6
10
  LOCAL_SQL = 'sql'
7
11
  LOCAL_WEB = 'web'
8
12
  EXTERNAL = 'url'
@@ -11,7 +15,7 @@ module OpenX
11
15
 
12
16
  RUNNING = 0
13
17
  PAUSED = 1
14
-
18
+
15
19
  class << self
16
20
  def find(id, *args)
17
21
  session = self.connection
@@ -77,32 +81,29 @@ module OpenX
77
81
  super(params)
78
82
  end
79
83
 
80
- # Alias for daily_statistics method to keep consistency with OpenX API calls
81
- # Originally it was call for ox.bannerDailyStatistics so it is kept for compatibility with the previous version
82
- def statistics start_on = Date.today, end_on = Date.today
83
- daily_statistics start_on, end_on
84
+ # Alias for daily_statistics method to keep consistency with OpenX API calls.
85
+ # Originally it was call for ox.bannerDailyStatistics so it is kept for compatibility with the previous version of the gem.
86
+ def statistics start_on = Date.today, end_on = Date.today, local_time_zone = true
87
+ daily_statistics start_on, end_on, local_time_zone
84
88
  end
85
89
 
86
- # Returns statistics in Array of Hashes by day, which are: impressions, clicks, requests and revenue.
90
+ # Returns statistics in Array of Hashes by day, which are: impressions, clicks, requests and revenue.
87
91
  # Each day is represented by XMLRPC::DateTime which has instant variables:
88
92
  # @year, @month, @day, @hour, @min, @sec
89
- def daily_statistics start_on = Date.today, end_on = Date.today
90
- session = self.class.connection
91
- @server.call('ox.bannerDailyStatistics', session, self.id, start_on, end_on)
93
+ def daily_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true
94
+ self.get_statistics('ox.bannerDailyStatistics', start_on, end_on, local_time_zone)
92
95
  end
93
96
 
94
97
  # Returns statistics in Array of Hashes by publisher, which are: impression, clicks, requests and revenue.
95
98
  # Also returns publisherName and publisherId
96
- def publisher_statistics start_on = Date.today, end_on = Date.today
97
- session = self.class.connection
98
- @server.call('ox.bannerPublisherStatistics', session, self.id, start_on, end_on)
99
+ def publisher_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true
100
+ self.get_statistics('ox.bannerPublisherStatistics', start_on, end_on, local_time_zone)
99
101
  end
100
102
 
101
103
  # Returns statistics in Array of Hashes by zone, which are: impression, clicks, requests, conversions and revenue.
102
104
  # Also returns publisherName, publisherId, zoneName, zoneId
103
- def zone_statistics start_on = Date.today, end_on = Date.today
104
- session = self.class.connection
105
- @server.call('ox.bannerZoneStatistics', session, self.id, start_on, end_on)
105
+ def zone_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true
106
+ self.get_statistics('ox.bannerZoneStatistics', start_on, end_on, local_time_zone)
106
107
  end
107
108
 
108
109
  def targeting
@@ -1,6 +1,10 @@
1
1
  module OpenX
2
2
  module Services
3
3
  class Campaign < Base
4
+
5
+ require 'openx/services/statistics'
6
+ include OpenX::Services::Statistics
7
+
4
8
  # Translate our property names to OpenX property names
5
9
  openx_accessor :name => :campaignName,
6
10
  :advertiser_id => :advertiserId,
@@ -27,7 +31,7 @@ module OpenX
27
31
  self.find_all = 'ox.getCampaignListByAdvertiserId'
28
32
 
29
33
  # Revenue types
30
- CPM = 1
34
+ CPM = 1
31
35
  CPC = 2
32
36
  CPA = 3
33
37
  MONTHLY_TENANCY = 4
@@ -37,12 +41,14 @@ module OpenX
37
41
  HIGH = 2
38
42
  EXCLUSIVE = 3
39
43
 
44
+ # Creates new Campaign for the given Advertiser.id required in params[:advertiser_id] or params[:advertiser]
40
45
  def initialize(params = {})
41
46
  raise ArgumentError.new("Missing advertiser_id") unless params[:advertiser_id] || params[:advertiser]
42
47
  params[:advertiser_id] ||= params[:advertiser].id
43
48
  super(params)
44
49
  end
45
50
 
51
+ # Return all banners for the Campaign
46
52
  def banners
47
53
  Banner.find(:all, self.id)
48
54
  end
@@ -1,6 +1,10 @@
1
1
  module OpenX
2
2
  module Services
3
3
  class Publisher < Base
4
+
5
+ require 'openx/services/statistics'
6
+ include OpenX::Services::Statistics
7
+
4
8
  openx_accessor :name => :publisherName,
5
9
  :contact_name => :contactName,
6
10
  :email => :emailAddress,
@@ -26,6 +30,18 @@ module OpenX
26
30
  def zones
27
31
  Zone.find(:all, self.id)
28
32
  end
33
+
34
+ # Returns statistics in Array of Hashes by day, which are: impression, clicks, requests and revenue.
35
+ def daily_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true
36
+ self.get_statistics('ox.publisherDailyStatistics', start_on, end_on, local_time_zone)
37
+ end
38
+
39
+ # Returns statistics in Array of Hashes by banner, which are: impression, clicks, requests and revenue.
40
+ # Also returns bannerName, bannerId, advertiserName, advertiserId, campaignName, campaignId
41
+ def banner_statistics start_on = Date.today, end_on = Date.today, local_time_zone = true
42
+ self.get_statistics('ox.publisherBannerStatistics', start_on, end_on, local_time_zone)
43
+ end
44
+
29
45
  end
30
46
  end
31
47
  end
@@ -0,0 +1,25 @@
1
+ module OpenX
2
+ module Services
3
+ module Statistics
4
+
5
+ # Generic method to get statistics.
6
+ # - +service_method+ - The name of the OpenX API service method to be called.
7
+ # - +start_on+ - When date range starts for stats request. OpenX parameter +oStartDate+ which ignores time part of it.
8
+ # - +end_on+ - When date range ends for stats request. OpenX parameter +oEndDate+ which ignores time part of it.
9
+ # - +local_time_zone+ - For v2 of OpenX API only which will respect the local Time Zone. OpenX parameter +localTZ+.
10
+ #
11
+ # With such generic method the gem is able to get any statistics available from the OpenX API,
12
+ # because all those statistics methods have the same call format.
13
+ def get_statistics service_method, start_on = Date.today, end_on = Date.today, local_time_zone = true
14
+ session = self.class.connection
15
+
16
+ # For compatibility with v1 of OpenX API.
17
+ if OpenX::Services::Base.configuration["url"].include?("/v1/")
18
+ @server.call(service_method, session, self.id, start_on, end_on)
19
+ else
20
+ @server.call(service_method, session, self.id, start_on, end_on, local_time_zone)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,6 +1,10 @@
1
1
  module OpenX
2
2
  module Services
3
3
  class Zone < Base
4
+
5
+ require 'openx/services/statistics'
6
+ include OpenX::Services::Statistics
7
+
4
8
  # Delivery types
5
9
  BANNER = 'delivery-b'
6
10
  INTERSTITIAL = 'delivery-i'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 4
9
- version: 1.1.4
8
+ - 6
9
+ version: 1.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Patterson
@@ -17,11 +17,11 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-04-18 00:00:00 +01:00
20
+ date: 2010-05-19 00:00:00 +01:00
21
21
  default_executable:
22
22
  dependencies: []
23
23
 
24
- description: A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/
24
+ description: A Ruby interface to the OpenX XML-RPC API. Used touchlocal 1.1.2 version as base for adding more API calls to OpenX API from http://developer.openx.org/api/ . It also works with v2 of OpenX API, especially that it now can pass localTZ to the OpenX API which will give back the correct statistics for the local time zone.
25
25
  email: jacobjp@mac.com
26
26
  executables: []
27
27
 
@@ -48,6 +48,7 @@ files:
48
48
  - lib/openx/services/campaign.rb
49
49
  - lib/openx/services/publisher.rb
50
50
  - lib/openx/services/session.rb
51
+ - lib/openx/services/statistics.rb
51
52
  - lib/openx/services/zone.rb
52
53
  - lib/openx/xmlrpc_client.rb
53
54
  - php/openx-2.8.1-keywords.diff