Manos Chorianopoulos

add redeemed_merchant_details at CouponItemModel

...@@ -2730,7 +2730,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -2730,7 +2730,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
2730 2730
2731 NSMutableDictionary* couponDictionary = [[NSMutableDictionary alloc] init]; 2731 NSMutableDictionary* couponDictionary = [[NSMutableDictionary alloc] init];
2732 [couponDictionary setValue:@"user_coupons" forKey:@"action"]; 2732 [couponDictionary setValue:@"user_coupons" forKey:@"action"];
2733 - [couponDictionary setValue:@[@"merchant"] forKey:@"details"]; 2733 + [couponDictionary setValue:@[@"merchant", @"redemption"] forKey:@"details"];
2734 [couponDictionary setValue:language forKey:@"language"]; 2734 [couponDictionary setValue:language forKey:@"language"];
2735 if ([couponsetType isEqual: @"supermarket"]) { 2735 if ([couponsetType isEqual: @"supermarket"]) {
2736 [couponDictionary setValue:@[@"supermarket"] forKey:@"couponset_types"]; 2736 [couponDictionary setValue:@[@"supermarket"] forKey:@"couponset_types"];
......
...@@ -850,6 +850,7 @@ public class swiftApi { ...@@ -850,6 +850,7 @@ public class swiftApi {
850 850
851 // Universal Coupons 851 // Universal Coupons
852 public var merchant_details: MerchantModel? 852 public var merchant_details: MerchantModel?
853 + public var redeemed_merchant_details: RedeemedMerchantDetailsModel?
853 854
854 855
855 public init(dictionary: [String: Any]) { 856 public init(dictionary: [String: Any]) {
...@@ -911,6 +912,15 @@ public class swiftApi { ...@@ -911,6 +912,15 @@ public class swiftApi {
911 } else { 912 } else {
912 self.merchant_details = nil 913 self.merchant_details = nil
913 } 914 }
915 +
916 + if let redeemedMerchantDetails = dictionary["redeemed_merchant_details"] as? [String: Any] {
917 +
918 + let tempRedeemedMerchantDetails = RedeemedMerchantDetailsModel(dictionary: redeemedMerchantDetails)
919 +
920 + self.redeemed_merchant_details = tempRedeemedMerchantDetails
921 + } else {
922 + self.redeemed_merchant_details = nil
923 + }
914 // <== 924 // <==
915 925
916 926
...@@ -9608,4 +9618,102 @@ public class swiftApi { ...@@ -9608,4 +9618,102 @@ public class swiftApi {
9608 } 9618 }
9609 } 9619 }
9610 9620
9621 +
9622 + /*
9623 + {
9624 + "img_preview" = "<null>";
9625 + name = "<null>";
9626 + "redeemed_date" = "<null>";
9627 + uuid = "<null>";
9628 + }
9629 + */
9630 + public class RedeemedMerchantDetailsModel: Codable {
9631 + private var img_preview: String?
9632 + private var name: String?
9633 + private var uuid: String?
9634 + private var redeemed_date: Date?
9635 + private var redeemed_date_string: String?
9636 +
9637 + public init() {
9638 + self.img_preview = ""
9639 + self.name = ""
9640 + self.uuid = ""
9641 + self.redeemed_date = Date()
9642 + self.redeemed_date_string = ""
9643 + }
9644 +
9645 + public init(dictionary: [String: Any]) {
9646 + self.img_preview = dictionary["img_preview"] as? String? ?? ""
9647 + self.name = dictionary["name"] as? String? ?? ""
9648 + self.uuid = dictionary["uuid"] as? String? ?? ""
9649 +
9650 + if let redeemedString = dictionary["redeemed_date"] as? String {
9651 + // Example "redeemed_date" = "2024-07-02T10:50:03.04416";
9652 +
9653 + let dateFormatter4 = DateFormatter()
9654 + // dateFormatter4.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSSS"
9655 + dateFormatter4.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSS"
9656 + if let date = dateFormatter4.date(from: redeemedString ?? "") {
9657 + self.redeemed_date = date
9658 + dateFormatter4.dateFormat = "dd/MM/yyyy"
9659 + let resultString = dateFormatter4.string(from: date)
9660 + self.redeemed_date_string = resultString
9661 + } else {
9662 + self.redeemed_date = Date()
9663 + self.redeemed_date_string = ""
9664 + }
9665 +
9666 + } else {
9667 + self.redeemed_date = Date()
9668 + self.redeemed_date_string = ""
9669 + }
9670 + }
9671 +
9672 + public var _img_preview: String {
9673 + get { // getter
9674 + return self.img_preview ?? ""
9675 + }
9676 + set(newValue) { //setter
9677 + self.img_preview = newValue
9678 + }
9679 + }
9680 +
9681 + public var _name: String {
9682 + get { // getter
9683 + return self.name ?? ""
9684 + }
9685 + set(newValue) { //setter
9686 + self.name = newValue
9687 + }
9688 + }
9689 +
9690 + public var _uuid: String {
9691 + get { // getter
9692 + return self.uuid ?? ""
9693 + }
9694 + set(newValue) { //setter
9695 + self.uuid = newValue
9696 + }
9697 + }
9698 +
9699 + public var _redeemed_date: Date {
9700 + get { // getter
9701 + return self.redeemed_date ?? Date()
9702 + }
9703 + set(newValue) { //setter
9704 + self.redeemed_date = newValue
9705 + }
9706 + }
9707 +
9708 + public var _redeemed_date_string: String {
9709 + get { // getter
9710 + return self.redeemed_date_string ?? ""
9711 + }
9712 + set(newValue) { //setter
9713 + self.redeemed_date_string = newValue
9714 + }
9715 + }
9716 +
9717 + }
9718 +
9611 } 9719 }
......