This commit is contained in:
Tyrel Souza 2014-05-02 16:55:27 -04:00
parent 242b2ab416
commit 93cdc5ef54
2 changed files with 15 additions and 1 deletions

View File

@ -27,7 +27,8 @@ class Campaign < ActiveRecord::Base
def to_bettervideo_format def to_bettervideo_format
campaign = self.as_json(include: :videolistings) campaign = self.as_json
campaign[:videolistings] = self.videolistings.all.map {|vl| vl.as_json }
campaigns = {campaigns: [campaign,], key: "PRO1234"} campaigns = {campaigns: [campaign,], key: "PRO1234"}
campaigns.to_json campaigns.to_json
end end

View File

@ -22,6 +22,19 @@ class Videolisting < ActiveRecord::Base
self.asseturls.split(',').collect { |url| { asseturl: url.strip } } self.asseturls.split(',').collect { |url| { asseturl: url.strip } }
end end
def as_json
{
assets: self.asseturls_array,
clientprovidedscript: self.clientprovidedscript,
musicselection: self.musicselection,
notes: self.notes,
producttypeid: 721,
toneofvideo: self.toneofvideo,
videocode: self.videocode,
voiceoverselection: self.voiceoverselection
}.as_json
end
private private
def set_videocode def set_videocode
self.videocode ||= SecureRandom.hex self.videocode ||= SecureRandom.hex