func handleCarouselCampaign(campaign: EVGCampaign) {
var itemData: [Codable] = []
let recCampaignSubItem = CampaignItem(
titleText: campaign.data["RecItemTitle"] as! String,
titleSize: campaign.data["RecItemTitleFontSize"] as! String,
titleColor: campaign.data["RecItemTitleFontColor"] as! String,
titleAlign: campaign.data["RecItemTitleAlign"] as! String
)
let campObject = encodeJson(campData: recCampaignSubItem)
itemData.append( campObject )
let recitems: Array = campaign.data["RecItems"] as! Array<[String: Any]>
for recitem: [String: Any] in recitems {
let recommendItem = RecommendItem(
id: recitem["_id"] as! String,
name: recitem["name"] as! String,
imageUrl: recitem["imageUrl"] as! String,
price: "\(recitem["price"]!)"
)
let jsonObject = encodeJson(campData: recommendItem)
itemData.append( jsonObject )
}
carouselView = CarouselController(
webView: webView!,
webViewFile: "carousel",
campData: itemData
)
evergageScreen?.trackImpression(campaign)
if (!campaign.isControlGroup) {
NSLog("New active campaign name %@ for target %@ with data %@",
campaign.campaignName, campaign.target, campaign.data)
}
}