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'
Constants inherited from Base
OpenX::Services::Base::CONFIGURATION_YAML
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Banner
constructor
A new instance of Banner.
- #statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
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.
68 69 70 71 72 |
# File 'lib/openx/services/banner.rb', line 68 def initialize(params = {}) raise ArgumentError unless params[:campaign_id] || params[:campaign] params[:campaign_id] ||= params[:campaign].id super(params) end |
Class Method Details
.find(id, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/openx/services/banner.rb', line 13 def find(id, *args) session = self.connection server = XMLRPC::Client.new2("#{session.url}#{endpoint}") if id == :all responses = server.call(find_all(), session.id, *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, id) new(translate(response)) end end |
Instance Method Details
#statistics(start_on = Date.today, end_on = Date.today) ⇒ Object
74 75 76 77 |
# File 'lib/openx/services/banner.rb', line 74 def statistics start_on = Date.today, end_on = Date.today session = self.class.connection @server.call('bannerDailyStatistics', session.id, self.id, start_on, end_on) end |