Class: Neuron::Client::Zone
Constant Summary
collapse
- ADS_BY_PRIORITY_TTL =
60
- REDIRECT =
"Redirect"
- IRIS =
"Iris"
- VAST =
"Vast"
- RESPONSE_TYPES =
[REDIRECT, IRIS, VAST]
- IRIS_2_0 =
'2_0'
- IRIS_2_5 =
'2_5'
- IRIS_VERSIONS =
[IRIS_2_0, IRIS_2_5]
- TEMPLATE_SLUGS =
['300x250']
- PLAYLIST_MODES =
['MAXI', 'MINI']
- PLAYBACK_MODE_OPTIONS =
[['Auto Play', 'AUTO'], ['Click To Play','CTP'], ['Rollover To Play', 'RTP']]
- PLAYBACK_MODES =
Hash[PLAYBACK_MODE_OPTIONS].values
- OVERLAY_PROVIDERS =
['NAMI', 'PREDICTV']
- ATTRIBUTES =
[
:id,
:ad_links,
:name,
:response_type, :template_slug, :channel, :expand, :iris_version, :mute, :autoplay, :playlist_mode, :volume, :color, :playback_mode, :overlay_provider, :overlay_feed_url,
:created_at, :updated_at, ]
- STATISTIC_TYPES =
{
'requests' => [],
'blocks' => ['reason'],
'defaults' => [],
'unitloads' => [],
'selections' => ['ad'],
'undeliveries' => ['ad'],
'impressions' => ['ad'],
'redirects' => ['ad'],
'clicks' => ['ad']
}
Instance Method Summary
collapse
#calculate_ads_by_priority
Methods included from Base
#apply_attributes!, #destroy, included, #initialize, #new_record?, #save, #to_create_hash, #to_hash, #to_update_hash, #update_attributes, #valid?
#all, #api=, #create, #create!, #find, #validate=
Instance Method Details
#ads_by_priority ⇒ Object
107
108
109
110
111
112
113
114
115
|
# File 'lib/neuron-client/model/zone.rb', line 107
def ads_by_priority
if connected_to_membase?
connection.fetch("Zone:#{id}:ads_by_priority", ADS_BY_PRIORITY_TTL) do
calculate_ads_by_priority
end
else
calculate_ads_by_priority
end
end
|
#attributes ⇒ Object
49
50
51
|
# File 'lib/neuron-client/model/zone.rb', line 49
def attributes
ATTRIBUTES
end
|
#find_ad(ad_id) ⇒ Object
57
58
59
|
# File 'lib/neuron-client/model/zone.rb', line 57
def find_ad(ad_id)
Ad.find(ad_id)
end
|
53
54
55
|
# File 'lib/neuron-client/model/zone.rb', line 53
def id=(id)
@id = id.to_s
end
|
#recent(statistic, parameters = {}) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/neuron-client/model/zone.rb', line 73
def recent(statistic, parameters={})
connected_to_admin!
by = (parameters[:by] || parameters['by']).to_s
minutes = parameters[:minutes] || parameters['minutes']
group_by = parameters[:group_by] || parameters['group_by']
parameters = {}
parameters['by'] = by unless by.blank?
parameters['minutes'] = minutes.to_i if minutes.to_i > 0
parameters['group_by'] = group_by.to_s unless group_by.blank?
if validate?
unless STATISTIC_TYPES.include?(statistic.to_s)
raise "Unsupported statistic: #{statistic}"
end
unless by.blank? || STATISTIC_TYPES[statistic.to_s].include?(by.to_s)
raise "Unsupported by: #{by}"
end
unless minutes.blank? || minutes.to_i > 0
raise "Unsupported minutes: #{minutes}"
end
unless group_by.blank? || group_by == 'hour'
raise "Unsupported group_by: #{group_by}"
end
end
connection.get("zones/#{id}/recent/#{statistic}", parameters)
end
|
#unlink(ad_id) ⇒ Object
100
101
102
103
104
105
|
# File 'lib/neuron-client/model/zone.rb', line 100
def unlink(ad_id)
connected_to_admin!
validate_id!(ad_id)
validate_uuid!(id)
connection.delete("zones/#{id}/ads/#{ad_id}")
end
|