Class: OpenX::Services::Banner
- Defined in:
- lib/openx/services/banner.rb
Constant Summary collapse
- LOCAL_SQL =
'sql'
- LOCAL_WEB =
'web'
- EXTERNAL =
'url'
- HTML =
'html'
- TEXT =
'txt'
- RUNNING =
0
- PAUSED =
1
Constants inherited from Base
OpenX::Services::Base::CONFIGURATION_YAML
Class Method Summary collapse
Instance Method Summary collapse
-
#daily_statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
Returns statistics in Array of Hashes by day, which are: impressions, clicks, requests and revenue.
-
#initialize(params = {}) ⇒ Banner
constructor
A new instance of Banner.
-
#publisher_statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
Returns statistics in Array of Hashes by publisher, which are: impression, clicks, requests and revenue.
-
#statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
Alias for daily_statistics method to keep consistency with OpenX API calls Originally it was call for ox.bannerDailyStatistics so it is kept for compatibility with the previous version.
- #targeting ⇒ Object
- #targeting=(targeting) ⇒ Object
-
#zone_statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
Returns statistics in Array of Hashes by zone, which are: impression, clicks, requests, conversions and revenue.
Methods inherited from Base
#<=>, configuration, configuration=, connection, connection=, create!, destroy, #destroy, has_one, #new_record?, openx_accessor, #save!
Constructor Details
#initialize(params = {}) ⇒ Banner
Returns a new instance of Banner.
74 75 76 77 78 |
# File 'lib/openx/services/banner.rb', line 74 def initialize(params = {}) raise ArgumentError.new("Missing campaign_id") unless params[:campaign_id] || params[:campaign] params[:campaign_id] ||= params[:campaign].id super(params) end |
Class Method Details
.find(id, *args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/openx/services/banner.rb', line 16 def find(id, *args) session = self.connection server = XmlrpcClient.new2("#{session.url}") if id == :all responses = server.call(find_all(), session, *args) response = responses.first return [] unless response responses = [response] ### Annoying.. For some reason OpenX returns a linked list. ### Probably a bug.... while response.key?('aImage') response = response.delete('aImage') break unless response responses << response end responses.map { |response| new(translate(response)) } else response = server.call(find_one(), session, id) new(translate(response)) end end |
Instance Method Details
#daily_statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
Returns statistics in Array of Hashes by day, which are: impressions, clicks, requests and revenue. Each day is represented by XMLRPC::DateTime which has instant variables: @year, @month, @day, @hour, @min, @sec
89 90 91 92 |
# File 'lib/openx/services/banner.rb', line 89 def daily_statistics start_on = Date.today, end_on = Date.today session = self.class.connection @server.call('ox.bannerDailyStatistics', session, self.id, start_on, end_on) end |
#publisher_statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
Returns statistics in Array of Hashes by publisher, which are: impression, clicks, requests and revenue. Also returns publisherName and publisherId
96 97 98 99 |
# File 'lib/openx/services/banner.rb', line 96 def publisher_statistics start_on = Date.today, end_on = Date.today session = self.class.connection @server.call('ox.bannerPublisherStatistics', session, self.id, start_on, end_on) end |
#statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
Alias for daily_statistics method to keep consistency with OpenX API calls Originally it was call for ox.bannerDailyStatistics so it is kept for compatibility with the previous version
82 83 84 |
# File 'lib/openx/services/banner.rb', line 82 def statistics start_on = Date.today, end_on = Date.today daily_statistics start_on, end_on end |
#targeting ⇒ Object
108 109 110 111 |
# File 'lib/openx/services/banner.rb', line 108 def targeting session = self.class.connection @server.call('ox.getBannerTargeting', session, self.id) end |
#targeting=(targeting) ⇒ Object
113 114 115 116 |
# File 'lib/openx/services/banner.rb', line 113 def targeting= targeting session = self.class.connection @server.call('ox.setBannerTargeting', session, self.id, targeting) end |
#zone_statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
Returns statistics in Array of Hashes by zone, which are: impression, clicks, requests, conversions and revenue. Also returns publisherName, publisherId, zoneName, zoneId
103 104 105 106 |
# File 'lib/openx/services/banner.rb', line 103 def zone_statistics start_on = Date.today, end_on = Date.today session = self.class.connection @server.call('ox.bannerZoneStatistics', session, self.id, start_on, end_on) end |