Manos Chorianopoulos

fix cosmoteSharingAsync callback

......@@ -2826,11 +2826,19 @@ public class swiftApi {
func sharingCallback (_ sharingData: SharingResponseModel?) -> Void {
if (sharingData != nil) {
DispatchQueue.main.async {
if (sharingData?._status != nil && sharingData?._status != "" && sharingData?._status == "pending") {
self.initialSharingDialog(controller, sharingData?._modal_text ?? "", sharingId)
if (sharingData?._status_outer == 1) {
if (sharingData?._status != nil && sharingData?._status != "" && sharingData?._status == "pending") {
self.initialSharingDialog(controller, sharingData?._modal_text ?? "", sharingId)
} else if (sharingData?._status != nil && sharingData?._status != "" && sharingData?._status == "reject") {
self.returnSharingDialog(controller, sharingData?._modal_text ?? "")
}
} else if (sharingData?._status != nil && sharingData?._status != "" && sharingData?._status == "reject") {
self.returnSharingDialog(controller, sharingData?._modal_text ?? "")
} else if (sharingData?._status_outer == 4) {
self.errorExpiredDialog(controller)
} else if (sharingData?._status_outer == 5) {
self.errorUsedDialog(controller)
}
}
} else { // status != 1
......@@ -3013,6 +3021,44 @@ public class swiftApi {
controller.present(alert, animated: true, completion: nil)
}
func errorExpiredDialog(_ controller: UIViewController) -> Void {
let alert = UIAlertController(title: "Αποτυχία", message: "Το δώρο έχει λήξει", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
controller.present(alert, animated: true, completion: nil)
}
func errorUsedDialog(_ controller: UIViewController) -> Void {
let alert = UIAlertController(title: "Αποτυχία", message: "Το δώρο έχει ήδη χρησιμοποιηθεί", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
controller.present(alert, animated: true, completion: nil)
}
public class LoyaltyGiftsForYouOfferClickEvent {
private var title: String
......@@ -3990,15 +4036,23 @@ public class swiftApi {
public class SharingResponseModel {
private var modal_text: String
private var status: String
private var status_outer: Int
private var msg: String
init() {
self.modal_text = ""
self.status = ""
self.status_outer = -1
self.msg = ""
}
init(dictionary: [String: Any]) {
self.modal_text = dictionary["modal_text"] as? String ?? ""
self.status = dictionary["status"] as? String ?? ""
let responseDataResult = (dictionary["result"] as? [String: Any] ?? [String: Any]())
self.modal_text = responseDataResult["modal_text"] as? String ?? ""
self.status = responseDataResult["status"] as? String ?? ""
self.status_outer = dictionary["status"] as? Int ?? -1
self.msg = dictionary["msg"] as? String ?? ""
}
public var _modal_text: String {
......@@ -4018,6 +4072,24 @@ public class swiftApi {
self.status = newValue
}
}
public var _status_outer: Int {
get { // getter
return self.status_outer
}
set(newValue) { //setter
self.status_outer = newValue
}
}
public var _msg: String {
get { // getter
return self.msg
}
set(newValue) { //setter
self.msg = newValue
}
}
}
......@@ -4029,10 +4101,10 @@ public class swiftApi {
func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void {
if let responseDataDictionary = responseData as? [String: AnyObject] {
if (responseDataDictionary["status"] as? Int == 1) {
let responseDataResult = (responseDataDictionary["result"] as? [String: Any] ?? [String: Any]())
if ((responseDataDictionary["status"] as? Int == 1) || (responseDataDictionary["status"] as? Int == 4) || (responseDataDictionary["status"] as? Int == 5)) {
// let responseDataResult = (responseDataDictionary["result"] as? [String: Any] ?? [String: Any]())
let tempResponse = SharingResponseModel(dictionary: responseDataResult)
let tempResponse = SharingResponseModel(dictionary: responseDataDictionary)
cosmoteSharingCallback(tempResponse);
} else {
cosmoteSharingCallback(nil)
......