Manos Chorianopoulos

add getLoyaltyBadge, update setCouponList

......@@ -14,6 +14,7 @@ public struct GlobalVariables {
static var userTag: String = ""
static var dfyCoupons: Array<swiftApi.ActiveDFYCouponModel> = []
static var couponList: Array<swiftApi.CouponItemModel> = []
static var loyaltyBadge: swiftApi.LoyaltyBadgeModel = swiftApi.LoyaltyBadgeModel()
}
public class swiftApi {
......@@ -1748,6 +1749,15 @@ public class swiftApi {
public func setCouponList(_ coupons: Array<CouponItemModel>) {
GlobalVariables.couponList = coupons
let loyaltyBadge = LoyaltyBadgeModel()
let totalCouponDiscount = coupons.reduce(0) { $0 + (Float($1.discount ?? "") ?? 0) }
loyaltyBadge._value = totalCouponDiscount
loyaltyBadge._couponCount = coupons.count
GlobalVariables.loyaltyBadge = loyaltyBadge
}
......@@ -1755,4 +1765,9 @@ public class swiftApi {
return GlobalVariables.couponList
}
public func getLoyaltyBadge() -> LoyaltyBadgeModel {
return GlobalVariables.loyaltyBadge
}
}
......