Class: OpenX::Services::Zone
Constant Summary collapse
- BANNER =
Delivery types
'delivery-b'
- INTERSTITIAL =
'delivery-i'
- TEXT =
'delivery-t'
- EMAIL =
'delivery-e'
- JAVASCRIPT =
Tag Types
'adjs'
- LOCAL =
'local'
- IFRAME =
'adframe'
- XMLRPC_TAG =
'xmlrpc'
Constants inherited from Base
Class Method Summary collapse
-
.deliver(zone_id, ip_address = '192.168.1.1', cookies = []) ⇒ Object
Deliver
zone_id
toip_address
withcookies
,.
Instance Method Summary collapse
-
#generate_tags(tag_type = IFRAME) ⇒ Object
Generate tags for displaying this zone using
tag_type
. -
#initialize(params = {}) ⇒ Zone
constructor
A new instance of Zone.
-
#link_banner(banner) ⇒ Object
Link this zone to
banner
. -
#link_campaign(campaign) ⇒ Object
Link this zone to
campaign
. -
#unlink_banner(banner) ⇒ Object
Unlink this zone from
banner
. -
#unlink_campaign(campaign) ⇒ Object
Unlink this zone from
campaign
.
Methods inherited from Base
#<=>, configuration, configuration=, connection, connection=, create!, destroy, #destroy, find, has_one, #new_record?, openx_accessor, #save!
Constructor Details
#initialize(params = {}) ⇒ Zone
Returns a new instance of Zone.
45 46 47 48 49 |
# File 'lib/openx/services/zone.rb', line 45 def initialize(params = {}) raise "need publisher" unless params[:publisher_id] || params[:publisher] params[:publisher_id] ||= params[:publisher].id super(params) end |
Class Method Details
.deliver(zone_id, ip_address = '192.168.1.1', cookies = []) ⇒ Object
Deliver zone_id
to ip_address
with cookies
,
35 36 37 38 39 40 41 42 |
# File 'lib/openx/services/zone.rb', line 35 def deliver zone_id, ip_address = '192.168.1.1', = [] url = "#{self.configuration['root']}/delivery/axmlrpc.php" server = XMLRPC::Client.new2(url) server.call('openads.view', { 'cookies' => , 'remote_addr' => ip_address, }, "zone:#{zone_id}", 0, '', '', true, []) end |
Instance Method Details
#generate_tags(tag_type = IFRAME) ⇒ Object
Generate tags for displaying this zone using tag_type
92 93 94 95 96 |
# File 'lib/openx/services/zone.rb', line 92 def (tag_type = IFRAME) session = self.class.connection server = XMLRPC::Client.new2("#{session.url}#{self.class.endpoint}") server.call("generateTags", session.id, self.id, tag_type, []) end |
#link_banner(banner) ⇒ Object
Link this zone to banner
72 73 74 75 76 77 78 79 |
# File 'lib/openx/services/zone.rb', line 72 def () raise "Zone must be saved" if new_record? raise ArgumentError.new("Banner must be saved")if .new_record? session = self.class.connection server = XMLRPC::Client.new2("#{session.url}#{self.class.endpoint}") server.call("linkBanner", session.id, self.id, .id) end |
#link_campaign(campaign) ⇒ Object
Link this zone to campaign
52 53 54 55 56 57 58 59 |
# File 'lib/openx/services/zone.rb', line 52 def link_campaign(campaign) raise "Zone must be saved" if new_record? raise ArgumentError.new("Campaign must be saved")if campaign.new_record? session = self.class.connection server = XMLRPC::Client.new2("#{session.url}#{self.class.endpoint}") server.call("linkCampaign", session.id, self.id, campaign.id) end |
#unlink_banner(banner) ⇒ Object
Unlink this zone from banner
82 83 84 85 86 87 88 89 |
# File 'lib/openx/services/zone.rb', line 82 def () raise "Zone must be saved" if new_record? raise ArgumentError.new("Banner must be saved")if .new_record? session = self.class.connection server = XMLRPC::Client.new2("#{session.url}#{self.class.endpoint}") server.call("unlinkBanner", session.id, self.id, .id) end |
#unlink_campaign(campaign) ⇒ Object
Unlink this zone from campaign
62 63 64 65 66 67 68 69 |
# File 'lib/openx/services/zone.rb', line 62 def unlink_campaign(campaign) raise "Zone must be saved" if new_record? raise ArgumentError.new("Campaign must be saved")if campaign.new_record? session = self.class.connection server = XMLRPC::Client.new2("#{session.url}#{self.class.endpoint}") server.call("unlinkCampaign", session.id, self.id, campaign.id) end |