Manos Chorianopoulos

fix verifyTicketAsync

...@@ -159,6 +159,7 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError * ...@@ -159,6 +159,7 @@ typedef void (^FailureResponse)(NSURLSessionDataTask * _Nullable task, NSError *
159 /////////////////////////////////////////////////////////////////////////////// 159 ///////////////////////////////////////////////////////////////////////////////
160 + (void)launchWithAppUUIDWithCallback:(NSString *)appUUID launchOptions:(NSDictionary *)launchOptions customPushDelegate:(id <WLCustomPushHandler>)customPushDelegate serverBaseUrl:(NSString *)url andSuccessBlock:(void (^)(NSDictionary *))success andFailureBlock:(void (^)(NSError *error))failure 160 + (void)launchWithAppUUIDWithCallback:(NSString *)appUUID launchOptions:(NSDictionary *)launchOptions customPushDelegate:(id <WLCustomPushHandler>)customPushDelegate serverBaseUrl:(NSString *)url andSuccessBlock:(void (^)(NSDictionary *))success andFailureBlock:(void (^)(NSError *error))failure
161 { 161 {
162 + NSLog(@"=== _sharedService: %@", _sharedService );
162 //Launch Once 163 //Launch Once
163 if (_sharedService != nil) { 164 if (_sharedService != nil) {
164 // TODO: Maybe add failure callback here? - msg: "already launched" 165 // TODO: Maybe add failure callback here? - msg: "already launched"
...@@ -1908,12 +1909,16 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -1908,12 +1909,16 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
1908 1909
1909 [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, access_token, refresh_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, accessToken, refreshToken]; 1910 [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, access_token, refresh_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, accessToken, refreshToken];
1910 1911
1911 - NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; 1912 + NSNumber* status = [NSNumber alloc];
1913 + status = [contextResponse objectForKey:@"result"];
1914 + NSString* result = @"";
1915 + result = [status isEqual: @1] ? @"success" : @"error";
1916 + NSDictionary *successResponse = @{@"result": result, @"status": status};
1912 if (success) { 1917 if (success) {
1913 success(successResponse); 1918 success(successResponse);
1914 } 1919 }
1915 NSLog(@"**************** WARPLY Response *****************" ); 1920 NSLog(@"**************** WARPLY Response *****************" );
1916 - NSLog(@"%@", successResponse ); 1921 + NSLog(@"%@", contextResponse );
1917 } failureBlock:^(NSError *error) { 1922 } failureBlock:^(NSError *error) {
1918 if (failure) { 1923 if (failure) {
1919 failure(error); 1924 failure(error);
...@@ -1945,12 +1950,16 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -1945,12 +1950,16 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
1945 1950
1946 [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, access_token, refresh_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, accessToken, refreshToken]; 1951 [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, access_token, refresh_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, accessToken, refreshToken];
1947 1952
1948 - NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; 1953 + NSNumber* status = [NSNumber alloc];
1954 + status = [contextResponse objectForKey:@"result"];
1955 + NSString* result = @"";
1956 + result = [status isEqual: @1] ? @"success" : @"error";
1957 + NSDictionary *successResponse = @{@"result": result, @"status": status};
1949 if (success) { 1958 if (success) {
1950 success(successResponse); 1959 success(successResponse);
1951 } 1960 }
1952 NSLog(@"**************** WARPLY Response *****************" ); 1961 NSLog(@"**************** WARPLY Response *****************" );
1953 - NSLog(@"%@", successResponse ); 1962 + NSLog(@"%@", contextResponse );
1954 } failureBlock:^(NSError *error) { 1963 } failureBlock:^(NSError *error) {
1955 if (failure) { 1964 if (failure) {
1956 failure(error); 1965 failure(error);
......
...@@ -2456,13 +2456,14 @@ public class swiftApi { ...@@ -2456,13 +2456,14 @@ public class swiftApi {
2456 2456
2457 if let verifyTicketDataDictionary = verifyTicketData as? [String: Any] { 2457 if let verifyTicketDataDictionary = verifyTicketData as? [String: Any] {
2458 2458
2459 + let tempResponse = VerifyTicketResponseModel(dictionary: verifyTicketDataDictionary)
2460 +
2461 + if (tempResponse.getStatus == 1) {
2459 let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() 2462 let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
2460 dynatraceEvent._eventName = "custom_success_login_loyalty" 2463 dynatraceEvent._eventName = "custom_success_login_loyalty"
2461 dynatraceEvent._parameters = nil 2464 dynatraceEvent._parameters = nil
2462 SwiftEventBus.post("dynatrace", sender: dynatraceEvent) 2465 SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
2463 2466
2464 - let tempResponse = VerifyTicketResponseModel(dictionary: verifyTicketDataDictionary)
2465 -
2466 verifyTicketCallback(tempResponse); 2467 verifyTicketCallback(tempResponse);
2467 2468
2468 swiftApi().getProfileAsync(getProfileCallback) 2469 swiftApi().getProfileAsync(getProfileCallback)
...@@ -2473,6 +2474,15 @@ public class swiftApi { ...@@ -2473,6 +2474,15 @@ public class swiftApi {
2473 dynatraceEvent._parameters = nil 2474 dynatraceEvent._parameters = nil
2474 SwiftEventBus.post("dynatrace", sender: dynatraceEvent) 2475 SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
2475 2476
2477 + verifyTicketCallback(tempResponse);
2478 + }
2479 +
2480 + } else {
2481 + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
2482 + dynatraceEvent._eventName = "custom_error_login_loyalty"
2483 + dynatraceEvent._parameters = nil
2484 + SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
2485 +
2476 verifyTicketCallback(nil) 2486 verifyTicketCallback(nil)
2477 } 2487 }
2478 2488
......