//
//  APMServicesController.h
//  APMServices
//
//  Created by Vincent Ducastel on 24/07/2015.
//  Copyright (c) 2015 Moonmiles. All rights reserved.
//

#import <CoreLocation/CoreLocation.h>

@class APMEarn;
@class APMUser;
@class APMProg;
@class APMGenerosity;
@class APMGift;
@class APMDevice;
@class APMAction;
@class APMBurn;
@class APMVersions;

@protocol APMServicesListener <NSObject>

-(void)apmServicesOnLoading;
-(void)apmServicesReady:(BOOL)newInfos;
-(void)apmServicesDisable;
-(void)apmServicesUserWinPoints:(APMEarn*)earn user:(APMUser*)user;

@end

@interface APMServices : NSObject<CLLocationManagerDelegate>

@property (weak, nonatomic) id<APMServicesListener> servicesListener;

@property(nonatomic, assign) BOOL sdkLifeCycleEnabled; //If true, life cycle is enabled, false life cycle is disabled
@property(nonatomic, assign) BOOL sdkIsLoading; //Block lifeCycle of badge if userClientConnect or userClientUpdate (APMServicesUser) is launched
@property(nonatomic, assign) BOOL geolocEnabled;

@property(nonatomic, strong) NSString *baseUrl;
@property(nonatomic, strong) NSString *apmVersionCode;
@property(nonatomic, strong) NSString *apmVersionName;
@property(nonatomic, strong) NSString *appID;
@property(nonatomic, strong) NSString *partnerID;
@property(nonatomic, strong) NSString *partnerSecret;

//Models
@property(nonatomic, strong, readonly) APMDevice* device;
@property(nonatomic, strong, readonly) APMProg* prog;
@property(nonatomic, strong, readonly) APMUser* user;
@property(nonatomic, strong, readonly) APMGift* gift;
@property(nonatomic, strong, readonly) APMGenerosity* generosity;
@property(nonatomic, strong, readonly) NSMutableArray *generosities;

@property(nonatomic, strong, readonly) NSMutableArray *status;
@property(nonatomic, strong, readonly) NSMutableDictionary* theme;

@property(nonatomic, strong, readonly) NSString *classID;
@property(nonatomic, strong, readonly) NSMutableArray *frequencies;
@property(nonatomic, strong, readonly) NSMutableArray *values;

//Init
+(APMServices *)sharedInstance;
-(void)initAppWithPartnerID:(NSString*)partnerID withPartnerSecret:(NSString*)partnerSecret;
-(void)initAppWithPartnerID:(NSString*)partnerID withPartnerSecret:(NSString*)partnerSecret withAppId:(NSString*)appId;

//Cycle de vie
-(void)viewWillAppear:(BOOL)animated;
-(void)viewWillAppear:(BOOL)animated classID:(NSString*)classID;
-(void)viewDidAppear:(BOOL)animated;
-(void)viewWillDisappear:(BOOL)animated;
-(void)viewDidDisappear:(BOOL)animated;

//Services
-(void)registerAction:(APMAction*)action;
-(void)removeActionWithActionName:(NSString*)actionName;
-(NSDictionary*)getActionsForClassId:(NSString*)classId;
-(void)selectClassID:(NSString*)classID;
-(void)triggerAction:(NSString*)actionName;
-(void)triggerAuto __attribute__((deprecated(("triggerAuto is DEPRECATED, use triggerAction"))));
-(void)triggerAuto:(NSString*)actionName __attribute__((deprecated(("triggerAuto is DEPRECATED, use triggerAction"))));
-(BOOL)handleOpenURL:(NSURL*)url;

//Getter and Setter
-(BOOL)isInitialLevel;
-(BOOL)debugMode;
-(void)setDebugMode:(BOOL)debugMode;
-(BOOL)servicesIsOnError;
-(BOOL)servicesIsDisabled;

//Other
-(void)resetAll;

@end
