Updates to iOS ApiClient - added getting for for offline state and settings for reachability status. This addresses "Default iOS reachability status #2422"

This commit is contained in:
Stuart Campbell 2016-03-22 10:56:56 +00:00
parent 0941db6fbd
commit 553ebd659a
6 changed files with 48 additions and 2 deletions

View File

@ -53,6 +53,10 @@ static void (^reachabilityChangeBlock)(int);
cacheEnabled = enabled; cacheEnabled = enabled;
} }
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus)status {
reachabilityStatus = status;
}
- (void)setHeaderValue:(NSString*) value - (void)setHeaderValue:(NSString*) value
forKey:(NSString*) forKey { forKey:(NSString*) forKey {
[self.requestSerializer setValue:value forHTTPHeaderField:forKey]; [self.requestSerializer setValue:value forHTTPHeaderField:forKey];
@ -238,6 +242,10 @@ static void (^reachabilityChangeBlock)(int);
return reachabilityStatus; return reachabilityStatus;
} }
+(bool) getOfflineState {
return offlineState;
}
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock { +(void) setReachabilityChangeBlock:(void(^)(int))changeBlock {
reachabilityChangeBlock = changeBlock; reachabilityChangeBlock = changeBlock;
} }

View File

@ -64,6 +64,20 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
*/ */
+(void) setOfflineState:(BOOL) state; +(void) setOfflineState:(BOOL) state;
/**
* Gets if the client is unreachable
*
* @return The client offline state
*/
+(bool) getOfflineState;
/**
* Sets the client reachability, this may be override by the reachability manager if reachability changes
*
* @param The client reachability.
*/
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus) status;
/** /**
* Gets the client reachability * Gets the client reachability
* *

View File

@ -73,6 +73,20 @@ extern NSString *const SWGResponseObjectErrorKey;
*/ */
+(void) setOfflineState:(BOOL) state; +(void) setOfflineState:(BOOL) state;
/**
* Gets if the client is unreachable
*
* @return The client offline state
*/
+(bool) getOfflineState;
/**
* Sets the client reachability, this may be override by the reachability manager if reachability changes
*
* @param The client reachability.
*/
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus) status;
/** /**
* Gets the client reachability * Gets the client reachability
* *

View File

@ -53,6 +53,10 @@ static void (^reachabilityChangeBlock)(int);
cacheEnabled = enabled; cacheEnabled = enabled;
} }
+(void) setReachabilityStatus:(AFNetworkReachabilityStatus)status {
reachabilityStatus = status;
}
- (void)setHeaderValue:(NSString*) value - (void)setHeaderValue:(NSString*) value
forKey:(NSString*) forKey { forKey:(NSString*) forKey {
[self.requestSerializer setValue:value forHTTPHeaderField:forKey]; [self.requestSerializer setValue:value forHTTPHeaderField:forKey];
@ -238,6 +242,10 @@ static void (^reachabilityChangeBlock)(int);
return reachabilityStatus; return reachabilityStatus;
} }
+(bool) getOfflineState {
return offlineState;
}
+(void) setReachabilityChangeBlock:(void(^)(int))changeBlock { +(void) setReachabilityChangeBlock:(void(^)(int))changeBlock {
reachabilityChangeBlock = changeBlock; reachabilityChangeBlock = changeBlock;
} }

View File

@ -17,4 +17,6 @@
@property(nonatomic) NSNumber* name; @property(nonatomic) NSNumber* name;
@property(nonatomic) NSNumber* snakeCase;
@end @end

View File

@ -20,7 +20,7 @@
*/ */
+ (JSONKeyMapper *)keyMapper + (JSONKeyMapper *)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"name": @"name" }]; return [[JSONKeyMapper alloc] initWithDictionary:@{ @"name": @"name", @"snake_case": @"snakeCase" }];
} }
/** /**
@ -30,7 +30,7 @@
*/ */
+ (BOOL)propertyIsOptional:(NSString *)propertyName + (BOOL)propertyIsOptional:(NSString *)propertyName
{ {
NSArray *optionalProperties = @[@"name"]; NSArray *optionalProperties = @[@"name", @"snakeCase"];
if ([optionalProperties containsObject:propertyName]) { if ([optionalProperties containsObject:propertyName]) {
return YES; return YES;