Manos Chorianopoulos

add sorting to campaigns

......@@ -179,7 +179,7 @@ public class swiftApi {
self.description = dictionary["description"] as? String? ?? ""
self.short_description = dictionary["short_description"] as? String? ?? ""
self.discount = dictionary["discount"] as? String? ?? ""
self.sorting = dictionary["sorting"] as? Int? ?? nil
self.sorting = dictionary["sorting"] as? Int? ?? 0
self.inner_text = dictionary["inner_text"] as? String? ?? ""
self.buyable = dictionary["buyable"] as? Bool? ?? false
self.visible = dictionary["visible"] as? Bool? ?? false
......@@ -523,7 +523,7 @@ public class swiftApi {
// self.campaign_type_settings = [String: Any]()
self.couponset = ""
self.type = ""
self.sorting = nil
self.sorting = 0
}
public init(dictionary: [String: Any]) {
......@@ -537,7 +537,7 @@ public class swiftApi {
self.message = dictionary["message"] as? String? ?? ""
self.loyaltyPackageId = ""
self.campaign_type = dictionary["campaign_type"] as? String? ?? ""
self.sorting = dictionary["sorting"] as? Int? ?? nil
self.sorting = dictionary["sorting"] as? Int? ?? 0
// let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""]
if let extra_fields = dictionary["extra_fields"] as? [String: Any] {
......@@ -745,7 +745,12 @@ public class swiftApi {
return (!isCcmsOffer)
}
getCampaignsCallback(filteredCampaigns);
let sortedCampaigns = filteredCampaigns.sorted {
$0._sorting < $1._sorting
}
getCampaignsCallback(sortedCampaigns);
}
func campaignsFailureCallback(_ error: Error?) -> Void {
......@@ -810,7 +815,11 @@ public class swiftApi {
filteredCampaigns = filteredCampaigns.filter { $0.offer_category != "questionnaire" }
}
getCampaignsCallback(filteredCampaigns);
let sortedCampaigns = filteredCampaigns.sorted {
$0._sorting < $1._sorting
}
getCampaignsCallback(sortedCampaigns);
})
} else {
......@@ -2760,7 +2769,11 @@ public class swiftApi {
// }
// }
GlobalVariables.campaigns = campaigns
let sortedCampaigns = campaigns.sorted {
$0._sorting < $1._sorting
}
GlobalVariables.campaigns = sortedCampaigns
}
......@@ -2900,7 +2913,11 @@ public class swiftApi {
// }
// }
GlobalVariables.campaigns = campaigns
let sortedCampaigns = campaigns.sorted {
$0._sorting < $1._sorting
}
GlobalVariables.campaigns = sortedCampaigns
}
......