Showing
5 changed files
with
60 additions
and
3 deletions
No preview for this file type
| ... | @@ -79,15 +79,32 @@ import UIKit | ... | @@ -79,15 +79,32 @@ import UIKit |
| 79 | termsButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal) | 79 | termsButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal) |
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | + | ||
| 83 | + func redeemCouponSetRequest(uuid: String) { | ||
| 84 | + swiftApi().redeemCouponSetAsync(uuid: uuid, redeemCouponSetCallback) | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void { | ||
| 88 | + if (response != nil) { | ||
| 89 | + DispatchQueue.main.async { | ||
| 90 | + if (response?.getStatus == 1) { | ||
| 91 | + // Do something | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + } else { | ||
| 95 | + } | ||
| 96 | + } | ||
| 82 | 97 | ||
| 83 | // MARK: - Actions | 98 | // MARK: - Actions |
| 84 | 99 | ||
| 85 | @IBAction func redeemButtomAction(_ sender: Any) { | 100 | @IBAction func redeemButtomAction(_ sender: Any) { |
| 86 | // SwiftEventBus.post("couponRedeem", sender: coupon) | 101 | // SwiftEventBus.post("couponRedeem", sender: coupon) |
| 102 | + | ||
| 103 | + redeemCouponSetRequest(uuid: couponset?.uuid ?? "") | ||
| 87 | 104 | ||
| 88 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 105 | + // let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
| 89 | - let vc = storyboard.instantiateViewController(withIdentifier: "MakeItAPresentViewController") as UIViewController | 106 | + // let vc = storyboard.instantiateViewController(withIdentifier: "MakeItAPresentViewController") as UIViewController |
| 90 | - self.navigationController?.pushViewController(vc, animated: true) | 107 | + // self.navigationController?.pushViewController(vc, animated: true) |
| 91 | } | 108 | } |
| 92 | 109 | ||
| 93 | @IBAction func termsButtonAction(_ sender: Any) { | 110 | @IBAction func termsButtonAction(_ sender: Any) { | ... | ... |
| ... | @@ -82,6 +82,7 @@ | ... | @@ -82,6 +82,7 @@ |
| 82 | - (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 82 | - (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
| 83 | - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 83 | - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
| 84 | - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 84 | - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
| 85 | +- (void)redeemCouponSetAsync:(NSString*)uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
| 85 | 86 | ||
| 86 | @end | 87 | @end |
| 87 | #endif /* MyApi_h */ | 88 | #endif /* MyApi_h */ | ... | ... |
| ... | @@ -1366,4 +1366,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; | ... | @@ -1366,4 +1366,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; |
| 1366 | }]; | 1366 | }]; |
| 1367 | } | 1367 | } |
| 1368 | 1368 | ||
| 1369 | +- (void)redeemCouponSetAsync:(NSString*)uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
| 1370 | +{ | ||
| 1371 | + [[Warply sharedService] redeemCouponSetsWithSuccessBlock:uuid :^(NSDictionary *response) { | ||
| 1372 | + if (success) { | ||
| 1373 | + success(response); | ||
| 1374 | + } | ||
| 1375 | + } failureBlock:^(NSError *error) { | ||
| 1376 | + if (failure) { | ||
| 1377 | + failure(error); | ||
| 1378 | + } | ||
| 1379 | + }]; | ||
| 1380 | +} | ||
| 1381 | + | ||
| 1369 | @end | 1382 | @end | ... | ... |
| ... | @@ -1562,7 +1562,33 @@ public class swiftApi { | ... | @@ -1562,7 +1562,33 @@ public class swiftApi { |
| 1562 | print("====================") | 1562 | print("====================") |
| 1563 | consumerIntegrationCallback(nil) | 1563 | consumerIntegrationCallback(nil) |
| 1564 | } | 1564 | } |
| 1565 | + } | ||
| 1566 | + | ||
| 1567 | + public func redeemCouponSetAsync(uuid: String, _ redeemCouponSetCallback: @escaping (_ responseData: GenericResponseModel?) -> Void) -> Void { | ||
| 1568 | + | ||
| 1569 | + let instanceOfMyApi = MyApi() | ||
| 1570 | + instanceOfMyApi.redeemCouponSetAsync(uuid, requestCallback, failureBlock: requestFailureCallback) | ||
| 1571 | + | ||
| 1572 | + func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void { | ||
| 1573 | + | ||
| 1574 | + if let responseDataDictionary = responseData as? [String: Any] { | ||
| 1575 | + | ||
| 1576 | + let tempResponse = GenericResponseModel(dictionary: responseDataDictionary) | ||
| 1565 | 1577 | ||
| 1578 | + redeemCouponSetCallback(tempResponse); | ||
| 1579 | + | ||
| 1580 | + } else { | ||
| 1581 | + redeemCouponSetCallback(nil) | ||
| 1582 | + } | ||
| 1583 | + | ||
| 1584 | + } | ||
| 1585 | + | ||
| 1586 | + func requestFailureCallback(_ error: Error?) -> Void { | ||
| 1587 | + print("consumerIntegration error: ") | ||
| 1588 | + print(error) | ||
| 1589 | + print("====================") | ||
| 1590 | + redeemCouponSetCallback(nil) | ||
| 1591 | + } | ||
| 1566 | } | 1592 | } |
| 1567 | 1593 | ||
| 1568 | } | 1594 | } | ... | ... |
-
Please register or login to post a comment