Swift code for webPunchOut UAD pages

This commit is contained in:
teegsh2 2024-08-29 15:36:20 +05:30
parent 884e0988df
commit 06dbe2c1a0
2 changed files with 28 additions and 17 deletions

View File

@ -135,3 +135,30 @@ public extension NavigationHandler {
try await NavigationHandler.shared().navigate(with: getOperationPopToViewController(with: pageType, navigationController: navigationController, delegateObject: delegateObject, animated: animated))
}
}
@objc
public extension MVMCoreLoadRequestOperation {
@objc static func fetchJsonForPageType(requestParameter: MVMCoreRequestParameters, completion: @escaping (([AnyHashable: Any]?, [AnyHashable: Any]?) -> Void)) {
MVMCoreCache.shared()?.fetchJSON(forPageType: requestParameter.pageType, completionHandler: { jsonDictionary in
if requestParameter.pageType == "webPunchOut_UAD" {
guard var jsonDictionary = jsonDictionary,
let actionMap = requestParameter.actionMap,
let extraParameters = actionMap["extraParameters"] as? [String: String],
let flowName = extraParameters["flowName"] else {
return
}
MVMCoreCache.shared()?.fetchJSON(forModule: flowName, completionHandler: { moduleDictionary in
guard let moduleDictionary = moduleDictionary,
let punchOut = moduleDictionary[flowName] as? [String: String],
let browserUrl = punchOut["browserUrl"] else {
return
}
jsonDictionary["browserUrl"] = browserUrl
completion(jsonDictionary, nil)
})
} else {
completion(jsonDictionary, nil)
}
})
}
}

View File

@ -236,24 +236,8 @@
}];
}];
} else if (requestParameters.pageType.length != 0) {
// Check cache function if page json is already in the cache.
[[MVMCoreCache sharedCache] fetchJSONForPageType:requestParameters.pageType completionHandler:^(NSDictionary * _Nullable jsonDictionary) {
if ([requestParameters.pageType isEqualToString:@"webPunchOut_UAD"]) {
NSMutableDictionary *newJsonDictionary = [jsonDictionary mutableCopy];
NSString *flowName = requestParameters.actionMap[@"extraParameters"][@"flowName"];
[[MVMCoreCache sharedCache] fetchJSONForModule: flowName completionHandler:^(NSDictionary * _Nullable moduleJsonDictionary) {
if (moduleJsonDictionary[flowName] != NULL && moduleJsonDictionary[flowName][@"browserUrl"] != NULL) {
[newJsonDictionary setObject: moduleJsonDictionary[flowName][@"browserUrl"] forKey:@"browserUrl"];
completionHandler(newJsonDictionary, nil);
}
}];
//jsonDictionary[@"browserUrl"] =
} else {
completionHandler(jsonDictionary,nil);
}
}];
[self fetchJsonForPageTypeWithRequestParameter: requestParameters completion: completionHandler];
} else if (modules > 0) {