Showing
5 changed files
with
294 additions
and
9 deletions
... | @@ -50,7 +50,8 @@ | ... | @@ -50,7 +50,8 @@ |
50 | - (NSMutableArray *)getTagsCategories; | 50 | - (NSMutableArray *)getTagsCategories; |
51 | - (NSMutableArray *)getTags; | 51 | - (NSMutableArray *)getTags; |
52 | - (NSDictionary *)login:(NSString *)id password:(NSString *)password loginType:(NSString*) loginType; | 52 | - (NSDictionary *)login:(NSString *)id password:(NSString *)password loginType:(NSString*) loginType; |
53 | -- (NSDictionary *)logout; | 53 | +// - (NSDictionary *)logout; |
54 | +- (void) logout:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
54 | - (NSDictionary *)register:(NSString *)id password:(NSString *)password name:(NSString*)name email:(NSString*)email segmentation:(NSNumber*)segmentation newsletter:(NSNumber*)newsletter; | 55 | - (NSDictionary *)register:(NSString *)id password:(NSString *)password name:(NSString*)name email:(NSString*)email segmentation:(NSNumber*)segmentation newsletter:(NSNumber*)newsletter; |
55 | - (NSDictionary *)registerAutoLogin:(NSString *)id password:(NSString *)password name:(NSString*)name email:(NSString*)email segmentation:(NSNumber*)segmentation newsletter:(NSNumber*)newsletter loginType:(NSString*)loginType; | 56 | - (NSDictionary *)registerAutoLogin:(NSString *)id password:(NSString *)password name:(NSString*)name email:(NSString*)email segmentation:(NSNumber*)segmentation newsletter:(NSNumber*)newsletter loginType:(NSString*)loginType; |
56 | - (NSDictionary *)refreshToken; | 57 | - (NSDictionary *)refreshToken; | ... | ... |
... | @@ -638,10 +638,23 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; | ... | @@ -638,10 +638,23 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; |
638 | return resp; | 638 | return resp; |
639 | } | 639 | } |
640 | 640 | ||
641 | -- (NSDictionary *)logout { | 641 | +// - (NSDictionary *)logout { |
642 | - NSDictionary *response = [NSDictionary alloc]; | 642 | +// NSDictionary *response = [NSDictionary alloc]; |
643 | - response = [[Warply sharedService] logout]; | 643 | +// response = [[Warply sharedService] logout]; |
644 | - return response; | 644 | +// return response; |
645 | +// } | ||
646 | + | ||
647 | +- (void) logout:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
648 | +{ | ||
649 | + [[Warply sharedService] logout:^(NSDictionary *response) { | ||
650 | + if (success) { | ||
651 | + success(response); | ||
652 | + } | ||
653 | + } failureBlock:^(NSError *error) { | ||
654 | + if (failure) { | ||
655 | + failure(error); | ||
656 | + } | ||
657 | + }]; | ||
645 | } | 658 | } |
646 | 659 | ||
647 | - (NSDictionary *)register:(NSString *)id password:(NSString *)password name:(NSString*)name email:(NSString*)email segmentation:(NSNumber*)segmentation newsletter:(NSNumber*)newsletter { | 660 | - (NSDictionary *)register:(NSString *)id password:(NSString *)password name:(NSString*)name email:(NSString*)email segmentation:(NSNumber*)segmentation newsletter:(NSNumber*)newsletter { | ... | ... |
... | @@ -325,7 +325,9 @@ WL_VERSION_INTERFACE() | ... | @@ -325,7 +325,9 @@ WL_VERSION_INTERFACE() |
325 | 325 | ||
326 | - (void)loginWithSuccessBlock:(NSString*)id andPassword:(NSString*)password andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 326 | - (void)loginWithSuccessBlock:(NSString*)id andPassword:(NSString*)password andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
327 | 327 | ||
328 | -- (NSDictionary*)logout; | 328 | +// - (NSDictionary*)logout; |
329 | + | ||
330 | +- (void)logout:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
329 | 331 | ||
330 | - (void)webAuthorizeWithSuccessBlock:(NSDictionary*)contextResponse andId:(NSString*)id andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 332 | - (void)webAuthorizeWithSuccessBlock:(NSDictionary*)contextResponse andId:(NSString*)id andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
331 | 333 | ... | ... |
... | @@ -1159,15 +1159,85 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1159,15 +1159,85 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1159 | }]; | 1159 | }]; |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | -- (NSDictionary*)logout | 1162 | +// - (NSDictionary*)logout |
1163 | +// { | ||
1164 | + | ||
1165 | +// @synchronized (_DatabaseLock) { | ||
1166 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1167 | +// } | ||
1168 | +// NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | ||
1169 | +// NSLog(@"**************** WARPLY Logout *****************" ); | ||
1170 | +// return successResponse; | ||
1171 | +// } | ||
1172 | + | ||
1173 | +- (void)logout:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
1163 | { | 1174 | { |
1175 | + /* | ||
1176 | + POST https://engage-stage.warp.ly/oauth/<app_uuid>/logout | ||
1177 | + | ||
1178 | + {"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjMyMjI4ODYsImlhdCI6MTcxMDE2ODIwMiwiZXhwIjoxNzEwMTcwMDAyLCJIT1NUIjoiaHR0cHM6Ly9lbmdhZ2Utc3RhZ2Uud2FycC5seSJ9.8W9x4uuEsZiL8NNtJmpA1I3JsMtx8j3jePAnGekNkAM", | ||
1179 | + "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjMyMjI4ODYsImlhdCI6MTcxMDE2ODIwMiwiZXhwIjoxNzEwMTcwMDAyLCJIT1NUIjoiaHR0cHM6Ly9lbmdhZ2Utc3RhZ2Uud2FycC5seSJ9.8W9x4uuEsZiL8NNtJmpA1I3JsMtx8j3jePAnGekNkAM"} | ||
1180 | + */ | ||
1181 | + | ||
1182 | + BOOL tableExist = NO; | ||
1183 | + @try { | ||
1184 | + @synchronized (_DatabaseLock) { | ||
1185 | + tableExist = [_db tableExists:@"requestVariables"]; | ||
1186 | + } | ||
1187 | + } | ||
1188 | + @catch (NSException *exception) { | ||
1189 | + NSLog(@"tableExists error: %@", exception.reason); | ||
1190 | + if (failure) { | ||
1191 | + NSError *error = nil; | ||
1192 | + failure(error); | ||
1193 | + } | ||
1194 | + } | ||
1195 | + @finally { | ||
1196 | +// NSLog(@"Finally condition"); | ||
1197 | + } | ||
1198 | + | ||
1199 | + if (tableExist == YES) { | ||
1200 | + NSString *accessToken = @""; | ||
1201 | + NSString *refreshToken = @""; | ||
1202 | + accessToken = [_sharedService getAccessToken2]; | ||
1203 | + refreshToken = [_sharedService getRefreshToken]; | ||
1204 | + | ||
1205 | + | ||
1206 | + NSMutableDictionary* data = [[NSMutableDictionary alloc] init]; | ||
1207 | + | ||
1208 | + [data setValue:accessToken forKey:@"access_token"]; | ||
1209 | + [data setValue:refreshToken forKey:@"refresh_token"]; | ||
1210 | + | ||
1211 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:data options:0 error:NULL]; | ||
1212 | + [self sendContextLogout:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1213 | + if (success) { | ||
1214 | + // success(contextResponse); | ||
1164 | 1215 | ||
1165 | @synchronized (_DatabaseLock) { | 1216 | @synchronized (_DatabaseLock) { |
1166 | [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1217 | [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1167 | } | 1218 | } |
1168 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | 1219 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
1169 | NSLog(@"**************** WARPLY Logout *****************" ); | 1220 | NSLog(@"**************** WARPLY Logout *****************" ); |
1170 | - return successResponse; | 1221 | + success(successResponse); |
1222 | + } | ||
1223 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
1224 | + NSLog(@"%@", contextResponse ); | ||
1225 | + } failureBlock:^(NSError *error) { | ||
1226 | + if (failure) { | ||
1227 | + failure(error); | ||
1228 | +// NSDictionary *failureResponse = @{@"result": @"failure", @"status":@2}; | ||
1229 | +// failure(failureResponse); | ||
1230 | + } | ||
1231 | + NSLog(@"Error at logout %@", error ); | ||
1232 | + }]; | ||
1233 | + } | ||
1234 | + | ||
1235 | + // @synchronized (_DatabaseLock) { | ||
1236 | + // [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1237 | + // } | ||
1238 | + // NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | ||
1239 | + // NSLog(@"**************** WARPLY Logout *****************" ); | ||
1240 | + // return successResponse; | ||
1171 | } | 1241 | } |
1172 | 1242 | ||
1173 | - (void)webAuthorizeWithSuccessBlock:(NSDictionary*)contextResponse andId:(NSString*)id andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | 1243 | - (void)webAuthorizeWithSuccessBlock:(NSDictionary*)contextResponse andId:(NSString*)id andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure |
... | @@ -4606,6 +4676,35 @@ NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithInvoca | ... | @@ -4606,6 +4676,35 @@ NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithInvoca |
4606 | return appIsRegisteredWithWarply; | 4676 | return appIsRegisteredWithWarply; |
4607 | } | 4677 | } |
4608 | 4678 | ||
4679 | +- (BOOL)sendContextLogout:(NSData*)context | ||
4680 | + successBlock:(void (^)(NSDictionary *contextResponse))successBlock | ||
4681 | + failureBlock:(void (^)(NSError *error))failureBlock | ||
4682 | +{ | ||
4683 | + BOOL appIsRegisteredWithWarply = [self isRegistrationValid]; | ||
4684 | + | ||
4685 | + if (WL_FEATURE_IS_DISABLED_WITH_KEY(WL_WARPLY_ENABLED)) | ||
4686 | + return appIsRegisteredWithWarply; | ||
4687 | + | ||
4688 | + if (appIsRegisteredWithWarply == NO) { | ||
4689 | + [_pendingOperationsQueue setSuspended:YES]; | ||
4690 | + [self registration]; | ||
4691 | + } | ||
4692 | + NSString *path = nil; | ||
4693 | + // NSString *path = @"logout"; | ||
4694 | + | ||
4695 | + NSInvocation *invocation = [self contextRequestInvocationWithTypeLogout:WLContextRequestTypePost | ||
4696 | + data:context | ||
4697 | + path:path | ||
4698 | + successBlock:[successBlock copy] | ||
4699 | + failureBlock:[failureBlock copy]]; | ||
4700 | + | ||
4701 | + | ||
4702 | + NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithInvocation:invocation]; | ||
4703 | + [_pendingOperationsQueue addOperation:operation]; | ||
4704 | + | ||
4705 | + return appIsRegisteredWithWarply; | ||
4706 | +} | ||
4707 | + | ||
4609 | #pragma - Events | 4708 | #pragma - Events |
4610 | /////////////////////////////////////////////////////////////////////////////// | 4709 | /////////////////////////////////////////////////////////////////////////////// |
4611 | - (void)addEvent:(WLEvent *)event priority:(BOOL)priority | 4710 | - (void)addEvent:(WLEvent *)event priority:(BOOL)priority |
... | @@ -6287,6 +6386,28 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -6287,6 +6386,28 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
6287 | return invocation; | 6386 | return invocation; |
6288 | } | 6387 | } |
6289 | 6388 | ||
6389 | +- (NSInvocation *)contextRequestInvocationWithTypeLogout:(WLContextRequestType)type | ||
6390 | + data:(NSData *)context | ||
6391 | + path:(NSString *)path | ||
6392 | + successBlock:(void (^)(NSDictionary *contextResponse))successBlock | ||
6393 | + failureBlock:(void (^)(NSError *error))failureBlock | ||
6394 | +{ | ||
6395 | + void (^ successBlockCopy)(void) = [successBlock copy]; | ||
6396 | + void (^ failureBlockCopy)(void) = [failureBlock copy]; | ||
6397 | + | ||
6398 | + NSMethodSignature *sgn = [self methodSignatureForSelector:@selector(runContextRequestWithTypeLogout:data:path:successBlock:failureBlock:)]; | ||
6399 | + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sgn]; | ||
6400 | + [invocation setTarget:self]; | ||
6401 | + [invocation setSelector:@selector(runContextRequestWithTypeLogout:data:path:successBlock:failureBlock:)]; | ||
6402 | + [invocation setArgument:&type atIndex:2]; | ||
6403 | + [invocation setArgument:&context atIndex:3]; | ||
6404 | + [invocation setArgument:&path atIndex:4]; | ||
6405 | + [invocation setArgument:&successBlockCopy atIndex:5]; | ||
6406 | + [invocation setArgument:&failureBlockCopy atIndex:6]; | ||
6407 | + [invocation retainArguments]; | ||
6408 | + return invocation; | ||
6409 | +} | ||
6410 | + | ||
6290 | - (NSInvocation *)contextRequestInvocationWithTypeCampaign:(WLContextRequestType)type | 6411 | - (NSInvocation *)contextRequestInvocationWithTypeCampaign:(WLContextRequestType)type |
6291 | data:(NSData *)context | 6412 | data:(NSData *)context |
6292 | path:(NSString *)path | 6413 | path:(NSString *)path |
... | @@ -6597,6 +6718,10 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -6597,6 +6718,10 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
6597 | urlString = [NSMutableString stringWithFormat:@"%@/api/async/info/%@/", _baseURL, _appUUID]; | 6718 | urlString = [NSMutableString stringWithFormat:@"%@/api/async/info/%@/", _baseURL, _appUUID]; |
6598 | } | 6719 | } |
6599 | 6720 | ||
6721 | + // if([path isEqualToString:@"logout"]){ | ||
6722 | + // urlString = [NSMutableString stringWithFormat:@"%@/oauth/%@/logout", _baseURL, _appUUID]; | ||
6723 | + // } | ||
6724 | + | ||
6600 | WLLOG(@"[WARP Trace] HTTP URL: %@", urlString); | 6725 | WLLOG(@"[WARP Trace] HTTP URL: %@", urlString); |
6601 | 6726 | ||
6602 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0]; | 6727 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0]; |
... | @@ -6717,6 +6842,94 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -6717,6 +6842,94 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
6717 | } | 6842 | } |
6718 | } | 6843 | } |
6719 | 6844 | ||
6845 | +- (void)runContextRequestWithTypeLogout:(WLContextRequestType)requestType | ||
6846 | + data:(NSData*)context | ||
6847 | + path:(NSString *)path | ||
6848 | + successBlock:(void (^)(id contextResponse))successBlock | ||
6849 | + failureBlock:(void (^)(NSError *error))failureBlock | ||
6850 | +{ | ||
6851 | + //Create REQUEST | ||
6852 | + // POST https://engage-stage.warp.ly/oauth/<app_uuid>/logout | ||
6853 | + NSMutableString *urlString = [NSMutableString stringWithFormat:@"%@/oauth/%@/logout", _baseURL, _appUUID]; | ||
6854 | + | ||
6855 | + WLLOG(@"[WARP Trace] HTTP URL: %@", urlString); | ||
6856 | + | ||
6857 | + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0]; | ||
6858 | + [request setTimeoutInterval:30.0]; | ||
6859 | + | ||
6860 | + NSDictionary *parameters; | ||
6861 | + | ||
6862 | + if (context != nil) { | ||
6863 | + parameters = [NSJSONSerialization JSONObjectWithData:context options:NSJSONReadingAllowFragments error:NULL]; | ||
6864 | + } | ||
6865 | + | ||
6866 | + SuccessResponse successResponse = ^(NSURLSessionDataTask * _Nonnull task, id _Nullable JSON) { | ||
6867 | + if (JSON == nil) { | ||
6868 | + successBlock(@{@"status": @"0"}); | ||
6869 | + } | ||
6870 | + else { | ||
6871 | + | ||
6872 | +// NSData *responseData = [NSJSONSerialization dataWithJSONObject:JSON options:NSJSONWritingPrettyPrinted error:NULL]; | ||
6873 | +// NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; | ||
6874 | + // WLLOG(@"[WARP Trace] HTTP %@ Response:%@", request.HTTPMethod, responseString); | ||
6875 | + WLLOG(@"************ WARP %@ CONTEXT ******************", request.HTTPMethod); | ||
6876 | + WLLOG(@"[WARP Trace] HTTP Web Id: %@", _webId); | ||
6877 | + WLLOG(@"[WARP Trace] HTTP API Key: %@", _apiKey); | ||
6878 | + WLLOG(@"[WARP Trace] HTTP %@ Request URL: %@", request.HTTPMethod, request.URL.absoluteString); | ||
6879 | + NSString *contextString = [[NSString alloc] initWithData:context encoding:NSUTF8StringEncoding]; | ||
6880 | + WLLOG(@"[WARP Trace] HTTP %@ Request Body: %@", request.HTTPMethod, contextString); | ||
6881 | + WLLOG(@"*************************************************"); | ||
6882 | + | ||
6883 | + if (successBlock) | ||
6884 | + { | ||
6885 | + successBlock(JSON); | ||
6886 | + } | ||
6887 | + } | ||
6888 | + }; | ||
6889 | + | ||
6890 | + FailureResponse faliureResponse = ^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { | ||
6891 | + WLLOG(@"************ WARP %@ CONTEXT ******************", request.HTTPMethod); | ||
6892 | + WLLOG(@"[WARP Trace] HTTP Web Id: %@", _webId); | ||
6893 | + WLLOG(@"[WARP Trace] HTTP API Key: %@", _apiKey); | ||
6894 | + WLLOG(@"[WARP Trace] HTTP %@ Request URL: %@", request.HTTPMethod, request.URL.absoluteString); | ||
6895 | + NSString *contextString = [[NSString alloc] initWithData:context encoding:NSUTF8StringEncoding]; | ||
6896 | + | ||
6897 | + | ||
6898 | + WLLOG(@"[WARP Trace] HTTP %@ Request Body: %@", request.HTTPMethod, contextString); | ||
6899 | + WLLOG(@"[WARP Trace] Error: %@", [error description]); | ||
6900 | + WLLOG(@"*************************************************"); | ||
6901 | + if (failureBlock) | ||
6902 | + failureBlock(error); | ||
6903 | + }; | ||
6904 | + | ||
6905 | + _httpClient.responseSerializer = [AFJSONResponseSerializer serializer]; | ||
6906 | + _httpClient.requestSerializer = [AFJSONRequestSerializer serializer]; | ||
6907 | + [_httpClient.requestSerializer setTimeoutInterval:30]; | ||
6908 | + | ||
6909 | + //Set HTTP Headers | ||
6910 | + time_t timestamp = (time_t) [[NSDate date] timeIntervalSince1970]; | ||
6911 | + [_httpClient.requestSerializer setValue:_webId forHTTPHeaderField:@"loyalty-web-id"]; | ||
6912 | + [_httpClient.requestSerializer setValue:[NSString stringWithFormat:@"%lu", timestamp] forHTTPHeaderField:@"loyalty-date"]; | ||
6913 | + [_httpClient.requestSerializer setValue:[[NSString stringWithFormat:@"%@%lu", _apiKey, timestamp] SHA256Sum] forHTTPHeaderField:@"loyalty-signature"]; | ||
6914 | + [_httpClient.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; | ||
6915 | + [_httpClient.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; | ||
6916 | + [_httpClient.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"User-Agent"]; | ||
6917 | + [_httpClient.requestSerializer setValue:[NSString stringWithFormat:@"ios:%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]] forHTTPHeaderField:@"loyalty-bundle-id"]; | ||
6918 | + [_httpClient.requestSerializer setValue:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forHTTPHeaderField:@"unique-device-id"]; | ||
6919 | + [_httpClient.requestSerializer setValue:@"apple" forHTTPHeaderField:@"vendor"]; | ||
6920 | + [_httpClient.requestSerializer setValue:@"platform" forHTTPHeaderField:@"ios"]; | ||
6921 | + [_httpClient.requestSerializer setValue:@"os_version" forHTTPHeaderField:[[UIDevice currentDevice] systemVersion]]; | ||
6922 | + [_httpClient.requestSerializer setValue:@"mobile" forHTTPHeaderField:@"channel"]; | ||
6923 | + if (requestType == WLContextRequestTypePost) { | ||
6924 | +// NSDictionary *parameters = [NSJSONSerialization JSONObjectWithData:context options:NSJSONReadingAllowFragments error:NULL]; | ||
6925 | + | ||
6926 | + [_httpClient POST:urlString parameters:parameters progress:nil success:successResponse failure:faliureResponse]; | ||
6927 | + } | ||
6928 | + else { | ||
6929 | + [_httpClient GET:urlString parameters:parameters progress:nil success:successResponse failure:faliureResponse]; | ||
6930 | + } | ||
6931 | +} | ||
6932 | + | ||
6720 | - (void)runContextRequestWithTypeCampaign:(WLContextRequestType)requestType | 6933 | - (void)runContextRequestWithTypeCampaign:(WLContextRequestType)requestType |
6721 | data:(NSData*)context | 6934 | data:(NSData*)context |
6722 | path:(NSString *)path | 6935 | path:(NSString *)path | ... | ... |
... | @@ -7590,10 +7590,55 @@ public class swiftApi { | ... | @@ -7590,10 +7590,55 @@ public class swiftApi { |
7590 | } | 7590 | } |
7591 | 7591 | ||
7592 | 7592 | ||
7593 | + // public func logout(_ logoutCallback: @escaping (_ responseData: VerifyTicketResponseModel?) -> Void) -> Void { | ||
7594 | + | ||
7595 | + // let instanceOfMyApi = MyApi() | ||
7596 | + // let responseData = instanceOfMyApi.logout() as [AnyHashable: Any]? | ||
7597 | + | ||
7598 | + // if let responseDataDictionary = responseData as? [String: Any] { | ||
7599 | + | ||
7600 | + // let tempResponse = VerifyTicketResponseModel(dictionary: responseDataDictionary) | ||
7601 | + | ||
7602 | + // if (tempResponse.getStatus == 1) { | ||
7603 | + // let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | ||
7604 | + // dynatraceEvent._eventName = "custom_success_logout_loyalty" | ||
7605 | + // dynatraceEvent._parameters = nil | ||
7606 | + // SwiftEventBus.post("dynatrace", sender: dynatraceEvent) | ||
7607 | + | ||
7608 | + // swiftApi().setUserTag("") | ||
7609 | + // swiftApi().setUserNonTelco(false) | ||
7610 | + // swiftApi().setCCMSLoyaltyCampaigns(campaigns: []) | ||
7611 | + | ||
7612 | + // let accessToken = instanceOfMyApi.getAccessTokenM() | ||
7613 | + // print("=================== TOKEN DELETED =========================") | ||
7614 | + // print("Bearer: ", accessToken) | ||
7615 | + // print("=================== TOKEN DELETED =========================") | ||
7616 | + // } else { | ||
7617 | + | ||
7618 | + // let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | ||
7619 | + // dynatraceEvent._eventName = "custom_error_logout_loyalty" | ||
7620 | + // dynatraceEvent._parameters = nil | ||
7621 | + // SwiftEventBus.post("dynatrace", sender: dynatraceEvent) | ||
7622 | + // } | ||
7623 | + | ||
7624 | + // logoutCallback(tempResponse); | ||
7625 | + | ||
7626 | + // } else { | ||
7627 | + // let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | ||
7628 | + // dynatraceEvent._eventName = "custom_error_logout_loyalty" | ||
7629 | + // dynatraceEvent._parameters = nil | ||
7630 | + // SwiftEventBus.post("dynatrace", sender: dynatraceEvent) | ||
7631 | + | ||
7632 | + // logoutCallback(nil) | ||
7633 | + // } | ||
7634 | + // } | ||
7635 | + | ||
7593 | public func logout(_ logoutCallback: @escaping (_ responseData: VerifyTicketResponseModel?) -> Void) -> Void { | 7636 | public func logout(_ logoutCallback: @escaping (_ responseData: VerifyTicketResponseModel?) -> Void) -> Void { |
7594 | 7637 | ||
7595 | let instanceOfMyApi = MyApi() | 7638 | let instanceOfMyApi = MyApi() |
7596 | - let responseData = instanceOfMyApi.logout() as [AnyHashable: Any]? | 7639 | + instanceOfMyApi.logout(successCallback, failureBlock: failureCallback) |
7640 | + | ||
7641 | + func successCallback(_ responseData: [AnyHashable : Any]?) -> Void { | ||
7597 | 7642 | ||
7598 | if let responseDataDictionary = responseData as? [String: Any] { | 7643 | if let responseDataDictionary = responseData as? [String: Any] { |
7599 | 7644 | ||
... | @@ -7633,6 +7678,17 @@ public class swiftApi { | ... | @@ -7633,6 +7678,17 @@ public class swiftApi { |
7633 | } | 7678 | } |
7634 | } | 7679 | } |
7635 | 7680 | ||
7681 | + func failureCallback(_ error: Error?) -> Void { | ||
7682 | + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | ||
7683 | + dynatraceEvent._eventName = "custom_error_logout_loyalty" | ||
7684 | + dynatraceEvent._parameters = nil | ||
7685 | + SwiftEventBus.post("dynatrace", sender: dynatraceEvent) | ||
7686 | + | ||
7687 | + logoutCallback(nil) | ||
7688 | + } | ||
7689 | + | ||
7690 | + } | ||
7691 | + | ||
7636 | 7692 | ||
7637 | public func didReceiveNotification(_ payload: [String : Any]) -> Void { | 7693 | public func didReceiveNotification(_ payload: [String : Any]) -> Void { |
7638 | 7694 | ... | ... |
-
Please register or login to post a comment