redone in objecitve c
This commit is contained in:
parent
5d92df5347
commit
45b84ae2e0
@ -25,7 +25,6 @@
|
||||
016FF6F2259A4FCC00F5E4AA /* ClientParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */; };
|
||||
016FF6F6259B9AED00F5E4AA /* ClientParameterRegistry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */; };
|
||||
016FF6FC259BA27E00F5E4AA /* ClientParameterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */; };
|
||||
016FF706259D180000F5E4AA /* ActionHandler+ClientParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */; };
|
||||
01934FE725A4FFC2003DCD67 /* ClientParameterActionProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */; };
|
||||
01C851CF23CF7B260021F976 /* JSONMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851CE23CF7B260021F976 /* JSONMap.swift */; };
|
||||
01C851D123CF97FE0021F976 /* ActionBackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C851D023CF97FE0021F976 /* ActionBackModel.swift */; };
|
||||
@ -154,7 +153,6 @@
|
||||
016FF6F1259A4FCC00F5E4AA /* ClientParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterModel.swift; sourceTree = "<group>"; };
|
||||
016FF6F5259B9AED00F5E4AA /* ClientParameterRegistry.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterRegistry.swift; sourceTree = "<group>"; };
|
||||
016FF6FB259BA27E00F5E4AA /* ClientParameterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterProtocol.swift; sourceTree = "<group>"; };
|
||||
016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ActionHandler+ClientParameters.swift"; sourceTree = "<group>"; };
|
||||
01934FE625A4FFC2003DCD67 /* ClientParameterActionProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientParameterActionProtocol.swift; sourceTree = "<group>"; };
|
||||
01C851CE23CF7B260021F976 /* JSONMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONMap.swift; sourceTree = "<group>"; };
|
||||
01C851D023CF97FE0021F976 /* ActionBackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActionBackModel.swift; sourceTree = "<group>"; };
|
||||
@ -585,7 +583,6 @@
|
||||
AFBB96B51FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h */,
|
||||
AFBB96B61FBA3CEC0008D868 /* MVMCoreActionHandler.h */,
|
||||
AFBB96B71FBA3CEC0008D868 /* MVMCoreActionHandler.m */,
|
||||
016FF705259D180000F5E4AA /* ActionHandler+ClientParameters.swift */,
|
||||
);
|
||||
path = ActionHandling;
|
||||
sourceTree = "<group>";
|
||||
@ -810,7 +807,6 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
AFED77A71FCCA29400BAE689 /* MVMCoreViewControllerProgrammaticMappingObject.m in Sources */,
|
||||
016FF706259D180000F5E4AA /* ActionHandler+ClientParameters.swift in Sources */,
|
||||
946EE1A7237B5B1C0036751F /* ModelRegistry.swift in Sources */,
|
||||
AFBB96641FBA3A570008D868 /* MVMCoreLoadHandler.m in Sources */,
|
||||
AFFCFA671FCCC0D700FD0730 /* MVMCoreLoadingOverlayHandler.m in Sources */,
|
||||
|
||||
@ -1,56 +0,0 @@
|
||||
//
|
||||
// ActionHandler+ClientParameters.swift
|
||||
// MVMCore
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 12/30/20.
|
||||
// Copyright © 2020 myverizon. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension MVMCoreActionHandler {
|
||||
|
||||
/// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters.
|
||||
@objc func setClientParameter(with actionMap: [String: Any]?, completionHandler: @escaping ([String : Any]?) -> ()) {
|
||||
|
||||
guard let actionMapWithClientParameters = actionMap, let clientParameters = actionMapWithClientParameters.optionalDictionaryForKey(KeyClientParameters) else {
|
||||
completionHandler(actionMap)
|
||||
return
|
||||
}
|
||||
|
||||
let isBackgroudRequest = actionMapWithClientParameters.boolForKey("background")
|
||||
|
||||
if !isBackgroudRequest {
|
||||
MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.startLoading()
|
||||
}
|
||||
|
||||
let stopLoadingOverlay = {() in
|
||||
if !isBackgroudRequest {
|
||||
MVMCoreLoadingOverlayHandler.sharedLoadingOverlay()?.stopLoading(true)
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
try MVMCoreObject.sharedInstance()?.clientParameterRegistry?.getParameters(with: clientParameters) { (clientParams) in
|
||||
guard let clientParams = clientParams else {
|
||||
stopLoadingOverlay()
|
||||
completionHandler(actionMapWithClientParameters)
|
||||
return
|
||||
}
|
||||
|
||||
var extraParams: [String : Any] = actionMapWithClientParameters.dictionaryForKey(KeyExtraParameters)
|
||||
extraParams.merge(clientParams) { (_, new) in new }
|
||||
var actionMapM = actionMapWithClientParameters
|
||||
actionMapM[KeyExtraParameters] = extraParams
|
||||
|
||||
stopLoadingOverlay()
|
||||
completionHandler(actionMapM)
|
||||
}
|
||||
} catch {
|
||||
stopLoadingOverlay()
|
||||
completionHandler(actionMapWithClientParameters)
|
||||
MVMCoreLoggingHandler.logDebugMessage(withDelegate: "Error clientParamters: \(error)")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -26,6 +26,7 @@
|
||||
#import "MVMCorePresentationDelegateProtocol.h"
|
||||
#import <SafariServices/SafariServices.h>
|
||||
#import <MVMCore/MVMCore-Swift.h>
|
||||
#import "MVMCoreLoadingOverlayHandler.h"
|
||||
|
||||
NSString * const KeyActionType = @"actionType";
|
||||
NSString * const KeyActionTypeLinkAway = @"openURL";
|
||||
@ -128,16 +129,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
}];
|
||||
};
|
||||
|
||||
/*
|
||||
BAU dictionary comparsion breaks if client parameters sets the dictionary.
|
||||
For now we will set client parameters only when its sent in the action map.
|
||||
We can move the code to Objective-C if required.
|
||||
*/
|
||||
if ([actionInformation dict:KeyClientParameters]) {
|
||||
[self setClientParameterWith:actionInformation completionHandler:performAction];
|
||||
} else {
|
||||
performAction(actionInformation);
|
||||
}
|
||||
[self setClientParameter:actionInformation completionHandler:performAction];
|
||||
}
|
||||
|
||||
- (void)shareAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
|
||||
@ -302,16 +294,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
[weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegateObject:delegateObject];
|
||||
};
|
||||
|
||||
/*
|
||||
BAU dictionary comparsion breaks if client parameters sets the dictionary.
|
||||
For now we will set client parameters only when its sent in the action map.
|
||||
We can move the code to Objective-C if required.
|
||||
*/
|
||||
if ([actionInformation dict:KeyClientParameters]) {
|
||||
[self setClientParameterWith:actionInformation completionHandler:performAction];
|
||||
} else {
|
||||
performAction(actionInformation);
|
||||
}
|
||||
[self setClientParameter:actionInformation completionHandler:performAction];
|
||||
}
|
||||
|
||||
- (void)prepareLinkAwayWithURL:(nullable NSURL *)url appURL:(nullable NSURL *)appURL actionInformation:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegateObject:(nullable DelegateObject *)delegateObject {
|
||||
@ -461,16 +444,7 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
}];
|
||||
};
|
||||
|
||||
/*
|
||||
BAU dictionary comparsion breaks if client parameters sets the dictionary.
|
||||
For now we will set client parameters only when its sent in the action map.
|
||||
We can move the code to Objective-C if required.
|
||||
*/
|
||||
if ([actionInformation dict:KeyClientParameters]) {
|
||||
[self setClientParameterWith:actionInformation completionHandler:performAction];
|
||||
} else {
|
||||
performAction(actionInformation);
|
||||
}
|
||||
[self setClientParameter:actionInformation completionHandler:performAction];
|
||||
}
|
||||
|
||||
- (void)restartAction:(nullable NSDictionary *)actionInformation additionalData:(nullable NSDictionary *)additionalData delegate:(nullable NSObject <MVMCoreLoadDelegateProtocol, MVMCorePresentationDelegateProtocol,MVMCoreActionDelegateProtocol>*)delegate {
|
||||
@ -589,15 +563,56 @@ NSString * const KeyActionTypeOpen = @"openPage";
|
||||
[weakSelf prepareLinkAwayWithURL:otherURL appURL:appURL actionInformation:actionMap additionalData:additionalData delegate:delegate];
|
||||
};
|
||||
|
||||
/*
|
||||
BAU dictionary comparsion breaks if client parameters sets the dictionary.
|
||||
For now we will set client parameters only when its sent in the action map.
|
||||
We can move the code to Objective-C if required.
|
||||
*/
|
||||
if ([actionInformation dict:KeyClientParameters]) {
|
||||
[self setClientParameterWith:actionInformation completionHandler:performAction];
|
||||
} else {
|
||||
performAction(actionInformation);
|
||||
[self setClientParameter:actionInformation completionHandler:performAction];
|
||||
}
|
||||
|
||||
/// Iterates through the clientParameters list. Gets values from the individual handlers and attaches the parameters to extraParameters.
|
||||
- (void)setClientParameter:(nullable NSDictionary *)actionInformation completionHandler:(nonnull void (^)(NSDictionary * _Nullable jsonDictionary))completionHandler {
|
||||
|
||||
NSDictionary *clientParametersMap = [actionInformation dict:KeyClientParameters];
|
||||
if (!clientParametersMap) {
|
||||
completionHandler(actionInformation);
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL isBackgroudRequest = [actionInformation boolForKey:@"background"];
|
||||
|
||||
if (!isBackgroudRequest) {
|
||||
[[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] startLoading];
|
||||
}
|
||||
|
||||
void (^stopLoadingOverlay)(void) = ^(void) {
|
||||
if (!isBackgroudRequest) {
|
||||
[[MVMCoreLoadingOverlayHandler sharedLoadingOverlay] stopLoading:true];
|
||||
}
|
||||
};
|
||||
|
||||
NSError *error = nil;
|
||||
[MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Fetching client parameters"];
|
||||
[[[MVMCoreObject sharedInstance] clientParameterRegistry] getParametersWith:clientParametersMap
|
||||
error:&error
|
||||
completionHandler:^(NSDictionary<NSString *,id> * _Nullable clientParameters) {
|
||||
[MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Finshed fetching client parameters"];
|
||||
if (clientParameters) {
|
||||
NSMutableDictionary *actionWithClientParameters = [actionInformation mutableCopy];
|
||||
NSMutableDictionary *extraParameters = [clientParameters mutableCopy];
|
||||
[extraParameters addEntriesFromDictionary:[actionWithClientParameters dictionaryForKey:KeyExtraParameters]];
|
||||
actionWithClientParameters[KeyExtraParameters] = extraParameters;
|
||||
|
||||
stopLoadingOverlay();
|
||||
completionHandler(actionWithClientParameters);
|
||||
} else {
|
||||
[MVMCoreLoggingHandler logDebugMessageWithDelegate:@"No client paramnters"];
|
||||
stopLoadingOverlay();
|
||||
completionHandler(actionInformation);
|
||||
}
|
||||
}];
|
||||
|
||||
if (error) {
|
||||
stopLoadingOverlay();
|
||||
completionHandler(actionInformation);
|
||||
[MVMCoreLoggingHandler logDebugMessageWithDelegate:@"Error clientparameters"];
|
||||
[MVMCoreLoggingHandler logDebugMessageWithDelegate:error.debugDescription];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ import Foundation
|
||||
/// ]
|
||||
///}
|
||||
/// completionHandler can return flat dictinary or a map. It depends on the paramters handler
|
||||
func getParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws {
|
||||
open func getParameters(with clientParameters: [String: Any], completionHandler:@escaping ([String: Any]?) -> ()) throws {
|
||||
|
||||
guard let clientParameterModel = try ClientParameterRegistry.getClientParameterModel(clientParameters) else {
|
||||
completionHandler(nil)
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MVMCoreRequestParameters.h"
|
||||
|
||||
#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG
|
||||
#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG
|
||||
|
||||
#if ENABLE_HARD_CODED_RESPONSE
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user