Consolidation
This commit is contained in:
parent
374ae5973a
commit
5e8d96a96c
@ -44,6 +44,7 @@ typedef void(^FreebeeLoadFinishedHandler)(MVMCoreOperation* _Nullable freebeeOpe
|
||||
- (BOOL)isFreeBeeAuthorizedValidUrl:(nullable NSURL*)url;
|
||||
- (nullable NSString*)urlForidFromConfigDict:(nonnull NSString*)urlId;
|
||||
|
||||
// Tries to get the data using freebee. If freebee is not enabled, gets the data without freebee.
|
||||
- (nullable NSData*)freebee_dataWithContentsOfURL:(NSURL *_Nullable)url;
|
||||
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *_Nullable)imageURL;
|
||||
|
||||
|
||||
@ -230,25 +230,29 @@ typedef NS_ENUM(NSUInteger, FreeBeeCampaignState) {
|
||||
}
|
||||
|
||||
#pragma mark FreeBee Helper for NSData
|
||||
- (nullable NSData*)freebee_dataWithContentsOfURL:(NSURL *)url {
|
||||
|
||||
NSData* data = nil;
|
||||
NSDictionary* proxyDict = [self proxyDictionaryforUrl:url];
|
||||
|
||||
- (nullable NSData *)freebeeDataWithURL:(NSURL *)url response:(NSURLResponse **)response {
|
||||
NSData *data = nil;
|
||||
NSDictionary *proxyDict = [self proxyDictionaryforUrl:url];
|
||||
|
||||
if ([self isFreeBeeEnabled] &&
|
||||
[self isValidCampaign] && proxyDict &&
|
||||
![self isExpired] && [self isFreeBeeEnabledForCurrentModule]) {
|
||||
|
||||
MVMCoreLog(@"Free Data Url, %@", url);
|
||||
NSError *error = nil;
|
||||
data = [self sendSynchronousRequest:url returningResponse:response error:&error];
|
||||
if (error) {
|
||||
data = nil;
|
||||
}
|
||||
MVMCoreLog(@"freebee_dataWithContentsOfURL:Free Data, %lu", (unsigned long)data.length);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
MVMCoreLog(@"Free Data Url, %@", url);
|
||||
NSURLResponse* response = nil;
|
||||
NSError* error = nil;
|
||||
data = [self sendSynchronousRequest:url returningResponse:&response error:&error];
|
||||
|
||||
if (error)
|
||||
data = nil;
|
||||
|
||||
MVMCoreLog(@"freebee_dataWithContentsOfURL:Free Data, %lu", (unsigned long)data.length);
|
||||
} else {
|
||||
- (nullable NSData*)freebee_dataWithContentsOfURL:(NSURL *)url {
|
||||
NSData *data = [self freebeeDataWithURL:url response:nil];
|
||||
if (!data) {
|
||||
data = [NSData dataWithContentsOfURL:url];
|
||||
}
|
||||
return data;
|
||||
@ -256,23 +260,9 @@ typedef NS_ENUM(NSUInteger, FreeBeeCampaignState) {
|
||||
|
||||
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *)imageURL {
|
||||
|
||||
NSData* data = nil;
|
||||
NSDictionary* proxyDict = [self proxyDictionaryforUrl:imageURL];
|
||||
|
||||
if ([self isFreeBeeEnabled] &&
|
||||
[self isValidCampaign] && proxyDict &&
|
||||
![self isExpired] && [self isFreeBeeEnabledForCurrentModule]) {
|
||||
|
||||
MVMCoreLog(@"Free Image Data Url, %@", imageURL);
|
||||
NSURLResponse* response = nil;
|
||||
NSError* error = nil;
|
||||
data = [self sendSynchronousRequest:imageURL returningResponse:&response error:&error];
|
||||
|
||||
if (error) {
|
||||
data = nil;
|
||||
}
|
||||
|
||||
MVMCoreLog(@"freebee_dataWithImageURL:Free Image Data, %lu", (unsigned long)data.length);
|
||||
NSURLResponse *response = nil;
|
||||
NSData *data = [self freebeeDataWithURL:imageURL response:&response];
|
||||
if (data) {
|
||||
NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data];
|
||||
return cachedResponse;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user