Showing
1 changed file
with
77 additions
and
5 deletions
... | @@ -2826,12 +2826,20 @@ public class swiftApi { | ... | @@ -2826,12 +2826,20 @@ public class swiftApi { |
2826 | func sharingCallback (_ sharingData: SharingResponseModel?) -> Void { | 2826 | func sharingCallback (_ sharingData: SharingResponseModel?) -> Void { |
2827 | if (sharingData != nil) { | 2827 | if (sharingData != nil) { |
2828 | DispatchQueue.main.async { | 2828 | DispatchQueue.main.async { |
2829 | + if (sharingData?._status_outer == 1) { | ||
2829 | if (sharingData?._status != nil && sharingData?._status != "" && sharingData?._status == "pending") { | 2830 | if (sharingData?._status != nil && sharingData?._status != "" && sharingData?._status == "pending") { |
2830 | self.initialSharingDialog(controller, sharingData?._modal_text ?? "", sharingId) | 2831 | self.initialSharingDialog(controller, sharingData?._modal_text ?? "", sharingId) |
2831 | 2832 | ||
2832 | } else if (sharingData?._status != nil && sharingData?._status != "" && sharingData?._status == "reject") { | 2833 | } else if (sharingData?._status != nil && sharingData?._status != "" && sharingData?._status == "reject") { |
2833 | self.returnSharingDialog(controller, sharingData?._modal_text ?? "") | 2834 | self.returnSharingDialog(controller, sharingData?._modal_text ?? "") |
2834 | } | 2835 | } |
2836 | + | ||
2837 | + } else if (sharingData?._status_outer == 4) { | ||
2838 | + self.errorExpiredDialog(controller) | ||
2839 | + | ||
2840 | + } else if (sharingData?._status_outer == 5) { | ||
2841 | + self.errorUsedDialog(controller) | ||
2842 | + } | ||
2835 | } | 2843 | } |
2836 | } else { // status != 1 | 2844 | } else { // status != 1 |
2837 | self.errorSharingDialog(controller) | 2845 | self.errorSharingDialog(controller) |
... | @@ -3013,6 +3021,44 @@ public class swiftApi { | ... | @@ -3013,6 +3021,44 @@ public class swiftApi { |
3013 | controller.present(alert, animated: true, completion: nil) | 3021 | controller.present(alert, animated: true, completion: nil) |
3014 | } | 3022 | } |
3015 | 3023 | ||
3024 | + func errorExpiredDialog(_ controller: UIViewController) -> Void { | ||
3025 | + | ||
3026 | + let alert = UIAlertController(title: "Αποτυχία", message: "Το δώρο έχει λήξει", preferredStyle: .alert) | ||
3027 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
3028 | + switch action.style{ | ||
3029 | + case .default: | ||
3030 | + print("default") | ||
3031 | + | ||
3032 | + case .cancel: | ||
3033 | + print("cancel") | ||
3034 | + | ||
3035 | + case .destructive: | ||
3036 | + print("destructive") | ||
3037 | + | ||
3038 | + } | ||
3039 | + })) | ||
3040 | + controller.present(alert, animated: true, completion: nil) | ||
3041 | + } | ||
3042 | + | ||
3043 | + func errorUsedDialog(_ controller: UIViewController) -> Void { | ||
3044 | + | ||
3045 | + let alert = UIAlertController(title: "Αποτυχία", message: "Το δώρο έχει ήδη χρησιμοποιηθεί", preferredStyle: .alert) | ||
3046 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
3047 | + switch action.style{ | ||
3048 | + case .default: | ||
3049 | + print("default") | ||
3050 | + | ||
3051 | + case .cancel: | ||
3052 | + print("cancel") | ||
3053 | + | ||
3054 | + case .destructive: | ||
3055 | + print("destructive") | ||
3056 | + | ||
3057 | + } | ||
3058 | + })) | ||
3059 | + controller.present(alert, animated: true, completion: nil) | ||
3060 | + } | ||
3061 | + | ||
3016 | 3062 | ||
3017 | public class LoyaltyGiftsForYouOfferClickEvent { | 3063 | public class LoyaltyGiftsForYouOfferClickEvent { |
3018 | private var title: String | 3064 | private var title: String |
... | @@ -3990,15 +4036,23 @@ public class swiftApi { | ... | @@ -3990,15 +4036,23 @@ public class swiftApi { |
3990 | public class SharingResponseModel { | 4036 | public class SharingResponseModel { |
3991 | private var modal_text: String | 4037 | private var modal_text: String |
3992 | private var status: String | 4038 | private var status: String |
4039 | + private var status_outer: Int | ||
4040 | + private var msg: String | ||
3993 | 4041 | ||
3994 | init() { | 4042 | init() { |
3995 | self.modal_text = "" | 4043 | self.modal_text = "" |
3996 | self.status = "" | 4044 | self.status = "" |
4045 | + self.status_outer = -1 | ||
4046 | + self.msg = "" | ||
3997 | } | 4047 | } |
3998 | 4048 | ||
3999 | init(dictionary: [String: Any]) { | 4049 | init(dictionary: [String: Any]) { |
4000 | - self.modal_text = dictionary["modal_text"] as? String ?? "" | 4050 | + let responseDataResult = (dictionary["result"] as? [String: Any] ?? [String: Any]()) |
4001 | - self.status = dictionary["status"] as? String ?? "" | 4051 | + self.modal_text = responseDataResult["modal_text"] as? String ?? "" |
4052 | + self.status = responseDataResult["status"] as? String ?? "" | ||
4053 | + | ||
4054 | + self.status_outer = dictionary["status"] as? Int ?? -1 | ||
4055 | + self.msg = dictionary["msg"] as? String ?? "" | ||
4002 | } | 4056 | } |
4003 | 4057 | ||
4004 | public var _modal_text: String { | 4058 | public var _modal_text: String { |
... | @@ -4018,6 +4072,24 @@ public class swiftApi { | ... | @@ -4018,6 +4072,24 @@ public class swiftApi { |
4018 | self.status = newValue | 4072 | self.status = newValue |
4019 | } | 4073 | } |
4020 | } | 4074 | } |
4075 | + | ||
4076 | + public var _status_outer: Int { | ||
4077 | + get { // getter | ||
4078 | + return self.status_outer | ||
4079 | + } | ||
4080 | + set(newValue) { //setter | ||
4081 | + self.status_outer = newValue | ||
4082 | + } | ||
4083 | + } | ||
4084 | + | ||
4085 | + public var _msg: String { | ||
4086 | + get { // getter | ||
4087 | + return self.msg | ||
4088 | + } | ||
4089 | + set(newValue) { //setter | ||
4090 | + self.msg = newValue | ||
4091 | + } | ||
4092 | + } | ||
4021 | } | 4093 | } |
4022 | 4094 | ||
4023 | 4095 | ||
... | @@ -4029,10 +4101,10 @@ public class swiftApi { | ... | @@ -4029,10 +4101,10 @@ public class swiftApi { |
4029 | func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void { | 4101 | func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void { |
4030 | 4102 | ||
4031 | if let responseDataDictionary = responseData as? [String: AnyObject] { | 4103 | if let responseDataDictionary = responseData as? [String: AnyObject] { |
4032 | - if (responseDataDictionary["status"] as? Int == 1) { | 4104 | + if ((responseDataDictionary["status"] as? Int == 1) || (responseDataDictionary["status"] as? Int == 4) || (responseDataDictionary["status"] as? Int == 5)) { |
4033 | - let responseDataResult = (responseDataDictionary["result"] as? [String: Any] ?? [String: Any]()) | 4105 | +// let responseDataResult = (responseDataDictionary["result"] as? [String: Any] ?? [String: Any]()) |
4034 | 4106 | ||
4035 | - let tempResponse = SharingResponseModel(dictionary: responseDataResult) | 4107 | + let tempResponse = SharingResponseModel(dictionary: responseDataDictionary) |
4036 | cosmoteSharingCallback(tempResponse); | 4108 | cosmoteSharingCallback(tempResponse); |
4037 | } else { | 4109 | } else { |
4038 | cosmoteSharingCallback(nil) | 4110 | cosmoteSharingCallback(nil) | ... | ... |
-
Please register or login to post a comment