Manos Chorianopoulos

fix coupon discount type

......@@ -42,7 +42,7 @@ import UIKit
func configureCell(coupon: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
......@@ -62,7 +62,11 @@ import UIKit
// couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
// nameLabel.text = couponSetData?.name ?? ""
dicountLabel.text = (coupon.discount ?? "") + "€"
let discount = couponSetData?.discount_type == "value" ? ((coupon.discount ?? "") + "€")
: couponSetData?.discount_type == "percentage" ? ((coupon.discount ?? "") + "%")
: couponSetData?.discount_type == "plus_one" ? "1+1"
: ((coupon.discount ?? "") + "€")
dicountLabel.text = discount
let htmlText = couponSetData?.inner_text ?? ""
discriptionLabel.text = htmlText.htmlToString
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
......
......@@ -425,6 +425,8 @@ public class swiftApi {
public let visible: Bool?
public let terms: String?
public let merchant_uuid: String?
public let discount_type: String? // "value" / "percentage" / "plus_one"
public let final_price: Float?
public init(dictionary: [String: Any]) {
self.uuid = dictionary["uuid"] as? String? ?? ""
......@@ -440,6 +442,8 @@ public class swiftApi {
self.visible = dictionary["visible"] as? Bool? ?? false
self.terms = dictionary["terms"] as? String? ?? ""
self.merchant_uuid = dictionary["merchant_uuid"] as? String? ?? ""
self.discount_type = dictionary["discount_type"] as? String? ?? ""
self.final_price = dictionary["final_price"] as? Float? ?? 0.0
let expirationObject = dictionary["expiration"] as? [String: Any]? ?? ["":""]
let expirationString = expirationObject?["value"] as? String? ?? ""
......