Class: OpenX::Services::Zone

Inherits:
Base
  • Object
show all
Defined in:
lib/openx/services/zone.rb

Constant Summary collapse

'delivery-b'
INTERSTITIAL =
'delivery-i'
TEXT =
'delivery-t'
EMAIL =
'delivery-e'
JAVASCRIPT =

Tag Types

'adjs'
LOCAL =
'local'
IFRAME =
'adframe'
XMLRPC_TAG =
'xmlrpc'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#<=>, establish_connection, has_one, #new_record?, openx_accessor, remote, with_connection

Methods included from Persistance::ClassMethods

#create!, #destroy, #find

Methods included from Persistance::InstanceMethods

#destroy, #save!

Constructor Details

#initialize(params = {}) ⇒ Zone

Returns a new instance of Zone.



42
43
44
45
46
# File 'lib/openx/services/zone.rb', line 42

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, options = {}) ⇒ Object

Deliver zone_id to ip_address with cookies,



34
35
36
37
38
# File 'lib/openx/services/zone.rb', line 34

def deliver(zone_id, options = {})
  options = { 'ip_address' => '192.168.1.1', 'cookies' => [] }.update(options)
  server  = XmlrpcClient.new("#{connection.host}/delivery/axmlrpc.php")
  server.call('openads.view', options, "zone:#{zone_id}", 0, '', '', true, [])
end

Instance Method Details

#generate_tags(tag_type = IFRAME) ⇒ Object

Generate tags for displaying this zone using tag_type



77
78
79
# File 'lib/openx/services/zone.rb', line 77

def generate_tags(tag_type = IFRAME)
  remote.call("ox.generateTags", self.id, tag_type, [])
end

Link this zone to banner

Raises:

  • (ArgumentError)


63
64
65
66
67
# File 'lib/openx/services/zone.rb', line 63

def link_banner(banner)
  raise "Zone must be saved" if new_record?
  raise ArgumentError.new("Banner must be saved")if banner.new_record?
  remote.call("ox.linkBanner",  self.id, banner.id)
end

Link this zone to campaign

Raises:

  • (ArgumentError)


49
50
51
52
53
# File 'lib/openx/services/zone.rb', line 49

def link_campaign(campaign)
  raise "Zone must be saved" if new_record?
  raise ArgumentError.new("Campaign must be saved")if campaign.new_record?
  remote.call("ox.linkCampaign", self.id, campaign.id)
end

Unlink this zone from banner

Raises:

  • (ArgumentError)


70
71
72
73
74
# File 'lib/openx/services/zone.rb', line 70

def unlink_banner(banner)
  raise "Zone must be saved" if new_record?
  raise ArgumentError.new("Banner must be saved")if banner.new_record?
  remote.call("ox.unlinkBanner", self.id, banner.id)
end

Unlink this zone from campaign

Raises:

  • (ArgumentError)


56
57
58
59
60
# File 'lib/openx/services/zone.rb', line 56

def unlink_campaign(campaign)
  raise "Zone must be saved" if new_record?
  raise ArgumentError.new("Campaign must be saved")if campaign.new_record?
  remote.call("ox.unlinkCampaign", self.id, campaign.id)
end