Manos Chorianopoulos

getSingleCampaignAsync and new badge functionality

...@@ -173,6 +173,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -173,6 +173,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
173 vc.ccms = campaigns[indexPath.row]._ccms 173 vc.ccms = campaigns[indexPath.row]._ccms
174 self.navigationController?.pushViewController(vc, animated: true) 174 self.navigationController?.pushViewController(vc, animated: true)
175 175
176 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
177 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
178 + }
179 +
176 } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") { 180 } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
177 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() 181 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
178 let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } 182 let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
...@@ -185,6 +189,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -185,6 +189,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
185 vc.ccms = item 189 vc.ccms = item
186 vc.campaign = campaigns[indexPath.row] 190 vc.campaign = campaigns[indexPath.row]
187 self.navigationController?.pushViewController(vc, animated: true) 191 self.navigationController?.pushViewController(vc, animated: true)
192 +
193 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
194 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
195 + }
188 break; 196 break;
189 } 197 }
190 } 198 }
...@@ -217,6 +225,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -217,6 +225,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
217 225
218 self.navigationController?.pushViewController(vc, animated: true) 226 self.navigationController?.pushViewController(vc, animated: true)
219 227
228 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
229 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
230 + }
231 +
220 break; 232 break;
221 } 233 }
222 } 234 }
...@@ -272,6 +284,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -272,6 +284,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
272 vc.params = params 284 vc.params = params
273 self.navigationController?.pushViewController(vc, animated: true) 285 self.navigationController?.pushViewController(vc, animated: true)
274 286
287 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
288 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
289 + }
290 +
275 } else { 291 } else {
276 let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent() 292 let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
277 seasonalEvent._title = campaigns[indexPath.row]._title ?? "" 293 seasonalEvent._title = campaigns[indexPath.row]._title ?? ""
...@@ -282,4 +298,17 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -282,4 +298,17 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
282 } 298 }
283 } 299 }
284 300
301 +
302 + func getSingleCampaignAsyncRequest(sessionUuid: String) {
303 + swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
304 + }
305 +
306 + func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
307 + if (getSingleCampaignData != nil) {
308 + DispatchQueue.main.async {
309 + }
310 + } else {
311 + }
312 + }
313 +
285 } 314 }
......
...@@ -115,6 +115,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -115,6 +115,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
115 vc.ccms = campaigns[indexPath.row]._ccms 115 vc.ccms = campaigns[indexPath.row]._ccms
116 self.navigationController?.pushViewController(vc, animated: true) 116 self.navigationController?.pushViewController(vc, animated: true)
117 117
118 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
119 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
120 + }
121 +
118 } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") { 122 } else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
119 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() 123 let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
120 let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } 124 let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
...@@ -127,6 +131,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -127,6 +131,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
127 vc.ccms = item 131 vc.ccms = item
128 vc.campaign = campaigns[indexPath.row] 132 vc.campaign = campaigns[indexPath.row]
129 self.navigationController?.pushViewController(vc, animated: true) 133 self.navigationController?.pushViewController(vc, animated: true)
134 +
135 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
136 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
137 + }
130 } 138 }
131 } 139 }
132 } 140 }
...@@ -158,6 +166,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -158,6 +166,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
158 166
159 self.navigationController?.pushViewController(vc, animated: true) 167 self.navigationController?.pushViewController(vc, animated: true)
160 168
169 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
170 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
171 + }
172 +
161 break; 173 break;
162 } 174 }
163 } 175 }
...@@ -218,6 +230,23 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -218,6 +230,23 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
218 vc.campaignUrl = url 230 vc.campaignUrl = url
219 vc.params = params 231 vc.params = params
220 self.navigationController?.pushViewController(vc, animated: true) 232 self.navigationController?.pushViewController(vc, animated: true)
233 +
234 + if let sessionUuid = campaigns[indexPath.row].session_uuid {
235 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
236 + }
237 + }
238 + }
239 +
240 +
241 + func getSingleCampaignAsyncRequest(sessionUuid: String) {
242 + swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
243 + }
244 +
245 + func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
246 + if (getSingleCampaignData != nil) {
247 + DispatchQueue.main.async {
248 + }
249 + } else {
221 } 250 }
222 } 251 }
223 252
......
...@@ -103,6 +103,7 @@ ...@@ -103,6 +103,7 @@
103 - (void)didReceiveNotification:(NSDictionary *)payload; 103 - (void)didReceiveNotification:(NSDictionary *)payload;
104 - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken; 104 - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken;
105 - (void)editProfileAsync:(NSString*)firstname andLastname:(NSString*)lastname andEmail:(NSString *)email andSalutation:(NSString *)salutation andMsisdn:(NSString *)msisdn andNickname:(NSString *)nickname andGender:(NSString *)gender andBirthday:(NSString *)birthday andNameDay:(NSString *)nameday andTaxID:(NSString *)taxid andProfileMetadata:(NSDictionary *)profileMetadata optin:(NSNumber *)optin newsLetter:(NSNumber *)newsletter andSMS:(NSNumber *)sms andSegmentation:(NSNumber *)segmentation andSMSSegmentation:(NSNumber *)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 105 - (void)editProfileAsync:(NSString*)firstname andLastname:(NSString*)lastname andEmail:(NSString *)email andSalutation:(NSString *)salutation andMsisdn:(NSString *)msisdn andNickname:(NSString *)nickname andGender:(NSString *)gender andBirthday:(NSString *)birthday andNameDay:(NSString *)nameday andTaxID:(NSString *)taxid andProfileMetadata:(NSDictionary *)profileMetadata optin:(NSNumber *)optin newsLetter:(NSNumber *)newsletter andSMS:(NSNumber *)sms andSegmentation:(NSNumber *)segmentation andSMSSegmentation:(NSNumber *)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
106 +- (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
106 107
107 @end 108 @end
108 #endif /* MyApi_h */ 109 #endif /* MyApi_h */
......
...@@ -1627,4 +1627,16 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; ...@@ -1627,4 +1627,16 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
1627 }]; 1627 }];
1628 } 1628 }
1629 1629
1630 +- (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure {
1631 + [[Warply sharedService] getSingleCampaignWithSuccessBlock:sessionUuid :^(NSDictionary *response) {
1632 + if (success) {
1633 + success(response);
1634 + }
1635 + } failureBlock:^(NSError *error) {
1636 + if (failure) {
1637 + failure(error);
1638 + }
1639 + }];
1640 +}
1641 +
1630 @end 1642 @end
......
...@@ -402,6 +402,9 @@ WL_VERSION_INTERFACE() ...@@ -402,6 +402,9 @@ WL_VERSION_INTERFACE()
402 - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 402 - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
403 403
404 - (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 404 - (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
405 +
406 +- (void)getSingleCampaignWithSuccessBlock:(NSString *)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
407 +
405 /*! 408 /*!
406 @abstract Get the full page add accordint to the display_type of a campaign. 409 @abstract Get the full page add accordint to the display_type of a campaign.
407 @attributeblock successBlock This block is called when getInbox is sucessful and allOffers is empty or nil and returns an array with the available WLInboxItem items. Otherwise, the allOffers array is filtered. 410 @attributeblock successBlock This block is called when getInbox is sucessful and allOffers is empty or nil and returns an array with the available WLInboxItem items. Otherwise, the allOffers array is filtered.
......
...@@ -2646,6 +2646,29 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -2646,6 +2646,29 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
2646 } 2646 }
2647 2647
2648 /////////////////////////////////////////////////////////////////////////////// 2648 ///////////////////////////////////////////////////////////////////////////////
2649 +- (BOOL)getContextWithPathCampaign:(NSString *)path
2650 + sessionUuid:(NSString *)sessionUuid
2651 + successBlock:(void (^)(id contextResponse))successBlock
2652 + failureBlock:(void (^)(NSError *error))failureBlock
2653 +{
2654 +
2655 + if ([self isRegistrationValid] == NO) {
2656 + [_pendingOperationsQueue setSuspended:YES];
2657 + [self registration];
2658 + }
2659 +
2660 + NSInvocation *invocation = [self contextRequestInvocationWithTypeCampaign:WLContextRequestTypeGet
2661 + data:nil path:path sessionUuid:sessionUuid
2662 + successBlock:[successBlock copy]
2663 + failureBlock:[failureBlock copy]];
2664 +
2665 + NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithInvocation:invocation];
2666 + [_pendingOperationsQueue addOperation:operation];
2667 +
2668 + return [self isRegistrationValid];
2669 +}
2670 +
2671 +///////////////////////////////////////////////////////////////////////////////
2649 - (BOOL)sendContext:(NSData*)context 2672 - (BOOL)sendContext:(NSData*)context
2650 successBlock:(void (^)(NSDictionary *contextResponse))successBlock 2673 successBlock:(void (^)(NSDictionary *contextResponse))successBlock
2651 failureBlock:(void (^)(NSError *error))failureBlock 2674 failureBlock:(void (^)(NSError *error))failureBlock
...@@ -4600,6 +4623,30 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) ...@@ -4600,6 +4623,30 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
4600 return invocation; 4623 return invocation;
4601 } 4624 }
4602 4625
4626 +- (NSInvocation *)contextRequestInvocationWithTypeCampaign:(WLContextRequestType)type
4627 + data:(NSData *)context
4628 + path:(NSString *)path
4629 + sessionUuid:(NSString *)sessionUuid
4630 + successBlock:(void (^)(NSDictionary *contextResponse))successBlock
4631 + failureBlock:(void (^)(NSError *error))failureBlock
4632 +{
4633 + void (^ successBlockCopy)(void) = [successBlock copy];
4634 + void (^ failureBlockCopy)(void) = [failureBlock copy];
4635 +
4636 + NSMethodSignature *sgn = [self methodSignatureForSelector:@selector(runContextRequestWithTypeCampaign:data:path:sessionUuid:successBlock:failureBlock:)];
4637 + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sgn];
4638 + [invocation setTarget:self];
4639 + [invocation setSelector:@selector(runContextRequestWithTypeCampaign:data:path:sessionUuid:successBlock:failureBlock:)];
4640 + [invocation setArgument:&type atIndex:2];
4641 + [invocation setArgument:&context atIndex:3];
4642 + [invocation setArgument:&path atIndex:4];
4643 + [invocation setArgument:&sessionUuid atIndex:5];
4644 + [invocation setArgument:&successBlockCopy atIndex:6];
4645 + [invocation setArgument:&failureBlockCopy atIndex:7];
4646 + [invocation retainArguments];
4647 + return invocation;
4648 +}
4649 +
4603 - (NSInvocation *)contextRequestInvocationWithType2:(WLContextRequestType)type 4650 - (NSInvocation *)contextRequestInvocationWithType2:(WLContextRequestType)type
4604 data:(NSData *)context 4651 data:(NSData *)context
4605 path:(NSString *)path 4652 path:(NSString *)path
...@@ -4974,6 +5021,134 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) ...@@ -4974,6 +5021,134 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
4974 } 5021 }
4975 } 5022 }
4976 5023
5024 +- (void)runContextRequestWithTypeCampaign:(WLContextRequestType)requestType
5025 + data:(NSData*)context
5026 + path:(NSString *)path
5027 + sessionUuid:(NSString *)sessionUuid
5028 + successBlock:(void (^)(id contextResponse))successBlock
5029 + failureBlock:(void (^)(NSError *error))failureBlock
5030 +{
5031 + //Create REQUEST
5032 + NSMutableString *urlString = [NSMutableString stringWithFormat:@"%@/api/session/%@", _baseURL, sessionUuid];
5033 +
5034 + WLLOG(@"[WARP Trace] HTTP URL: %@", urlString);
5035 +
5036 + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:100];
5037 +
5038 + NSDictionary *parameters;
5039 +
5040 + if (context != nil) {
5041 + parameters = [NSJSONSerialization JSONObjectWithData:context options:NSJSONReadingAllowFragments error:NULL];
5042 + }
5043 +
5044 + SuccessResponse successResponse = ^(NSURLSessionDataTask * _Nonnull task, id _Nullable JSON) {
5045 + if (JSON == nil) {
5046 + successBlock(@{@"status": @"0"});
5047 + }
5048 + else {
5049 +
5050 +// NSData *responseData = [NSJSONSerialization dataWithJSONObject:JSON options:NSJSONWritingPrettyPrinted error:NULL];
5051 +// NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
5052 + // WLLOG(@"[WARP Trace] HTTP %@ Response:%@", request.HTTPMethod, responseString);
5053 + WLLOG(@"************ WARP %@ CONTEXT ******************", request.HTTPMethod);
5054 + WLLOG(@"[WARP Trace] HTTP Web Id: %@", _webId);
5055 + WLLOG(@"[WARP Trace] HTTP API Key: %@", _apiKey);
5056 + WLLOG(@"[WARP Trace] HTTP %@ Request URL: %@", request.HTTPMethod, request.URL.absoluteString);
5057 + NSString *contextString = [[NSString alloc] initWithData:context encoding:NSUTF8StringEncoding];
5058 + WLLOG(@"[WARP Trace] HTTP %@ Request Body: %@", request.HTTPMethod, contextString);
5059 + WLLOG(@"*************************************************");
5060 + NSDictionary *contextResponse=[JSON valueForKey:@"context"];
5061 +
5062 +
5063 +
5064 + if ([JSON objectForKey:@"status"]) {
5065 +
5066 + int status = [[JSON valueForKey:@"status"] intValue];
5067 +
5068 + if (status != WLResultCodesSuccess)
5069 + {
5070 + if ((status == WLResultCodesInvalidWebID) || (status == WLResultCodesDeviceRegistrationFailed))
5071 + {
5072 + self.webId = nil;
5073 + self.apiKey = nil;
5074 +
5075 + [_pendingOperationsQueue setSuspended:YES];
5076 + }
5077 +
5078 + NSString *errorDescrition = (status <= [WLResultCodesDescriptions count]) && status > 0 ? (WLResultCodesDescriptions[(status-1)]) : ([NSString stringWithFormat:@"Internal WARP Server error %d", status]);
5079 +
5080 + NSDictionary *eDict = @{NSLocalizedDescriptionKey: errorDescrition};
5081 + NSError *error = [NSError errorWithDomain:WARP_ERROR_DOMAIN code:status userInfo:eDict];
5082 +
5083 + if (failureBlock)
5084 + failureBlock(error);
5085 +
5086 + return;
5087 + }
5088 +
5089 + if (successBlock)
5090 + {
5091 + if ([path length]!=0)
5092 + {
5093 + successBlock([contextResponse valueForKey:path]);
5094 + return;
5095 + }
5096 + successBlock(contextResponse);
5097 + }
5098 +
5099 +
5100 + }else{
5101 + NSError *error = [NSError errorWithDomain:WARP_ERROR_DOMAIN code:1026 userInfo:@{NSLocalizedDescriptionKey: NSLocalizedString(@"Empty response", @"Warply")}];
5102 + if (failureBlock)
5103 + failureBlock(error);
5104 +
5105 + }
5106 +
5107 + }
5108 + };
5109 +
5110 + FailureResponse faliureResponse = ^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
5111 + WLLOG(@"************ WARP %@ CONTEXT ******************", request.HTTPMethod);
5112 + WLLOG(@"[WARP Trace] HTTP Web Id: %@", _webId);
5113 + WLLOG(@"[WARP Trace] HTTP API Key: %@", _apiKey);
5114 + WLLOG(@"[WARP Trace] HTTP %@ Request URL: %@", request.HTTPMethod, request.URL.absoluteString);
5115 + NSString *contextString = [[NSString alloc] initWithData:context encoding:NSUTF8StringEncoding];
5116 +
5117 +
5118 + WLLOG(@"[WARP Trace] HTTP %@ Request Body: %@", request.HTTPMethod, contextString);
5119 + WLLOG(@"[WARP Trace] Error: %@", [error description]);
5120 + WLLOG(@"*************************************************");
5121 + if (failureBlock)
5122 + failureBlock(error);
5123 + };
5124 +
5125 + _httpClient.responseSerializer = [AFJSONResponseSerializer serializer];
5126 + _httpClient.requestSerializer = [AFJSONRequestSerializer serializer];
5127 +
5128 + //Set HTTP Headers
5129 + time_t timestamp = (time_t) [[NSDate date] timeIntervalSince1970];
5130 + [_httpClient.requestSerializer setValue:_webId forHTTPHeaderField:@"loyalty-web-id"];
5131 + [_httpClient.requestSerializer setValue:[NSString stringWithFormat:@"%lu", timestamp] forHTTPHeaderField:@"loyalty-date"];
5132 + [_httpClient.requestSerializer setValue:[[NSString stringWithFormat:@"%@%lu", _apiKey, timestamp] SHA256Sum] forHTTPHeaderField:@"loyalty-signature"];
5133 + [_httpClient.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
5134 + [_httpClient.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
5135 + [_httpClient.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"User-Agent"];
5136 + [_httpClient.requestSerializer setValue:[NSString stringWithFormat:@"ios:%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]] forHTTPHeaderField:@"loyalty-bundle-id"];
5137 + [_httpClient.requestSerializer setValue:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forHTTPHeaderField:@"unique-device-id"];
5138 + [_httpClient.requestSerializer setValue:@"apple" forHTTPHeaderField:@"vendor"];
5139 + [_httpClient.requestSerializer setValue:@"platform" forHTTPHeaderField:@"ios"];
5140 + [_httpClient.requestSerializer setValue:@"os_version" forHTTPHeaderField:[[UIDevice currentDevice] systemVersion]];
5141 + [_httpClient.requestSerializer setValue:@"mobile" forHTTPHeaderField:@"channel"];
5142 + if (requestType == WLContextRequestTypePost) {
5143 +// NSDictionary *parameters = [NSJSONSerialization JSONObjectWithData:context options:NSJSONReadingAllowFragments error:NULL];
5144 +
5145 + [_httpClient POST:urlString parameters:parameters progress:nil success:successResponse failure:faliureResponse];
5146 + }
5147 + else {
5148 + [_httpClient GET:urlString parameters:parameters progress:nil success:successResponse failure:faliureResponse];
5149 + }
5150 +}
5151 +
4977 - (void)runContextRequestWithTypeCosmote:(WLContextRequestType)requestType 5152 - (void)runContextRequestWithTypeCosmote:(WLContextRequestType)requestType
4978 data:(NSData*)context 5153 data:(NSData*)context
4979 path:(NSString *)path 5154 path:(NSString *)path
...@@ -5714,6 +5889,23 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg ...@@ -5714,6 +5889,23 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg
5714 } 5889 }
5715 5890
5716 /////////////////////////////////////////////////////////////////////////////// 5891 ///////////////////////////////////////////////////////////////////////////////
5892 +- (void)getSingleCampaignWithSuccessBlock:(NSString *)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
5893 +{
5894 + [self getContextWithPathCampaign:nil sessionUuid:sessionUuid successBlock:^(NSDictionary *contextResponse) {
5895 + if (success){
5896 + success(contextResponse);
5897 + }
5898 + NSLog(@"**************** WARPLY Response *****************" );
5899 + NSLog(@"%@", contextResponse );
5900 + } failureBlock:^(NSError *error) {
5901 + if (failure) {
5902 + failure(error);
5903 + }
5904 + NSLog(@"Error at get Single Campaign %@", error );
5905 + }];
5906 +}
5907 +
5908 +///////////////////////////////////////////////////////////////////////////////
5717 - (void)networkReachabilityReporting 5909 - (void)networkReachabilityReporting
5718 { 5910 {
5719 __weak Warply *myself = self; 5911 __weak Warply *myself = self;
......
...@@ -4921,6 +4921,10 @@ public class swiftApi { ...@@ -4921,6 +4921,10 @@ public class swiftApi {
4921 vc.campaign = campaign 4921 vc.campaign = campaign
4922 controller.navigationController?.pushViewController(vc, animated: true) 4922 controller.navigationController?.pushViewController(vc, animated: true)
4923 4923
4924 + if let sessionUuid = campaign.session_uuid {
4925 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
4926 + }
4927 +
4924 break; 4928 break;
4925 } 4929 }
4926 } 4930 }
...@@ -4933,6 +4937,22 @@ public class swiftApi { ...@@ -4933,6 +4937,22 @@ public class swiftApi {
4933 vc.campaignUrl = swiftApi().constructCampaignUrl(campaign) 4937 vc.campaignUrl = swiftApi().constructCampaignUrl(campaign)
4934 vc.params = swiftApi().constructCampaignParams(campaign) 4938 vc.params = swiftApi().constructCampaignParams(campaign)
4935 controller.navigationController?.pushViewController(vc, animated: true) 4939 controller.navigationController?.pushViewController(vc, animated: true)
4940 +
4941 + if let sessionUuid = campaign.session_uuid {
4942 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
4943 + }
4944 + }
4945 +
4946 + func getSingleCampaignAsyncRequest(sessionUuid: String) {
4947 + swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
4948 + }
4949 +
4950 + func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
4951 + if (getSingleCampaignData != nil) {
4952 + DispatchQueue.main.async {
4953 + }
4954 + } else {
4955 + }
4936 } 4956 }
4937 } 4957 }
4938 4958
...@@ -4962,6 +4982,10 @@ public class swiftApi { ...@@ -4962,6 +4982,10 @@ public class swiftApi {
4962 vc.campaignUrl = swiftApi().constructCcmsUrl(loyaltyCampaign, ccms) 4982 vc.campaignUrl = swiftApi().constructCcmsUrl(loyaltyCampaign, ccms)
4963 vc.params = swiftApi().constructCcmsParams(loyaltyCampaign, ccms) 4983 vc.params = swiftApi().constructCcmsParams(loyaltyCampaign, ccms)
4964 controller.navigationController?.pushViewController(vc, animated: true) 4984 controller.navigationController?.pushViewController(vc, animated: true)
4985 +
4986 + if let sessionUuid = loyaltyCampaign.session_uuid {
4987 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
4988 + }
4965 break; 4989 break;
4966 4990
4967 } else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) { 4991 } else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) {
...@@ -4971,11 +4995,27 @@ public class swiftApi { ...@@ -4971,11 +4995,27 @@ public class swiftApi {
4971 vc.ccms = ccms 4995 vc.ccms = ccms
4972 vc.campaign = loyaltyCampaign 4996 vc.campaign = loyaltyCampaign
4973 controller.navigationController?.pushViewController(vc, animated: true) 4997 controller.navigationController?.pushViewController(vc, animated: true)
4998 +
4999 + if let sessionUuid = loyaltyCampaign.session_uuid {
5000 + getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
5001 + }
4974 break; 5002 break;
4975 5003
4976 } 5004 }
4977 } 5005 }
4978 } 5006 }
5007 +
5008 + func getSingleCampaignAsyncRequest(sessionUuid: String) {
5009 + swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
5010 + }
5011 +
5012 + func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
5013 + if (getSingleCampaignData != nil) {
5014 + DispatchQueue.main.async {
5015 + }
5016 + } else {
5017 + }
5018 + }
4979 } 5019 }
4980 5020
4981 5021
...@@ -5647,4 +5687,56 @@ public class swiftApi { ...@@ -5647,4 +5687,56 @@ public class swiftApi {
5647 } 5687 }
5648 5688
5649 5689
5690 + public func getSingleCampaignAsync(sessionUuid: String, _ getSingleCampaignCallback: @escaping (_ getSingleCampaignData: VerifyTicketResponseModel?) -> Void) -> Void {
5691 +
5692 + let instanceOfMyApi = MyApi()
5693 + instanceOfMyApi.getSingleCampaignAsync(sessionUuid, getSingleCampaignAsyncCallback, failureBlock: getSingleCampaignFailureCallback)
5694 +
5695 + func getSingleCampaignAsyncCallback(_ getSingleCampaignData: [AnyHashable: Any]?) -> Void {
5696 +
5697 + swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback)
5698 +
5699 + func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
5700 + if (campaignsData != nil) {
5701 + DispatchQueue.main.async {
5702 + }
5703 + } else {
5704 + }
5705 + }
5706 +
5707 + if let getSingleCampaignDataDictionary = getSingleCampaignData as? [String: Any] {
5708 +
5709 + let tempResponse = VerifyTicketResponseModel(dictionary: getSingleCampaignDataDictionary)
5710 +
5711 + getSingleCampaignCallback(tempResponse);
5712 +
5713 + if (tempResponse.getStatus == 1) {
5714 + }
5715 +
5716 + } else {
5717 + getSingleCampaignCallback(nil)
5718 + }
5719 +
5720 + }
5721 +
5722 + func getSingleCampaignFailureCallback(_ error: Error?) -> Void {
5723 +
5724 + swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback)
5725 +
5726 + func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
5727 + if (campaignsData != nil) {
5728 + DispatchQueue.main.async {
5729 + }
5730 + } else {
5731 + }
5732 + }
5733 +
5734 + print("getSingleCampaign error: ")
5735 + print(error)
5736 + print("====================")
5737 + getSingleCampaignCallback(nil)
5738 + }
5739 + }
5740 +
5741 +
5650 } 5742 }
......