hardcode json

This commit is contained in:
Suresh, Kamlesh 2019-05-08 14:58:55 -04:00
parent 00058468c1
commit 4d86d201df
3 changed files with 14 additions and 2 deletions

View File

@ -293,7 +293,7 @@
- (nullable NSURLSessionTask *)sendRequest:(nonnull MVMCoreRequestParameters *)requestParameters locationForError:(nonnull NSString *)locationForError requestFinished:(nullable void (^)(id _Nullable jsonObject, MVMCoreErrorObject *_Nullable error))requestFinished {
#if ENABLE_HARD_CODED_RESPONSE
NSDictionary *response = [[MFHardCodedServerResponse sharedInstance] getHardCodedResponseForRequest:requestParameters];
NSDictionary *response = [[MFHardCodedServerResponse new] getHardCodedResponseForPageType:requestParameters.pageType];
if (response) {
if (requestFinished) {
requestFinished(response, nil);

View File

@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import "MVMCoreRequestParameters.h"
#define ENABLE_HARD_CODED_RESPONSE 0 && DEBUG
#define ENABLE_HARD_CODED_RESPONSE 1 && DEBUG
#if ENABLE_HARD_CODED_RESPONSE
@ -19,6 +19,8 @@
- (NSDictionary *) getHardCodedResponseForRequest:(MVMCoreRequestParameters *)request;
- (NSDictionary *) getHardCodedResponseForPageType:(NSString *)pageType;
@end
#endif

View File

@ -56,6 +56,16 @@
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 *cannedResponse = nil;