Merge branch 'feature/open_page_url' into 'develop'

Adds url and base url for open page.

See merge request BPHV_MIPS/mvm_core!140
This commit is contained in:
Pfeil, Scott Robert 2021-01-28 12:49:27 -05:00
commit d545af3278
4 changed files with 42 additions and 29 deletions

View File

@ -110,34 +110,32 @@
- (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error {
NSURL *url = nil;
if (requestParameters.alternateBaseURL) {
url = requestParameters.alternateBaseURL;
} else {
url = [MVMCoreSessionObject sharedGlobal].baseURL;
}
NSURL *url = requestParameters.URL;
if (!url) {
url = [NSURL URLWithString:URLProdPostpayBase];
if (requestParameters.alternateBaseURL) {
url = requestParameters.alternateBaseURL;
} else {
url = [MVMCoreSessionObject sharedGlobal].baseURL ?: [NSURL URLWithString:URLProdPostpayBase];
}
// Appends the context root.
if (requestParameters.contextRoot) {
url = [url URLByAppendingPathComponent:requestParameters.contextRoot];
} else if ([MVMCoreSessionObject sharedGlobal].contextRoot) {
url = [url URLByAppendingPathComponent:[MVMCoreSessionObject sharedGlobal].contextRoot];
}
// Appends the page type
if (requestParameters.pageType) {
url = [url URLByAppendingPathComponent:requestParameters.pageType];
}
// This has changed since the initial agreement. Seems server always needs page type now.
/* else if (requestParameters.modules) {
url = [url URLByAppendingPathComponent:KeyModuleMap];
}*/
}
// Appends the context root.
if (requestParameters.contextRoot) {
url = [url URLByAppendingPathComponent:requestParameters.contextRoot];
} else if ([MVMCoreSessionObject sharedGlobal].contextRoot) {
url = [url URLByAppendingPathComponent:[MVMCoreSessionObject sharedGlobal].contextRoot];
}
// Appends the page type
if (requestParameters.pageType) {
url = [url URLByAppendingPathComponent:requestParameters.pageType];
}
// This has changed since the initial agreement. Seems server always needs page type now.
/* else if (requestParameters.modules) {
url = [url URLByAppendingPathComponent:KeyModuleMap];
}*/
// Adds modules needed to the request parameters.
if (requestParameters.modules.count > 0) {
[requestParameters addRequestParameters:@{KeyModuleList:requestParameters.modules}];

View File

@ -36,9 +36,15 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) {
// adding parent pageType for freebee
@property (nullable, strong, nonatomic) NSString *parentPageType;
// Context root for server
/// App context to use when building the url. For ex: baseURL/appContext/pageType
@property (nullable, strong, nonatomic) NSString *contextRoot;
/// Base URL to use when building the url. For ex: baseURL/appContext/pageType
@property (nullable, strong, nonatomic) NSURL *alternateBaseURL;
/// Entire URL to use instead of building the url
@property (nullable, strong, nonatomic) NSURL *URL;
// A flag for if you do not want to try loading any actual view controller. (Unless there is an error screen)
@property (assign, nonatomic) BOOL noViewControllerToLoad;
@ -82,9 +88,6 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) {
// If the request was created with an action map.
@property (nullable, strong, nonatomic) NSDictionary *actionMap;
// only used when the base url is not the same as mf
@property (nullable, strong, nonatomic) NSURL *alternateBaseURL;
@property (nullable, strong, nonatomic) NSNumber *customTimeoutTime;
// Will open support panel at the end of the load.

View File

@ -66,6 +66,14 @@
if (self = [self initWithPageType:[actionMap stringForKey:KeyPageType] additionalModules:[actionMap array:KeyModuleList] extraParameters:[actionMap dict:KeyExtraParameters]]) {
self.contextRoot = [actionMap string:KeyContextRoot];
NSString *alternateBase = [actionMap string:@"baseURL"];
if (alternateBase) {
self.alternateBaseURL = [NSURL URLWithString:[alternateBase stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet]];
}
NSString *url = [actionMap string:@"URL"];
if (url) {
self.URL = [NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}
self.actionMap = actionMap;
self.customTimeoutTime = [actionMap optionalNumberForKey:@"customTimeoutTime"];
self.openSupportPanel = [actionMap boolForKey:KeyOpenSupport];
@ -136,6 +144,7 @@
copyObject.imageData = self.imageData;
copyObject.customTimeoutTime = self.customTimeoutTime;
copyObject.backgroundRequest = self.backgroundRequest;
copyObject.URL = self.URL;
return copyObject;
}

View File

@ -15,6 +15,9 @@
public static var identifier: String = "openPage"
public var actionType: String = ActionOpenPageModel.identifier
public var pageType: String
public var baseURL: String?
public var appContext: String?
public var URL: String?
public var extraParameters: JSONValueDictionary?
public var analyticsData: JSONValueDictionary?
public var presentationStyle: String?