Merge branch 'feature/url_resolution' into 'develop'
Move URL request resolution to MVMCoreRequestParameters. ### Summary Adjusting request URL resolution to be sooner for page tracking. Co-authored-by: Kyle Matthew Hedden <kyle.hedden@verizonwireless.com> See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core/-/merge_requests/258
This commit is contained in:
commit
6a0be99ce2
@ -134,31 +134,7 @@
|
||||
|
||||
- (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error {
|
||||
|
||||
NSURL *url = requestParameters.URL;
|
||||
if (!url) {
|
||||
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];
|
||||
}*/
|
||||
}
|
||||
NSURL *url = [requestParameters resolveURL:[MVMCoreSessionObject sharedGlobal]];
|
||||
|
||||
// Adds modules needed to the request parameters.
|
||||
if (requestParameters.modules.count > 0) {
|
||||
|
||||
@ -111,6 +111,8 @@
|
||||
- (void)main {
|
||||
MVMCoreLog(@"Load Operation begun for page type %@, background load %@, delegate %@", self.requestParameters.pageType, @(self.backgroundLoad),self.delegateObject.loadDelegate);
|
||||
|
||||
[self.requestParameters resolveURL:[MVMCoreSessionObject sharedGlobal]];
|
||||
|
||||
// Always check for cancellation before launching the task.
|
||||
if ([self checkAndHandleForCancellation]) {
|
||||
return;
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCore/MVMCoreSessionObject.h>
|
||||
|
||||
// The loading style.
|
||||
// MFLoadStyleDefault: This means it has not been explicitely set by the developer. Standard push.
|
||||
@ -124,4 +125,7 @@ typedef NS_ENUM(NSInteger, MFLoadStyle) {
|
||||
/// Returns optional and required modules
|
||||
- (nullable NSArray<NSString *> *)allModules;
|
||||
|
||||
/// Resolves the URL given the session object and the current request parameters.
|
||||
- (nonnull NSURL *)resolveURL:(nonnull MVMCoreSessionObject *)sessionObject;
|
||||
|
||||
@end
|
||||
|
||||
@ -10,9 +10,12 @@
|
||||
#import "NSDictionary+MFConvenience.h"
|
||||
#import "MVMCoreJSONConstants.h"
|
||||
#import "MVMCoreViewControllerMappingObject.h"
|
||||
#import "MVMCoreConstants.h"
|
||||
|
||||
@interface MVMCoreRequestParameters ()
|
||||
|
||||
@property (nonatomic, strong, nullable) NSURL *determinedURL;
|
||||
|
||||
- (nullable instancetype)initWithExtraParameters:(nullable NSDictionary *)extraParameters;
|
||||
|
||||
@end
|
||||
@ -86,6 +89,56 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setAlternateBaseURL:(NSURL *)alternateBaseURL {
|
||||
_alternateBaseURL = alternateBaseURL;
|
||||
_URL = self.determinedURL; // Reset resolution when changed.
|
||||
}
|
||||
|
||||
- (void)setPageType:(NSString *)pageType {
|
||||
_pageType = pageType;
|
||||
_URL = self.determinedURL; // Reset resolution when changed.
|
||||
}
|
||||
|
||||
- (void)setContextRoot:(NSString *)contextRoot {
|
||||
_contextRoot = contextRoot;
|
||||
_URL = self.determinedURL; // Reset resolution when changed.
|
||||
}
|
||||
|
||||
- (void)setURL:(NSURL *)URL {
|
||||
self.determinedURL = URL; // If set directly, this becomes the ultimate URL.
|
||||
_URL = URL;
|
||||
}
|
||||
|
||||
- (NSURL *)resolveURL:(MVMCoreSessionObject *)sessionObject {
|
||||
|
||||
if (self.URL) {
|
||||
// Previously resovled.
|
||||
return self.URL;
|
||||
}
|
||||
|
||||
NSURL *url;
|
||||
if (self.alternateBaseURL) {
|
||||
url = self.alternateBaseURL;
|
||||
} else {
|
||||
url = sessionObject.baseURL ?: [NSURL URLWithString:URLProdPostpayBase];
|
||||
}
|
||||
|
||||
// Appends the context root.
|
||||
if (self.contextRoot) {
|
||||
url = [url URLByAppendingPathComponent:self.contextRoot];
|
||||
} else if (sessionObject.contextRoot) {
|
||||
url = [url URLByAppendingPathComponent:[MVMCoreSessionObject sharedGlobal].contextRoot];
|
||||
}
|
||||
|
||||
// Appends the page type
|
||||
if (self.pageType) {
|
||||
url = [url URLByAppendingPathComponent:self.pageType];
|
||||
}
|
||||
|
||||
_URL = url;
|
||||
return url;
|
||||
}
|
||||
|
||||
- (void)addRequestParameters:(nonnull NSDictionary *)parameters {
|
||||
|
||||
if ([parameters count] > 0) {
|
||||
@ -152,6 +205,7 @@
|
||||
copyObject.customTimeoutTime = self.customTimeoutTime;
|
||||
copyObject.backgroundRequest = self.backgroundRequest;
|
||||
copyObject.URL = self.URL;
|
||||
copyObject.determinedURL = self.determinedURL;
|
||||
copyObject.actionMap = self.actionMap;
|
||||
return copyObject;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user