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'

Constants inherited from Base

Base::CONFIGURATION_YAML

Class Method Summary collapse

Instance Method Summary collapse

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', cookies = []
  url = "#{self.configuration['root']}/delivery/axmlrpc.php"
  server = XMLRPC::Client.new2(url)
  server.call('openads.view', {
    'cookies'     => 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 generate_tags(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 this zone to banner

Raises:

  • (ArgumentError)


72
73
74
75
76
77
78
79
# File 'lib/openx/services/zone.rb', line 72

def link_banner(banner)
  raise "Zone must be saved" if new_record?
  raise ArgumentError.new("Banner must be saved")if banner.new_record?

  session   = self.class.connection
  server    = XMLRPC::Client.new2("#{session.url}#{self.class.endpoint}")
  server.call("linkBanner", session.id, self.id, banner.id)
end

Link this zone to campaign

Raises:

  • (ArgumentError)


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 this zone from banner

Raises:

  • (ArgumentError)


82
83
84
85
86
87
88
89
# File 'lib/openx/services/zone.rb', line 82

def unlink_banner(banner)
  raise "Zone must be saved" if new_record?
  raise ArgumentError.new("Banner must be saved")if banner.new_record?

  session   = self.class.connection
  server    = XMLRPC::Client.new2("#{session.url}#{self.class.endpoint}")
  server.call("unlinkBanner", session.id, self.id, banner.id)
end

Unlink this zone from campaign

Raises:

  • (ArgumentError)


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