Manos Chorianopoulos

add redeemed_merchant_details at CouponItemModel

......@@ -2730,7 +2730,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
NSMutableDictionary* couponDictionary = [[NSMutableDictionary alloc] init];
[couponDictionary setValue:@"user_coupons" forKey:@"action"];
[couponDictionary setValue:@[@"merchant"] forKey:@"details"];
[couponDictionary setValue:@[@"merchant", @"redemption"] forKey:@"details"];
[couponDictionary setValue:language forKey:@"language"];
if ([couponsetType isEqual: @"supermarket"]) {
[couponDictionary setValue:@[@"supermarket"] forKey:@"couponset_types"];
......
......@@ -850,6 +850,7 @@ public class swiftApi {
// Universal Coupons
public var merchant_details: MerchantModel?
public var redeemed_merchant_details: RedeemedMerchantDetailsModel?
public init(dictionary: [String: Any]) {
......@@ -911,6 +912,15 @@ public class swiftApi {
} else {
self.merchant_details = nil
}
if let redeemedMerchantDetails = dictionary["redeemed_merchant_details"] as? [String: Any] {
let tempRedeemedMerchantDetails = RedeemedMerchantDetailsModel(dictionary: redeemedMerchantDetails)
self.redeemed_merchant_details = tempRedeemedMerchantDetails
} else {
self.redeemed_merchant_details = nil
}
// <==
......@@ -9608,4 +9618,102 @@ public class swiftApi {
}
}
/*
{
"img_preview" = "<null>";
name = "<null>";
"redeemed_date" = "<null>";
uuid = "<null>";
}
*/
public class RedeemedMerchantDetailsModel: Codable {
private var img_preview: String?
private var name: String?
private var uuid: String?
private var redeemed_date: Date?
private var redeemed_date_string: String?
public init() {
self.img_preview = ""
self.name = ""
self.uuid = ""
self.redeemed_date = Date()
self.redeemed_date_string = ""
}
public init(dictionary: [String: Any]) {
self.img_preview = dictionary["img_preview"] as? String? ?? ""
self.name = dictionary["name"] as? String? ?? ""
self.uuid = dictionary["uuid"] as? String? ?? ""
if let redeemedString = dictionary["redeemed_date"] as? String {
// Example "redeemed_date" = "2024-07-02T10:50:03.04416";
let dateFormatter4 = DateFormatter()
// dateFormatter4.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSSS"
dateFormatter4.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSS"
if let date = dateFormatter4.date(from: redeemedString ?? "") {
self.redeemed_date = date
dateFormatter4.dateFormat = "dd/MM/yyyy"
let resultString = dateFormatter4.string(from: date)
self.redeemed_date_string = resultString
} else {
self.redeemed_date = Date()
self.redeemed_date_string = ""
}
} else {
self.redeemed_date = Date()
self.redeemed_date_string = ""
}
}
public var _img_preview: String {
get { // getter
return self.img_preview ?? ""
}
set(newValue) { //setter
self.img_preview = newValue
}
}
public var _name: String {
get { // getter
return self.name ?? ""
}
set(newValue) { //setter
self.name = newValue
}
}
public var _uuid: String {
get { // getter
return self.uuid ?? ""
}
set(newValue) { //setter
self.uuid = newValue
}
}
public var _redeemed_date: Date {
get { // getter
return self.redeemed_date ?? Date()
}
set(newValue) { //setter
self.redeemed_date = newValue
}
}
public var _redeemed_date_string: String {
get { // getter
return self.redeemed_date_string ?? ""
}
set(newValue) { //setter
self.redeemed_date_string = newValue
}
}
}
}
......