Manos Chorianopoulos

add redeemCouponSetAsync with extra_data

...@@ -22,6 +22,7 @@ import UIKit ...@@ -22,6 +22,7 @@ import UIKit
22 @IBOutlet weak var termsTextView: UITextView! 22 @IBOutlet weak var termsTextView: UITextView!
23 @IBOutlet weak var termsTextViewHeight: NSLayoutConstraint! 23 @IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
24 24
25 + public var ccms: swiftApi.LoyaltyContextualOfferModel?
25 public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer() 26 public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
26 27
27 let uiscreen: CGRect = UIScreen.main.bounds 28 let uiscreen: CGRect = UIScreen.main.bounds
...@@ -122,7 +123,12 @@ import UIKit ...@@ -122,7 +123,12 @@ import UIKit
122 } 123 }
123 124
124 func redeemCouponSetRequest(uuid: String, communication_uuid: String) { 125 func redeemCouponSetRequest(uuid: String, communication_uuid: String) {
126 + if (ccms == nil) {
125 swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback) 127 swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback)
128 + } else {
129 + // TODO: MAybe change user_msisdn: profile?._msisdn ?? ""
130 + swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, user_msisdn: profile?._msisdn ?? "", businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), redeemCouponSetCallback)
131 + }
126 } 132 }
127 133
128 func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void { 134 func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
......
...@@ -185,8 +185,6 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -185,8 +185,6 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
185 } else if (campaigns[indexPath.row]._campaign_type == "coupon") { 185 } else if (campaigns[indexPath.row]._campaign_type == "coupon") {
186 let couponsetUuid = campaigns[indexPath.row]._couponset 186 let couponsetUuid = campaigns[indexPath.row]._couponset
187 187
188 - // TODO: search if loyalty id exists
189 -
190 if (couponsetUuid != "") { 188 if (couponsetUuid != "") {
191 let couponsetsList = swiftApi().getCouponSetList() 189 let couponsetsList = swiftApi().getCouponSetList()
192 190
...@@ -196,7 +194,19 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -196,7 +194,19 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
196 let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController 194 let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
197 vc.couponset = item 195 vc.couponset = item
198 vc.campaign = campaigns[indexPath.row] 196 vc.campaign = campaigns[indexPath.row]
199 - // TODO: add ccms 197 +
198 + let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
199 + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
200 +
201 + if (loyaltyCampaignIdExists == true) {
202 + for item in ccmsCampaigns {
203 + if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
204 + vc.ccms = item
205 + break;
206 + }
207 + }
208 + }
209 +
200 self.navigationController?.pushViewController(vc, animated: true) 210 self.navigationController?.pushViewController(vc, animated: true)
201 211
202 break; 212 break;
......
...@@ -143,6 +143,19 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -143,6 +143,19 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
143 let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController 143 let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
144 vc.couponset = item 144 vc.couponset = item
145 vc.campaign = campaigns[indexPath.row] 145 vc.campaign = campaigns[indexPath.row]
146 +
147 + let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
148 + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
149 +
150 + if (loyaltyCampaignIdExists == true) {
151 + for item in ccmsCampaigns {
152 + if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
153 + vc.ccms = item
154 + break;
155 + }
156 + }
157 + }
158 +
146 self.navigationController?.pushViewController(vc, animated: true) 159 self.navigationController?.pushViewController(vc, animated: true)
147 160
148 break; 161 break;
......
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
86 - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 86 - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
87 - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 87 - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
88 - (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 88 - (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
89 +- (void)redeemCouponSetAsync:(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;
89 - (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 90 - (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
90 - (void)setPacingDetailsAsync:(NSNumber*)steps :(NSString*)date :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 91 - (void)setPacingDetailsAsync:(NSNumber*)steps :(NSString*)date :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
91 - (void)cosmoteSharingAsync:(NSString*)sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 92 - (void)cosmoteSharingAsync:(NSString*)sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
...@@ -1441,6 +1441,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; ...@@ -1441,6 +1441,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
1441 }]; 1441 }];
1442 } 1442 }
1443 1443
1444 +- (void)redeemCouponSetAsync:(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
1445 +{
1446 + [[Warply sharedService] redeemCouponSetsWithSuccessBlock:uuid :communication_uuid :user_msisdn :businessService :offerName :productType :provDuration :noOfRecurrance :price :discount :voiceCategory :dataCategory :minsValue :dataValue :provStepValueMins :OfferAudienceLevel :UACIOfferTrackingCode :OFFERCODE1 :SCORE :ZONE :WAVE :VALIDITY :TREATMENT_CODE :ccms_session_id :^(NSDictionary *response) {
1447 + if (success) {
1448 + success(response);
1449 + }
1450 + } failureBlock:^(NSError *error) {
1451 + if (failure) {
1452 + failure(error);
1453 + }
1454 + }];
1455 +}
1456 +
1444 - (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure 1457 - (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
1445 { 1458 {
1446 [[Warply sharedService] getPacingDetailsWithSuccessBlock:^(NSDictionary *response) { 1459 [[Warply sharedService] getPacingDetailsWithSuccessBlock:^(NSDictionary *response) {
......
...@@ -389,6 +389,8 @@ WL_VERSION_INTERFACE() ...@@ -389,6 +389,8 @@ WL_VERSION_INTERFACE()
389 389
390 - (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 390 - (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
391 391
392 +- (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;
393 +
392 - (void) cosmoteCouponSharingWithSuccessBlock:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 394 - (void) cosmoteCouponSharingWithSuccessBlock:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
393 395
394 - (void) cosmoteSharingWithSuccessBlock:(NSString*) sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 396 - (void) cosmoteSharingWithSuccessBlock:(NSString*) sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
...@@ -2170,6 +2170,66 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -2170,6 +2170,66 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
2170 }]; 2170 }];
2171 } 2171 }
2172 2172
2173 +- (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
2174 +{
2175 + NSDictionary *postDictionary = @{@"coupon": @{@"action": @"retrieve_coupon", @"coupon_set": uuid, @"communication_uuid": communication_uuid, @"extra_data": @{@"user_msisdn": user_msisdn, @"businessService": businessService, @"offerName": offerName, @"productType": productType, @"provDuration": provDuration, @"noOfRecurrance": noOfRecurrance, @"price": price, @"discount": discount, @"voiceCategory": voiceCategory, @"dataCategory": dataCategory, @"minsValue": minsValue, @"dataValue": dataValue, @"provStepValueMins": provStepValueMins, @"InteractiveChannel": @"COSMOTE_OMNI", @"InteractionPoint": ZONE, @"Session_ID": ccms_session_id, @"OfferAudienceLevel": OfferAudienceLevel, @"MSISDN": user_msisdn, @"GUID": @"", @"parameters": @[
2176 + @{@"Name": @"UACIOfferTrackingCode", @"Value": UACIOfferTrackingCode, @"Type": @"string"},
2177 + @{@"Name": @"UACICustomLoggerTableName", @"Value": @"VW_WHITELIST", @"Type": @"string"},
2178 + @{@"Name": @"MSISDN", @"Value": user_msisdn, @"Type": @"string"},
2179 + @{@"Name": @"OFFERCODE1", @"Value": OFFERCODE1, @"Type": @"string"},
2180 + @{@"Name": @"SCORE", @"Value": SCORE, @"Type": @"INT"},
2181 + @{@"Name": @"PREDICATE", @"Value": @"0", @"Type": @"string"},
2182 + @{@"Name": @"ZONE", @"Value": ZONE, @"Type": @"string"},
2183 + @{@"Name": @"APPLICATIONNAME", @"Value": ZONE, @"Type": @"string"},
2184 + @{@"Name": @"Session_ID", @"Value": ccms_session_id, @"Type": @"string"},
2185 + @{@"Name": @"CAMPAIGN_CODE", @"Value": @"MCC_00006", @"Type": @"string"},
2186 + @{@"Name": @"CAMPAIGN_TYPE", @"Value": @"Inbound", @"Type": @"string"},
2187 + @{@"Name": @"UACIResponseTypeCode", @"Value": @"CON", @"Type": @"string"},
2188 + @{@"Name": @"CHANNEL", @"Value": @"ONE_APP", @"Type": @"string"},
2189 + @{@"Name": @"WAVE", @"Value": WAVE, @"Type": @"string"},
2190 + @{@"Name": @"RESPONSECHANNEL", @"Value": @"ONE_APP", @"Type": @"string"},
2191 + @{@"Name": @"VALIDITY", @"Value": VALIDITY, @"Type": @"INT"},
2192 + @{@"Name": @"TREATMENT_CODE", @"Value": TREATMENT_CODE, @"Type": @"string"},
2193 + @{@"Name": @"EventName", @"Value": @"INTEREST_P", @"Type": @"string"}
2194 + ]}}};
2195 + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL];
2196 + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
2197 + if (success) {
2198 + success(contextResponse);
2199 + }
2200 + NSLog(@"**************** WARPLY Response *****************" );
2201 + NSLog(@"%@", contextResponse );
2202 + } failureBlock:^(NSError *error) {
2203 + if (failure) {
2204 + NSDictionary* dict = [NSDictionary alloc];
2205 + dict = [error userInfo];
2206 + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"];
2207 + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) {
2208 + [self refreshToken:^(NSDictionary *response) {
2209 + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
2210 + if (success) {
2211 + success(contextResponse);
2212 + }
2213 + NSLog(@"**************** WARPLY Response *****************" );
2214 + NSLog(@"%@", contextResponse );
2215 + } failureBlock:^(NSError *error) {
2216 + if (failure) {
2217 + failure(error);
2218 + }
2219 + }];
2220 + } failureBlock:^(NSError *error) {
2221 + if (failure) {
2222 + [_db executeUpdate:@"DROP TABLE requestVariables"];
2223 + failure(error);
2224 + }
2225 + NSLog(@"Error at token %@", error );
2226 + }];
2227 + }
2228 + NSLog(@"Error at redeem coupon sets %@", error );
2229 + }
2230 + }];
2231 +}
2232 +
2173 - (void) cosmoteCouponSharingWithSuccessBlock:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure 2233 - (void) cosmoteCouponSharingWithSuccessBlock:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
2174 { 2234 {
2175 NSDictionary *postDictionary = @{@"coupon": @{@"action": @"share", @"coupon": coupon, @"sender_msisdn": sender, @"receiver_msisdn": receiver}}; 2235 NSDictionary *postDictionary = @{@"coupon": @{@"action": @"share", @"coupon": coupon, @"sender_msisdn": sender, @"receiver_msisdn": receiver}};
......
...@@ -3479,6 +3479,34 @@ public class swiftApi { ...@@ -3479,6 +3479,34 @@ public class swiftApi {
3479 } 3479 }
3480 3480
3481 3481
3482 + public func redeemCouponSetAsync(uuid: String, communication_uuid: String, user_msisdn: String, businessService: String, offerName: String, productType: String, provDuration: String, noOfRecurrance: String, price: String, discount: String, voiceCategory: String, dataCategory: String, minsValue: String, dataValue: String, provStepValueMins: String, OfferAudienceLevel: String, UACIOfferTrackingCode: String, OFFERCODE1: String, SCORE: String, ZONE: String, WAVE: String, VALIDITY: String, TREATMENT_CODE: String, ccms_session_id: String, _ redeemCouponSetCallback: @escaping (_ responseData: GenericResponseModel?) -> Void) -> Void {
3483 +
3484 + let instanceOfMyApi = MyApi()
3485 + instanceOfMyApi.redeemCouponSetAsync(uuid, communication_uuid, user_msisdn, businessService, offerName, productType, provDuration, noOfRecurrance, price, discount, voiceCategory, dataCategory, minsValue, dataValue, provStepValueMins, OfferAudienceLevel, UACIOfferTrackingCode, OFFERCODE1, SCORE, ZONE, WAVE, VALIDITY, TREATMENT_CODE, ccms_session_id, requestCallback, failureBlock: requestFailureCallback)
3486 +
3487 + func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void {
3488 +
3489 + if let responseDataDictionary = responseData as? [String: Any] {
3490 +
3491 + let tempResponse = GenericResponseModel(dictionary: responseDataDictionary)
3492 +
3493 + redeemCouponSetCallback(tempResponse);
3494 +
3495 + } else {
3496 + redeemCouponSetCallback(nil)
3497 + }
3498 +
3499 + }
3500 +
3501 + func requestFailureCallback(_ error: Error?) -> Void {
3502 + print("redeemCouponSet error: ")
3503 + print(error)
3504 + print("====================")
3505 + redeemCouponSetCallback(nil)
3506 + }
3507 + }
3508 +
3509 +
3482 public func setUniqueCampaignList(_ campaigns: Array<CampaignItemModel>) -> Void { 3510 public func setUniqueCampaignList(_ campaigns: Array<CampaignItemModel>) -> Void {
3483 // let userTag = self.getUserTag() 3511 // let userTag = self.getUserTag()
3484 // var campaignsArray:Array<CampaignItemModel> = [] 3512 // var campaignsArray:Array<CampaignItemModel> = []
......