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;
|
- (BOOL)isFreeBeeAuthorizedValidUrl:(nullable NSURL*)url;
|
||||||
- (nullable NSString*)urlForidFromConfigDict:(nonnull NSString*)urlId;
|
- (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 NSData*)freebee_dataWithContentsOfURL:(NSURL *_Nullable)url;
|
||||||
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *_Nullable)imageURL;
|
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *_Nullable)imageURL;
|
||||||
|
|
||||||
|
|||||||
@ -230,25 +230,29 @@ typedef NS_ENUM(NSUInteger, FreeBeeCampaignState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark FreeBee Helper for NSData
|
#pragma mark FreeBee Helper for NSData
|
||||||
- (nullable NSData*)freebee_dataWithContentsOfURL:(NSURL *)url {
|
|
||||||
|
- (nullable NSData *)freebeeDataWithURL:(NSURL *)url response:(NSURLResponse **)response {
|
||||||
NSData* data = nil;
|
NSData *data = nil;
|
||||||
NSDictionary* proxyDict = [self proxyDictionaryforUrl:url];
|
NSDictionary *proxyDict = [self proxyDictionaryforUrl:url];
|
||||||
|
|
||||||
if ([self isFreeBeeEnabled] &&
|
if ([self isFreeBeeEnabled] &&
|
||||||
[self isValidCampaign] && proxyDict &&
|
[self isValidCampaign] && proxyDict &&
|
||||||
![self isExpired] && [self isFreeBeeEnabledForCurrentModule]) {
|
![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);
|
- (nullable NSData*)freebee_dataWithContentsOfURL:(NSURL *)url {
|
||||||
NSURLResponse* response = nil;
|
NSData *data = [self freebeeDataWithURL:url response:nil];
|
||||||
NSError* error = nil;
|
if (!data) {
|
||||||
data = [self sendSynchronousRequest:url returningResponse:&response error:&error];
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
data = nil;
|
|
||||||
|
|
||||||
MVMCoreLog(@"freebee_dataWithContentsOfURL:Free Data, %lu", (unsigned long)data.length);
|
|
||||||
} else {
|
|
||||||
data = [NSData dataWithContentsOfURL:url];
|
data = [NSData dataWithContentsOfURL:url];
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
@ -256,23 +260,9 @@ typedef NS_ENUM(NSUInteger, FreeBeeCampaignState) {
|
|||||||
|
|
||||||
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *)imageURL {
|
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *)imageURL {
|
||||||
|
|
||||||
NSData* data = nil;
|
NSURLResponse *response = nil;
|
||||||
NSDictionary* proxyDict = [self proxyDictionaryforUrl:imageURL];
|
NSData *data = [self freebeeDataWithURL:imageURL response:&response];
|
||||||
|
if (data) {
|
||||||
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);
|
|
||||||
NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data];
|
NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data];
|
||||||
return cachedResponse;
|
return cachedResponse;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user