//
//  MVMCoreErrorObject.h
//  myverizon
//
//  Created by Scott Pfeil on 3/6/14.
//  Copyright (c) 2014 Verizon Wireless. All rights reserved.
//
//  An object that keeps track of error details.

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface MVMCoreErrorObject : NSObject

// error information
@property (nullable, strong, nonatomic) NSString *title;
@property (nullable, strong, nonatomic) NSString *messageToDisplay;
@property (nullable, strong, nonatomic) NSString *messageToLog;
@property (nullable, strong, nonatomic) NSString *domain;
@property (nullable, strong, nonatomic) NSString *location;
@property (nullable, strong, nonatomic) NSDate *date;
@property (nullable, strong, nonatomic) NSString *systemDomain;
@property (nonatomic) NSInteger code;
@property (nonatomic) UIApplicationState applicationState;

// For the crash log.
@property (nullable, strong, nonatomic) NSDictionary *crashLog;

// A flag for if the error is silent or not (displayed to the user)
@property (nonatomic) BOOL silentError;

// A flag for if the error should be logged. (Used in the standardrequestprotocol flow).
@property (nonatomic) BOOL logError;

// A flag for keeping track if this is an error screen error.
@property (nonatomic) BOOL errorScreenError;
@property (nonatomic) BOOL nativeDrivenErrorScreen;
// For SSL Pinning
// A flag for keeping track if this is an SSL error.
@property (nonatomic) BOOL sslError;

// Creates an object with the given error info.
- (nullable instancetype)initWithTitle:(nullable NSString *)title message:(nullable NSString *)message code:(NSInteger)code domain:(nullable NSString *)domain location:(nullable NSString *)location;
- (nullable instancetype)initWithTitle:(nullable NSString *)title messageToLog:(nullable NSString *)messageToLog code:(NSInteger)code domain:(nullable NSString *)domain location:(nullable NSString *)location;
- (nullable instancetype)initWithTitle:(nullable NSString *)title message:(nullable NSString *)message messageToLog:(nullable NSString *)messageToLog code:(NSInteger)code domain:(nullable NSString *)domain location:(nullable NSString *)location;

// Creates and returns an error object for the load object. May be nil.
+ (nullable instancetype)createErrorObjectForErrorInfo:(nullable NSDictionary *)errorInfo location:(nullable NSString *)location;

// Creates and returns an error object for the NSError. May be nil.
+ (nullable instancetype)createErrorObjectForNSError:(nonnull NSError *)error location:(nullable NSString *)location;

// Initializes the error object with a given crash log.
- (nullable instancetype)initWithCrashLog:(nullable NSDictionary *)crashLog;

// Returns the error code as readable string and appends a signifier for domain.
- (nonnull NSString *)stringErrorCode;

// Returns the error code as readable string and appends a signifier for domain.
+ (nonnull NSString *)stringErrorCode:(NSInteger)code domain:(nonnull NSString *)domain;

// Returns the state of the application when the error occurred.
- (nonnull NSString *)stringApplicationState;

@end
