//
//  MFFreebeeHandler.h
//  mobilefirst
//
//  Created by Patrick Sommer on 1/3/17.
//  Copyright © 2017 Verizon Wireless. All rights reserved.
//

#import <Foundation/Foundation.h>

@class FreeBeeAuthObject;
@class MVMCoreOperation;
@class MFFreebeeOperation;

typedef void(^FreebeeLoadFinishedHandler)(MVMCoreOperation* _Nullable freebeeOperation, BOOL isValid);

@interface MFFreebeeHandler : NSObject

@property(nullable, nonatomic, strong, readonly) FreeBeeAuthObject* freeBeeAuthObj;

@property(nonatomic, readonly) BOOL isValidCampaign;
@property(nonatomic, readonly) MFFreebeeOperation* _Nullable   freebeeOperation;

+ (nullable instancetype)sharedHandler;

- (void)activateFreeBeeIfServerEnabled;
- (void)invalidateFreeBeeState;

- (void)processFreeBeeAuthRequestWithCompletionHandler:(nullable FreebeeLoadFinishedHandler)completionHandler;
- (BOOL)canProceedWithFreebeeAuthRequest;
- (BOOL)isFreeBeeEnabled;
- (BOOL)isExpired;

- (void)enableFreeBeeForCurrentModule:(BOOL)enable;
- (BOOL)isFreeBeeEnabledForCurrentModule;
- (BOOL)isExcludedModule:(nullable NSString*)parentPageType;
- (BOOL)isAllowedPage:(nullable NSString*)pageType;

- (void)printStatusDescription;

- (nullable NSDictionary*)proxyDictionaryforUrl:(nullable NSURL*)url;
- (nullable NSDictionary*)campaignHeaderforUrl:(nullable NSURL*)url;

- (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;

- (void)configureFreeBeeWithDict:(nullable NSDictionary*)configDict withSessionReset:(BOOL)isReset;
@end
