Initial commit
This commit is contained in:
37
app/services/vendors/vistar/vistar_fetch_schedule.rb
vendored
Normal file
37
app/services/vendors/vistar/vistar_fetch_schedule.rb
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
module Vendors
|
||||
module Vistar
|
||||
class VistarFetchSchedule
|
||||
def initialize(tokens)
|
||||
@tokens = tokens
|
||||
end
|
||||
|
||||
def call(params)
|
||||
fetch = fetch_ad(params)
|
||||
return nil unless fetch && fetch[:advertisement]
|
||||
|
||||
ad = fetch[:advertisement][0]
|
||||
{
|
||||
contents: [
|
||||
{
|
||||
name: "vistar_asset_#{ad[:asset_id]}",
|
||||
url: ad[:asset_url]
|
||||
}
|
||||
],
|
||||
startTime: Time.at(ad[:display_time]).to_datetime,
|
||||
items: [
|
||||
{
|
||||
contentIndex: 0,
|
||||
duration: "#{ad[:length_in_seconds]}s",
|
||||
pop_url: ad[:proof_of_play_url]
|
||||
}
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
def fetch_ad(params)
|
||||
Vendors::Vistar::VistarFetchAd.new(@tokens).call(params)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user