Merge branch 'feature/hardcoded_json' into 'develop'

Feature/hardcoded json

See merge request BPHV_MIPS/mvm_core!14
This commit is contained in:
Hedden, Kyle Matthew 2019-05-10 16:08:22 -04:00
commit 5bb580b6de
2 changed files with 17 additions and 0 deletions

View File

@ -19,6 +19,8 @@
- (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request; - (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request;
- (NSDictionary *) getHardCodedResponseForPageType:(NSString *)pageType;
@end @end
#endif #endif

View File

@ -56,6 +56,16 @@
return self; return self;
} }
- (NSDictionary *) getHardCodedResponseForPageType:(NSString *)pageType {
NSError *error;
NSString *filePath = [[NSBundle mainBundle] pathForResource:pageType ofType:@"json"];
if (filePath) {
return [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:filePath] options:NSJSONReadingMutableContainers error:&error];
}
return nil;
}
- (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request { - (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request {
NSDictionary *cannedResponse = nil; NSDictionary *cannedResponse = nil;
@ -87,6 +97,11 @@
} }
} }
if (!cannedResponse) {
cannedResponse = [self getHardCodedResponseForPageType:request.pageType];
}
return cannedResponse; return cannedResponse;
} }