//
//  SCAdEvent.h
//  SCTVOSSDK
//
//  Copyright © 2018 smartclip. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
/**
 * This class describes a certain adEvent, as being sent for eventCallbacks.
 */
@interface SCAdEvent : NSObject

///EventType: type of events that are fired during the progress of an ad slot.
typedef enum EventType {

    /**
     * Indicates the intial undefined state.
     */
    EVENT_TYPE_UNDEFINED = -1,

    /**
     * Is fired when the user clicks on the ad.
     */
    ON_AD_CLICKED,

    ON_AD_CREATIVE_VIEW,

    /**
     * Is fired when requesting or parsing of the manifest failed, also when ad playback failed.
     * Check Event.errorCode (or Event.info.errorCode) and the IAB VAST 4.0 Error Codes Table
     * for details.
     */
    ON_AD_ERROR,

    /**
     * Is fired when a single ad has been stopped. _(!) Double‐check the attribute adVariant to find out
     * whether this is the last ad or see {@code ON_AD_SLOTCOMPLETE}.
     */
    ON_AD_FINISHED,

    /**
     * Is fired when the playback of a single ad has reached 25%.
     */
    ON_AD_FIRST_QUARTILE,

    /**
     * Is fired when the user‐visible phase of the ad has begun.
     */
    ON_AD_IMPRESSION,

    /**
     * Is fired when a VPAID ad changes its linearity.
     */
    ON_AD_LINEARITY_CHANGE,

    /**
     * Is fired when the ad manifest (VAST tag) has been loaded.
     */
    ON_AD_MANIFEST_LOADED,

    /**
     * Is fired when the playback of a single ad has reached 50%.
     */
    ON_AD_MID_POINT,


    ON_AD_MUTED,

    /**
     * Is fired when the playback of a single ad has been paused.
     */
    ON_AD_PAUSED,

    /**
     * Is fired when the playback of a single ad has been finished and reached 100%.
     */
    ON_AD_PLAYBACK_FINISHED,

    /**
     * Is fired when the playback of a single ad has been started, 0%.
     */
    ON_AD_PLAYBACK_START,

    /**
     * Is fired when the playback of a single ad has been resumed.
     */
    ON_AD_PLAYING,

    ON_AD_PROGRESS,

    ON_AD_REINSERTION_ACTIVATION,

    /**
     * Is fired when an ad manifest (VAST tag) was parsed and the ads have been added onto the
     * queue.
     */
    ON_AD_SCHEDULED,

    ON_AD_SIZE_CHANGED,

    /**
     * Is fired when an advertisement becomes skippable.
     */
    ON_AD_SKIPPABLE_STATE_CHANGE,

    /**
     * Is fired when an ad has been skipped.
     */
    ON_AD_SKIPPED,

    /**
     * Is fired when an ad‐break has been finished, regardless whether the requested ad
     * manifest contained valid ads or not.
     */
    ON_AD_SLOT_COMPLETE,

    /**
     * Is fired when the playback of all ads for the current ad‐break has finished, most likely
     * after the CLOSER.
     */
    ON_AD_SLOT_FINISHED,

    /**
     * Is fired when an ad‐break has been requested.
     */
    ON_AD_SLOT_START,

    ON_AD_SLOT_STARTED,

    ON_AD_START,

    /**
     * Is fired when the playback of an ad has been started.
     */
    ON_AD_STARTED,

    /**
     * Is fired when the playback of a single ad has reached 75%.
     */
    ON_AD_THIRD_QUARTILE,

    ON_AD_UNMUTED,

    ON_AD_VOLUME_CHANGED,

    ON_AD_WARNING,

    ON_CLOSED_CAPTIONS_DETECTED,

    /**
     * Is fired when a manifest contains <Companion> ads. Companion ads can be requested through the API property
     * adCompanions
     */
    ON_AD_COMPANIONS_DETECTED,

    ON_COMPANION_CLICKED,

    ON_COMPANION_CREATIVE_VIEW,

    /**
     * Is fired when a manifest contains <Extension> nodes. Extensions can be requested through the API property
     * adExtensions
     */
    ON_EXTENSIONS_DETECTED,

    ON_GENERAL_ERROR,

    /**
     * Is fired once the add-on is going to request resources through HOMAD. Requires that HOMAD has been enabled during the player setup. See HOMAD Prerequisites
     */
    ON_HOMAD_ACTIVATION,

    /**
     * Is fired when the HOMAD initialization has failed (ex: wrong clientConfig) or when HOMAD detected issues while requesting an ad.
     */
    ON_HOMAD_PENALTY,

    ON_ICONS_DETECTED,

    ON_ICON_CLICKED,

    ON_PLAYBACK_FINISHED,

    ON_VERFICATION_DETECTED

} EventType;

///Event type
@property (nonatomic)       EventType          type;

///Always smartclip
@property (nonatomic, copy) NSString           *issuer;

///Adopted from the Bitmovin Player Events. Current client time
@property (nonatomic)       NSTimeInterval      timestamp;

/**
 * Initalizer, takes a JSON formatted description string
 * - Parameter description: description as JSON formatted string
 */
- (id)initWithDescription:(NSString*)description;

/**
 * Gives back a string describing the current event
 */
- (NSString*)eventString;
@end

NS_ASSUME_NONNULL_END
