Manos Chorianopoulos

add getLoyaltyBadge, update setCouponList

...@@ -14,6 +14,7 @@ public struct GlobalVariables { ...@@ -14,6 +14,7 @@ public struct GlobalVariables {
14 static var userTag: String = "" 14 static var userTag: String = ""
15 static var dfyCoupons: Array<swiftApi.ActiveDFYCouponModel> = [] 15 static var dfyCoupons: Array<swiftApi.ActiveDFYCouponModel> = []
16 static var couponList: Array<swiftApi.CouponItemModel> = [] 16 static var couponList: Array<swiftApi.CouponItemModel> = []
17 + static var loyaltyBadge: swiftApi.LoyaltyBadgeModel = swiftApi.LoyaltyBadgeModel()
17 } 18 }
18 19
19 public class swiftApi { 20 public class swiftApi {
...@@ -1748,6 +1749,15 @@ public class swiftApi { ...@@ -1748,6 +1749,15 @@ public class swiftApi {
1748 1749
1749 public func setCouponList(_ coupons: Array<CouponItemModel>) { 1750 public func setCouponList(_ coupons: Array<CouponItemModel>) {
1750 GlobalVariables.couponList = coupons 1751 GlobalVariables.couponList = coupons
1752 +
1753 + let loyaltyBadge = LoyaltyBadgeModel()
1754 +
1755 + let totalCouponDiscount = coupons.reduce(0) { $0 + (Float($1.discount ?? "") ?? 0) }
1756 +
1757 + loyaltyBadge._value = totalCouponDiscount
1758 + loyaltyBadge._couponCount = coupons.count
1759 +
1760 + GlobalVariables.loyaltyBadge = loyaltyBadge
1751 } 1761 }
1752 1762
1753 1763
...@@ -1755,4 +1765,9 @@ public class swiftApi { ...@@ -1755,4 +1765,9 @@ public class swiftApi {
1755 return GlobalVariables.couponList 1765 return GlobalVariables.couponList
1756 } 1766 }
1757 1767
1768 +
1769 + public func getLoyaltyBadge() -> LoyaltyBadgeModel {
1770 + return GlobalVariables.loyaltyBadge
1771 + }
1772 +
1758 } 1773 }
......