Manos Chorianopoulos

add redeemCouponSetAsync request

......@@ -79,15 +79,32 @@ import UIKit
termsButton.setImage(UIImage(named: "ic_down_dark.png", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil), for: .normal)
}
}
func redeemCouponSetRequest(uuid: String) {
swiftApi().redeemCouponSetAsync(uuid: uuid, redeemCouponSetCallback)
}
func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
// Do something
}
}
} else {
}
}
// MARK: - Actions
@IBAction func redeemButtomAction(_ sender: Any) {
// SwiftEventBus.post("couponRedeem", sender: coupon)
redeemCouponSetRequest(uuid: couponset?.uuid ?? "")
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "MakeItAPresentViewController") as UIViewController
self.navigationController?.pushViewController(vc, animated: true)
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "MakeItAPresentViewController") as UIViewController
// self.navigationController?.pushViewController(vc, animated: true)
}
@IBAction func termsButtonAction(_ sender: Any) {
......
......@@ -82,6 +82,7 @@
- (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)redeemCouponSetAsync:(NSString*)uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
@end
#endif /* MyApi_h */
......
......@@ -1366,4 +1366,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)redeemCouponSetAsync:(NSString*)uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] redeemCouponSetsWithSuccessBlock:uuid :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
@end
......
......@@ -1562,7 +1562,33 @@ public class swiftApi {
print("====================")
consumerIntegrationCallback(nil)
}
}
public func redeemCouponSetAsync(uuid: String, _ redeemCouponSetCallback: @escaping (_ responseData: GenericResponseModel?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.redeemCouponSetAsync(uuid, requestCallback, failureBlock: requestFailureCallback)
func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void {
if let responseDataDictionary = responseData as? [String: Any] {
let tempResponse = GenericResponseModel(dictionary: responseDataDictionary)
redeemCouponSetCallback(tempResponse);
} else {
redeemCouponSetCallback(nil)
}
}
func requestFailureCallback(_ error: Error?) -> Void {
print("consumerIntegration error: ")
print(error)
print("====================")
redeemCouponSetCallback(nil)
}
}
}
......