Manos Chorianopoulos

jwt changes logout

......@@ -50,7 +50,8 @@
- (NSMutableArray *)getTagsCategories;
- (NSMutableArray *)getTags;
- (NSDictionary *)login:(NSString *)id password:(NSString *)password loginType:(NSString*) loginType;
- (NSDictionary *)logout;
// - (NSDictionary *)logout;
- (void) logout:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (NSDictionary *)register:(NSString *)id password:(NSString *)password name:(NSString*)name email:(NSString*)email segmentation:(NSNumber*)segmentation newsletter:(NSNumber*)newsletter;
- (NSDictionary *)registerAutoLogin:(NSString *)id password:(NSString *)password name:(NSString*)name email:(NSString*)email segmentation:(NSNumber*)segmentation newsletter:(NSNumber*)newsletter loginType:(NSString*)loginType;
- (NSDictionary *)refreshToken;
......
......@@ -638,10 +638,23 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
return resp;
}
- (NSDictionary *)logout {
NSDictionary *response = [NSDictionary alloc];
response = [[Warply sharedService] logout];
return response;
// - (NSDictionary *)logout {
// NSDictionary *response = [NSDictionary alloc];
// response = [[Warply sharedService] logout];
// return response;
// }
- (void) logout:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] logout:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (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()
- (void)loginWithSuccessBlock:(NSString*)id andPassword:(NSString*)password andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (NSDictionary*)logout;
// - (NSDictionary*)logout;
- (void)logout:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)webAuthorizeWithSuccessBlock:(NSDictionary*)contextResponse andId:(NSString*)id andLoginType:(NSString*)loginType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
......@@ -7590,10 +7590,55 @@ public class swiftApi {
}
// public func logout(_ logoutCallback: @escaping (_ responseData: VerifyTicketResponseModel?) -> Void) -> Void {
// let instanceOfMyApi = MyApi()
// let responseData = instanceOfMyApi.logout() as [AnyHashable: Any]?
// if let responseDataDictionary = responseData as? [String: Any] {
// let tempResponse = VerifyTicketResponseModel(dictionary: responseDataDictionary)
// if (tempResponse.getStatus == 1) {
// let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
// dynatraceEvent._eventName = "custom_success_logout_loyalty"
// dynatraceEvent._parameters = nil
// SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
// swiftApi().setUserTag("")
// swiftApi().setUserNonTelco(false)
// swiftApi().setCCMSLoyaltyCampaigns(campaigns: [])
// let accessToken = instanceOfMyApi.getAccessTokenM()
// print("=================== TOKEN DELETED =========================")
// print("Bearer: ", accessToken)
// print("=================== TOKEN DELETED =========================")
// } else {
// let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
// dynatraceEvent._eventName = "custom_error_logout_loyalty"
// dynatraceEvent._parameters = nil
// SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
// }
// logoutCallback(tempResponse);
// } else {
// let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
// dynatraceEvent._eventName = "custom_error_logout_loyalty"
// dynatraceEvent._parameters = nil
// SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
// logoutCallback(nil)
// }
// }
public func logout(_ logoutCallback: @escaping (_ responseData: VerifyTicketResponseModel?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
let responseData = instanceOfMyApi.logout() as [AnyHashable: Any]?
instanceOfMyApi.logout(successCallback, failureBlock: failureCallback)
func successCallback(_ responseData: [AnyHashable : Any]?) -> Void {
if let responseDataDictionary = responseData as? [String: Any] {
......@@ -7633,6 +7678,17 @@ public class swiftApi {
}
}
func failureCallback(_ error: Error?) -> Void {
let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
dynatraceEvent._eventName = "custom_error_logout_loyalty"
dynatraceEvent._parameters = nil
SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
logoutCallback(nil)
}
}
public func didReceiveNotification(_ payload: [String : Any]) -> Void {
......