Merge branch 'develop' of gitlab.verizon.com:BPHV_MIPS/mvm_core into develop

This commit is contained in:
Suresh, Kamlesh 2020-05-27 11:35:52 -04:00
commit ebbf922500
5 changed files with 29 additions and 10 deletions

View File

@ -35,6 +35,8 @@
#pragma mark - Request Functions. #pragma mark - Request Functions.
- (void)setHeadersForRequest:(nonnull NSMutableURLRequest *)request requestParameters:(nonnull MVMCoreRequestParameters *)requestParameters;
// Creates a request object with the given parameters. // Creates a request object with the given parameters.
- (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error; - (nullable NSURLRequest *)requestWithParameters:(nonnull MVMCoreRequestParameters *)requestParameters error:(MVMCoreErrorObject *_Nonnull *_Nonnull)error;

View File

@ -35,15 +35,7 @@
@implementation MVMCoreLoadHandler @implementation MVMCoreLoadHandler
+ (nullable instancetype)sharedGlobal { + (nullable instancetype)sharedGlobal {
static dispatch_once_t once; return [MVMCoreActionUtility initializerClassCheck:[MVMCoreObject sharedInstance].loadHandler classToVerify:self];
static id sharedInstance;
dispatch_once(&once, ^
{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
} }
- (instancetype)init { - (instancetype)init {
@ -234,7 +226,7 @@
return boundary; return boundary;
} }
- (void)setHeadersForRequest:(NSMutableURLRequest *)request requestParameters:(MVMCoreRequestParameters *)requestParameters { - (void)setHeadersForRequest:(nonnull NSMutableURLRequest *)request requestParameters:(nonnull MVMCoreRequestParameters *)requestParameters {
[request setHTTPMethod:@"POST"]; [request setHTTPMethod:@"POST"];
[request setValue:@"no-cache, no-store" forHTTPHeaderField:@"Cache-Control"]; [request setValue:@"no-cache, no-store" forHTTPHeaderField:@"Cache-Control"];

View File

@ -61,4 +61,26 @@ extension Decodable {
} }
} }
public enum DecoderKeyError: Error {
case createKey
}
public extension JSONDecoder {
/// Adds a delegate object to the decoder for use in the model initializers.
func add<T: DelegateObject>(delegateObject: T) throws {
guard let key = CodingUserInfoKey(rawValue: "delegateObject") else {
throw DecoderKeyError.createKey
}
userInfo.updateValue(delegateObject, forKey: key)
}
}
public extension Decoder {
/// Gets a delegate object from the decoder for use in the model initializers. Had to be added before decode.
func get<T: DelegateObject>() throws -> T? {
guard let key = CodingUserInfoKey(rawValue: "delegateObject") else {
throw DecoderKeyError.createKey
}
return userInfo[key] as? T
}
}

View File

@ -17,6 +17,7 @@
#import <MVMCore/MVMCoreLoggingDelegateProtocol.h> #import <MVMCore/MVMCoreLoggingDelegateProtocol.h>
#import <MVMCore/MVMCoreGlobalTopAlertDelegateProtocol.h> #import <MVMCore/MVMCoreGlobalTopAlertDelegateProtocol.h>
#import <MVMCore/MVMCoreLoggingHandler.h> #import <MVMCore/MVMCoreLoggingHandler.h>
#import <MVMCore/MVMCoreLoadHandler.h>
@interface MVMCoreObject : NSObject @interface MVMCoreObject : NSObject
@ -25,6 +26,7 @@
@property (nullable, strong, nonatomic) MVMCoreViewControllerMappingObject *viewControllerMapping; @property (nullable, strong, nonatomic) MVMCoreViewControllerMappingObject *viewControllerMapping;
@property (nullable, strong, nonatomic) MVMCoreActionHandler *actionHandler; @property (nullable, strong, nonatomic) MVMCoreActionHandler *actionHandler;
@property (nullable, strong, nonatomic) MVMCoreSessionTimeHandler *sessionHandler; @property (nullable, strong, nonatomic) MVMCoreSessionTimeHandler *sessionHandler;
@property (nullable, strong, nonatomic) MVMCoreLoadHandler *loadHandler;
// The delegates // The delegates
@property (nullable, strong, nonatomic) id <MVMCoreGlobalLoadProtocol> globalLoadDelegate; @property (nullable, strong, nonatomic) id <MVMCoreGlobalLoadProtocol> globalLoadDelegate;

View File

@ -26,6 +26,7 @@
self.sessionHandler = [[MVMCoreSessionTimeHandler alloc] init]; self.sessionHandler = [[MVMCoreSessionTimeHandler alloc] init];
self.actionHandler = [[MVMCoreActionHandler alloc] init]; self.actionHandler = [[MVMCoreActionHandler alloc] init];
self.loggingDelegate = [[MVMCoreLoggingHandler alloc] init]; self.loggingDelegate = [[MVMCoreLoggingHandler alloc] init];
self.loadHandler = [[MVMCoreLoadHandler alloc] init];
} }
@end @end