Manos Chorianopoulos

add cancelUnifiedCoupon functionality

...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -3479,14 +3479,14 @@ ...@@ -3479,14 +3479,14 @@
3479 </connections> 3479 </connections>
3480 </tableViewCell> 3480 </tableViewCell>
3481 <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="UnifiedCouponBCFooterTableViewCell" id="LD5-ES-J67" customClass="UnifiedCouponBCFooterTableViewCell" customModule="SwiftWarplyFramework"> 3481 <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="UnifiedCouponBCFooterTableViewCell" id="LD5-ES-J67" customClass="UnifiedCouponBCFooterTableViewCell" customModule="SwiftWarplyFramework">
3482 - <rect key="frame" x="0.0" y="935.5" width="414" height="160"/> 3482 + <rect key="frame" x="0.0" y="935.5" width="414" height="220"/>
3483 <autoresizingMask key="autoresizingMask"/> 3483 <autoresizingMask key="autoresizingMask"/>
3484 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="LD5-ES-J67" id="DmN-AA-8n5"> 3484 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="LD5-ES-J67" id="DmN-AA-8n5">
3485 - <rect key="frame" x="0.0" y="0.0" width="414" height="160"/> 3485 + <rect key="frame" x="0.0" y="0.0" width="414" height="220"/>
3486 <autoresizingMask key="autoresizingMask"/> 3486 <autoresizingMask key="autoresizingMask"/>
3487 <subviews> 3487 <subviews>
3488 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="L4W-1e-9fQ"> 3488 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="L4W-1e-9fQ">
3489 - <rect key="frame" x="0.0" y="0.0" width="414" height="160"/> 3489 + <rect key="frame" x="0.0" y="0.0" width="414" height="220"/>
3490 <subviews> 3490 <subviews>
3491 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Kdi-w7-eKZ"> 3491 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Kdi-w7-eKZ">
3492 <rect key="frame" x="123.5" y="20" width="167" height="50"/> 3492 <rect key="frame" x="123.5" y="20" width="167" height="50"/>
...@@ -3502,8 +3502,22 @@ ...@@ -3502,8 +3502,22 @@
3502 <action selector="mapButtonAction:" destination="kZo-uj-MVp" eventType="touchUpInside" id="jm9-HG-8Sd"/> 3502 <action selector="mapButtonAction:" destination="kZo-uj-MVp" eventType="touchUpInside" id="jm9-HG-8Sd"/>
3503 </connections> 3503 </connections>
3504 </button> 3504 </button>
3505 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BrE-JO-TPr">
3506 + <rect key="frame" x="91" y="80" width="232" height="50"/>
3507 + <constraints>
3508 + <constraint firstAttribute="height" constant="50" id="NrC-VW-t5Y"/>
3509 + </constraints>
3510 + <fontDescription key="fontDescription" name="PeridotPE-Bold" family="Peridot PE" pointSize="17"/>
3511 + <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
3512 + <state key="normal" title="Ακύρωση ενιαίου κουπονιού">
3513 + <color key="titleColor" red="0.054901960780000002" green="0.65098039220000004" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
3514 + </state>
3515 + <connections>
3516 + <action selector="cancelButtonAction:" destination="kZo-uj-MVp" eventType="touchUpInside" id="4mm-Dp-2gO"/>
3517 + </connections>
3518 + </button>
3505 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Sq7-ea-Nx2"> 3519 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Sq7-ea-Nx2">
3506 - <rect key="frame" x="103.5" y="90" width="207" height="40"/> 3520 + <rect key="frame" x="103.5" y="150" width="207" height="40"/>
3507 <constraints> 3521 <constraints>
3508 <constraint firstAttribute="height" constant="40" id="UgG-aB-OOw"/> 3522 <constraint firstAttribute="height" constant="40" id="UgG-aB-OOw"/>
3509 </constraints> 3523 </constraints>
...@@ -3518,7 +3532,7 @@ ...@@ -3518,7 +3532,7 @@
3518 </connections> 3532 </connections>
3519 </button> 3533 </button>
3520 <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kkr-9H-ZSx" customClass="UnselectableTappableTextView" customModule="SwiftWarplyFramework"> 3534 <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="center" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kkr-9H-ZSx" customClass="UnselectableTappableTextView" customModule="SwiftWarplyFramework">
3521 - <rect key="frame" x="20" y="130" width="374" height="0.0"/> 3535 + <rect key="frame" x="20" y="190" width="374" height="0.0"/>
3522 <color key="backgroundColor" systemColor="systemBackgroundColor"/> 3536 <color key="backgroundColor" systemColor="systemBackgroundColor"/>
3523 <constraints> 3537 <constraints>
3524 <constraint firstAttribute="height" id="oLt-F6-WA7"/> 3538 <constraint firstAttribute="height" id="oLt-F6-WA7"/>
...@@ -3531,9 +3545,11 @@ ...@@ -3531,9 +3545,11 @@
3531 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> 3545 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
3532 <constraints> 3546 <constraints>
3533 <constraint firstItem="Kdi-w7-eKZ" firstAttribute="top" secondItem="L4W-1e-9fQ" secondAttribute="top" constant="20" id="1IM-rZ-u2k"/> 3547 <constraint firstItem="Kdi-w7-eKZ" firstAttribute="top" secondItem="L4W-1e-9fQ" secondAttribute="top" constant="20" id="1IM-rZ-u2k"/>
3534 - <constraint firstItem="Sq7-ea-Nx2" firstAttribute="top" secondItem="Kdi-w7-eKZ" secondAttribute="bottom" constant="20" id="1Qv-cX-6D8"/> 3548 + <constraint firstItem="Sq7-ea-Nx2" firstAttribute="top" secondItem="BrE-JO-TPr" secondAttribute="bottom" constant="20" id="1Qv-cX-6D8"/>
3535 <constraint firstItem="Kkr-9H-ZSx" firstAttribute="leading" secondItem="L4W-1e-9fQ" secondAttribute="leading" constant="20" id="7pl-xk-jHX"/> 3549 <constraint firstItem="Kkr-9H-ZSx" firstAttribute="leading" secondItem="L4W-1e-9fQ" secondAttribute="leading" constant="20" id="7pl-xk-jHX"/>
3536 <constraint firstAttribute="trailing" secondItem="Kkr-9H-ZSx" secondAttribute="trailing" constant="20" id="VBo-Kj-h0s"/> 3550 <constraint firstAttribute="trailing" secondItem="Kkr-9H-ZSx" secondAttribute="trailing" constant="20" id="VBo-Kj-h0s"/>
3551 + <constraint firstItem="BrE-JO-TPr" firstAttribute="centerX" secondItem="L4W-1e-9fQ" secondAttribute="centerX" id="bW8-3Y-oqb"/>
3552 + <constraint firstItem="BrE-JO-TPr" firstAttribute="top" secondItem="Kdi-w7-eKZ" secondAttribute="bottom" constant="10" id="dEo-5F-kZg"/>
3537 <constraint firstItem="Kkr-9H-ZSx" firstAttribute="top" secondItem="Sq7-ea-Nx2" secondAttribute="bottom" id="jsT-BU-52c"/> 3553 <constraint firstItem="Kkr-9H-ZSx" firstAttribute="top" secondItem="Sq7-ea-Nx2" secondAttribute="bottom" id="jsT-BU-52c"/>
3538 <constraint firstItem="Sq7-ea-Nx2" firstAttribute="width" secondItem="L4W-1e-9fQ" secondAttribute="width" multiplier="0.5" id="ljh-1k-pkA"/> 3554 <constraint firstItem="Sq7-ea-Nx2" firstAttribute="width" secondItem="L4W-1e-9fQ" secondAttribute="width" multiplier="0.5" id="ljh-1k-pkA"/>
3539 <constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="Sq7-ea-Nx2" secondAttribute="bottom" constant="30" id="nmp-6u-Pr6"/> 3555 <constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="Sq7-ea-Nx2" secondAttribute="bottom" constant="30" id="nmp-6u-Pr6"/>
...@@ -3553,6 +3569,7 @@ ...@@ -3553,6 +3569,7 @@
3553 </tableViewCellContentView> 3569 </tableViewCellContentView>
3554 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> 3570 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
3555 <connections> 3571 <connections>
3572 + <outlet property="cancelButton" destination="BrE-JO-TPr" id="fJv-84-jmi"/>
3556 <outlet property="mapButton" destination="Kdi-w7-eKZ" id="DIH-nr-baa"/> 3573 <outlet property="mapButton" destination="Kdi-w7-eKZ" id="DIH-nr-baa"/>
3557 <outlet property="mapButtonHeight" destination="SUG-HC-XQH" id="GRr-Cz-ZUP"/> 3574 <outlet property="mapButtonHeight" destination="SUG-HC-XQH" id="GRr-Cz-ZUP"/>
3558 <outlet property="mapButtonTopSpace" destination="1IM-rZ-u2k" id="Maj-hs-eqg"/> 3575 <outlet property="mapButtonTopSpace" destination="1IM-rZ-u2k" id="Maj-hs-eqg"/>
......
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
83 - (void)getUnifiedCouponsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 83 - (void)getUnifiedCouponsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
84 - (void)getCouponsetsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 84 - (void)getCouponsetsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
85 - (void)getCouponsetsDealsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 85 - (void)getCouponsetsDealsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
86 +- (void) cancelUnifiedCouponAsync:(NSString*) transactionId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
86 - (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; 87 - (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure;
87 - (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 88 - (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
88 - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 89 - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
...@@ -1490,6 +1490,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; ...@@ -1490,6 +1490,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
1490 }]; 1490 }];
1491 } 1491 }
1492 1492
1493 +- (void) cancelUnifiedCouponAsync:(NSString*) transactionId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
1494 +{
1495 + [[Warply sharedService] cancelUnifiedCouponWithSuccessBlock:transactionId :^(NSDictionary *response) {
1496 + if (success) {
1497 + success(response);
1498 + }
1499 + } failureBlock:^(NSError *error) {
1500 + if (failure) {
1501 + failure(error);
1502 + }
1503 + }];
1504 +}
1505 +
1493 - (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure 1506 - (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure
1494 { 1507 {
1495 [[Warply sharedService] getInbox2WithSuccessBlock :^(NSArray *inbox) { 1508 [[Warply sharedService] getInbox2WithSuccessBlock :^(NSArray *inbox) {
......
...@@ -17,6 +17,7 @@ import AVFoundation ...@@ -17,6 +17,7 @@ import AVFoundation
17 @IBOutlet weak var mapButton: UIButton! 17 @IBOutlet weak var mapButton: UIButton!
18 @IBOutlet weak var mapButtonHeight: NSLayoutConstraint! 18 @IBOutlet weak var mapButtonHeight: NSLayoutConstraint!
19 @IBOutlet weak var mapButtonTopSpace: NSLayoutConstraint! 19 @IBOutlet weak var mapButtonTopSpace: NSLayoutConstraint!
20 + @IBOutlet weak var cancelButton: UIButton!
20 21
21 public override func awakeFromNib() { 22 public override func awakeFromNib() {
22 super.awakeFromNib() 23 super.awakeFromNib()
...@@ -32,6 +33,16 @@ import AVFoundation ...@@ -32,6 +33,16 @@ import AVFoundation
32 mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 50) 33 mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 50)
33 mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25) 34 mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
34 35
36 + cancelButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 17)
37 + cancelButton.setTitle("Ακύρωση ενιαίου κουπονιού", for: .normal)
38 + cancelButton.setTitleColor(UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00), for: .normal)
39 + cancelButton.layer.cornerRadius = 15.0
40 + cancelButton.frame = CGRect(x: 0.0, y: 0.0, width: cancelButton.intrinsicContentSize.width, height: 50)
41 + cancelButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
42 + cancelButton.backgroundColor = .clear
43 + cancelButton.layer.borderWidth = 2
44 + cancelButton.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
45 +
35 // mapButton.isHidden = true 46 // mapButton.isHidden = true
36 // mapButtonHeight.constant = 0 47 // mapButtonHeight.constant = 0
37 // mapButtonTopSpace.constant = 0 48 // mapButtonTopSpace.constant = 0
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
8 import UIKit 8 import UIKit
9 import RSBarcodes_Swift 9 import RSBarcodes_Swift
10 import AVFoundation 10 import AVFoundation
11 -// import SwiftEventBus 11 +import SwiftEventBus
12 12
13 @objc public class UnifiedCouponBarcodeViewController: UIViewController { 13 @objc public class UnifiedCouponBarcodeViewController: UIViewController {
14 @IBOutlet weak var mainView: UIView! 14 @IBOutlet weak var mainView: UIView!
...@@ -57,6 +57,88 @@ import AVFoundation ...@@ -57,6 +57,88 @@ import AVFoundation
57 57
58 58
59 // MARK: - Functions 59 // MARK: - Functions
60 + func showConfirmDialog() -> Void {
61 +
62 + let alert = UIAlertController(title: "Ακύρωση Κουπονιού", message: "Είσαι σίγουρος ότι θέλεις να ακυρώσεις το κουπόνι σου;", preferredStyle: .alert)
63 +
64 + let cancelButton = UIAlertAction(title: "Όχι", style: .default, handler: { action in
65 + switch action.style{
66 + case .default:
67 + print("default")
68 +
69 + case .cancel:
70 + print("cancel")
71 +
72 + case .destructive:
73 + print("destructive")
74 +
75 + }
76 + })
77 + // cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
78 + alert.addAction(cancelButton)
79 +
80 + alert.addAction(UIAlertAction(title: "Ναι", style: .default, handler: { action in
81 + switch action.style{
82 + case .default:
83 + self.cancelUnifiedCouponRequest()
84 +
85 + case .cancel:
86 + print("cancel")
87 +
88 + case .destructive:
89 + print("destructive")
90 +
91 + }
92 + }))
93 +
94 + self.present(alert, animated: true, completion: nil)
95 + }
96 +
97 + func showSuccessDialog() -> Void {
98 +
99 + let alert = UIAlertController(title: "Ακύρωση Κουπονιού", message: "Το ενιαίο κουπόνι σου ακυρώθηκε επιτυχώς. Βρες τα μεμονωμένα κουπόνια στο καλάθι SM deals.", preferredStyle: .alert)
100 + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
101 + switch action.style{
102 + case .default:
103 + SwiftEventBus.post("refresh_unified_coupons")
104 + self.navigationController?.popViewController(animated: true)
105 + self.dismiss(animated: true, completion: {})
106 +
107 + case .cancel:
108 + print("cancel")
109 +
110 + case .destructive:
111 + print("destructive")
112 +
113 + }
114 + }))
115 + self.present(alert, animated: true, completion: nil)
116 + }
117 +
118 + func cancelUnifiedCouponRequest () -> Void {
119 + var tranIdFound = "";
120 + for coupon in self.coupon?._coupons ?? [] {
121 + if ((coupon.transaction_uuid != nil) && coupon.transaction_uuid != "") {
122 + tranIdFound = coupon.transaction_uuid ?? "";
123 + break;
124 + }
125 + }
126 +
127 + if (tranIdFound != "") {
128 + swiftApi().cancelUnifiedCouponAsync(transactionId: tranIdFound, self.cancelUnifiedCouponCallback, failureCallback: { errorCode in })
129 + }
130 + }
131 +
132 + func cancelUnifiedCouponCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void {
133 + if (responseData != nil) {
134 + DispatchQueue.main.async {
135 + if (responseData?.getStatus == 1) {
136 + self.showSuccessDialog()
137 + }
138 +
139 + }
140 + }
141 + }
60 142
61 // MARK: - Actions 143 // MARK: - Actions
62 @IBAction func showCouponsButtonAction(_ sender: Any) { 144 @IBAction func showCouponsButtonAction(_ sender: Any) {
...@@ -109,6 +191,10 @@ import AVFoundation ...@@ -109,6 +191,10 @@ import AVFoundation
109 // } 191 // }
110 // } 192 // }
111 } 193 }
194 +
195 + @IBAction func cancelButtonAction(_ sender: Any) {
196 + self.showConfirmDialog()
197 + }
112 } 198 }
113 199
114 // MARK: - TableView 200 // MARK: - TableView
......
...@@ -405,6 +405,8 @@ WL_VERSION_INTERFACE() ...@@ -405,6 +405,8 @@ WL_VERSION_INTERFACE()
405 405
406 - (void) getCouponSetsDealsWithSuccessBlock:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 406 - (void) getCouponSetsDealsWithSuccessBlock:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
407 407
408 +- (void) cancelUnifiedCouponWithSuccessBlock:(NSString*) transactionId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
409 +
408 - (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 410 - (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
409 411
410 - (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 412 - (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
...@@ -3388,6 +3388,63 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -3388,6 +3388,63 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
3388 }]; 3388 }];
3389 } 3389 }
3390 3390
3391 +- (void) cancelUnifiedCouponWithSuccessBlock:(NSString*) transactionId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
3392 +{
3393 + NSMutableDictionary* data = [[NSMutableDictionary alloc] init];
3394 +
3395 + [data setValue:@"cancel_unified_coupon" forKey:@"action"];
3396 + [data setValue:transactionId forKey:@"transaction_id"];
3397 +
3398 + NSMutableDictionary* dataCoupons = [[NSMutableDictionary alloc] init];
3399 + [dataCoupons setValue:data forKey:@"coupon"];
3400 + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dataCoupons options:0 error:NULL];
3401 + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
3402 + if (success) {
3403 + success(contextResponse);
3404 + }
3405 + NSLog(@"**************** WARPLY Response *****************" );
3406 + NSLog(@"%@", contextResponse );
3407 + } failureBlock:^(NSError *error) {
3408 + if (failure) {
3409 + NSDictionary* dict = [NSDictionary alloc];
3410 + dict = [error userInfo];
3411 + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"];
3412 + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) {
3413 +
3414 +// NSString* errorDomain = [error domain];
3415 +// NSError *errorToken = [NSError errorWithDomain:errorDomain code:401 userInfo:dict];
3416 +//
3417 +// if (failure) {
3418 +// failure(errorToken);
3419 +// }
3420 +
3421 + [self refreshToken:^(NSDictionary *response) {
3422 + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
3423 + if (success) {
3424 + success(contextResponse);
3425 + }
3426 + NSLog(@"**************** WARPLY Response *****************" );
3427 + NSLog(@"%@", contextResponse );
3428 + } failureBlock:^(NSError *error) {
3429 + if (failure) {
3430 + failure(error);
3431 + }
3432 + }];
3433 + } failureBlock:^(NSError *error) {
3434 + if (failure) {
3435 + // [_db executeUpdate:@"DROP TABLE requestVariables"];
3436 + failure(error);
3437 + }
3438 + NSLog(@"Error at token %@", error );
3439 + }];
3440 + } else {
3441 + NSLog(@"Error at Cancel Unified Coupon %@", error );
3442 + failure(error);
3443 + }
3444 + }
3445 + }];
3446 +}
3447 +
3391 - (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure 3448 - (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
3392 { 3449 {
3393 NSDictionary *postDictionary = @{@"coupon": @{@"action": @"retrieve_coupon", @"coupon_set": uuid, @"communication_uuid": communication_uuid}}; 3450 NSDictionary *postDictionary = @{@"coupon": @{@"action": @"retrieve_coupon", @"coupon_set": uuid, @"communication_uuid": communication_uuid}};
......
...@@ -691,6 +691,7 @@ public class swiftApi { ...@@ -691,6 +691,7 @@ public class swiftApi {
691 public let category: String? 691 public let category: String?
692 public let barcode: String? 692 public let barcode: String?
693 public let status: Int? 693 public let status: Int?
694 + public let transaction_uuid: String?
694 public let redeemed: String? 695 public let redeemed: String?
695 public let redeemed_date: Date? 696 public let redeemed_date: Date?
696 public var couponset_data: CouponSetItemModel? 697 public var couponset_data: CouponSetItemModel?
...@@ -713,6 +714,14 @@ public class swiftApi { ...@@ -713,6 +714,14 @@ public class swiftApi {
713 self.barcode = dictionary["barcode"] as? String? ?? "" 714 self.barcode = dictionary["barcode"] as? String? ?? ""
714 self.status = dictionary["status"] as? Int? ?? nil 715 self.status = dictionary["status"] as? Int? ?? nil
715 716
717 + if let tranIdString = dictionary["transaction_uuid"] as? String? ?? "", tranIdString != "" {
718 + self.transaction_uuid = tranIdString
719 + } else if let tranIdInt = dictionary["transaction_uuid"] as? Int? ?? 0, tranIdInt != 0 {
720 + self.transaction_uuid = String(tranIdInt)
721 + } else {
722 + self.transaction_uuid = ""
723 + }
724 +
716 if let tempDiscount = dictionary["discount"] as? String? ?? "" { 725 if let tempDiscount = dictionary["discount"] as? String? ?? "" {
717 if tempDiscount.contains(",") { 726 if tempDiscount.contains(",") {
718 let formattedDiscount = tempDiscount.replacingOccurrences(of: ",", with: ".") 727 let formattedDiscount = tempDiscount.replacingOccurrences(of: ",", with: ".")
...@@ -7382,4 +7391,76 @@ public class swiftApi { ...@@ -7382,4 +7391,76 @@ public class swiftApi {
7382 } 7391 }
7383 7392
7384 7393
7394 + public func cancelUnifiedCouponAsync(transactionId: String, _ cancelUnifiedCouponCallback: @escaping (_ responseData: GenericResponseModel?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void {
7395 +
7396 + let instanceOfMyApi = MyApi()
7397 + instanceOfMyApi.cancelUnifiedCouponAsync(transactionId, requestCallback, failureBlock: requestFailureCallback)
7398 +
7399 + func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void {
7400 +
7401 + if let responseDataDictionary = responseData as? [String: Any] {
7402 +
7403 + let tempResponse = GenericResponseModel(dictionary: responseDataDictionary)
7404 +
7405 + if (tempResponse != nil) {
7406 + DispatchQueue.main.async {
7407 + if (tempResponse.getStatus == 1) {
7408 + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
7409 + dynatraceEvent._eventName = "custom_success_cancel_unified_coupon"
7410 + dynatraceEvent._parameters = nil
7411 + SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
7412 +
7413 + } else {
7414 + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
7415 + dynatraceEvent._eventName = "custom_error_cancel_unified_coupon"
7416 + dynatraceEvent._parameters = nil
7417 + SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
7418 +
7419 + }
7420 + }
7421 + } else {
7422 + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
7423 + dynatraceEvent._eventName = "custom_error_cancel_unified_coupon"
7424 + dynatraceEvent._parameters = nil
7425 + SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
7426 + }
7427 +
7428 + cancelUnifiedCouponCallback(tempResponse);
7429 +
7430 + } else {
7431 + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
7432 + dynatraceEvent._eventName = "custom_error_cancel_unified_coupon"
7433 + dynatraceEvent._parameters = nil
7434 + SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
7435 +
7436 + cancelUnifiedCouponCallback(nil)
7437 + }
7438 +
7439 + }
7440 +
7441 + func requestFailureCallback(_ error: Error?) -> Void {
7442 + print("cancelUnifiedCoupon error: ")
7443 + print(error)
7444 + print("====================")
7445 +
7446 + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
7447 + dynatraceEvent._eventName = "custom_error_cancel_unified_coupon"
7448 + dynatraceEvent._parameters = nil
7449 + SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
7450 +
7451 + if let error = error as? NSError {
7452 +// if (error.code == 401) {
7453 +// let sessionEvent = swiftApi.LoyaltySDKSessionExpiredEventModel()
7454 +// sessionEvent._sessionExpired = true
7455 +// SwiftEventBus.post("sdk_session_expired", sender: sessionEvent)
7456 +// }
7457 +
7458 + failureCallback(error.code)
7459 + } else {
7460 + failureCallback(-1)
7461 + }
7462 + }
7463 + }
7464 +
7465 +
7385 } 7466 }
......