#pragma once

#include "PokktAdsFunctions.h"
#include "PokktAdsComponent.generated.h"


UCLASS(ClassGroup=Advertising, HideCategories=(Activation, "Components|Activation", Collision), meta=(BlueprintSpawnableComponent))
class UPokktAdsComponent : public UActorComponent
{
	GENERATED_BODY()
	
public:

	/**
	 * Pokkt Delegates
	 **/
	DECLARE_MULTICAST_DELEGATE_ThreeParams(FPKT_AdCachingCompletedDelegate, FString, bool, FString)
	DECLARE_MULTICAST_DELEGATE_ThreeParams(FPKT_AdCachingFailedDelegate, FString, bool, FString)
	DECLARE_MULTICAST_DELEGATE_TwoParams(FPKT_AdClosedDelegate, FString, bool)
	DECLARE_MULTICAST_DELEGATE_TwoParams(FPKT_AdCompletedDelegate, FString, bool)
	DECLARE_MULTICAST_DELEGATE_ThreeParams(FPKT_AdFailedToShowDelegate, FString, bool, FString)
	DECLARE_MULTICAST_DELEGATE_TwoParams(FPKT_AdDisplayedDelegate, FString, bool)
    DECLARE_MULTICAST_DELEGATE_TwoParams(FPKT_AdClickedDelegate, FString, bool)
	DECLARE_MULTICAST_DELEGATE_TwoParams(FPKT_AdSkippedDelegate, FString, bool)
	DECLARE_MULTICAST_DELEGATE_ThreeParams(FPKT_AdGratifiedDelegate, FString, bool, FString)
	DECLARE_MULTICAST_DELEGATE_OneParam(FPKT_BannerLoadedDelegate, FString)
	DECLARE_MULTICAST_DELEGATE_TwoParams(FPKT_BannerLoadFailedDelegate, FString, FString)
    DECLARE_MULTICAST_DELEGATE_OneParam(FPKT_BannerClickedDelegate, FString)

	static FPKT_AdCachingCompletedDelegate VideoAdCachingCompletedDelegate;
	static FPKT_AdCachingFailedDelegate VideoAdCachingFailedDelegate;
	static FPKT_AdClosedDelegate VideoAdClosedDelegate;
	static FPKT_AdCompletedDelegate VideoAdCompletedDelegate;
	static FPKT_AdFailedToShowDelegate VideoAdFailedToShowDelegate;
	static FPKT_AdDisplayedDelegate VideoAdDisplayedDelegate;
    static FPKT_AdClickedDelegate VideoAdClickedDelegate;
	static FPKT_AdSkippedDelegate VideoAdSkippedDelegate;
	static FPKT_AdGratifiedDelegate VideoAdGratifiedDelegate;

	static FPKT_AdCachingCompletedDelegate InterstitialCachingCompletedDelegate;
	static FPKT_AdCachingFailedDelegate InterstitialCachingFailedDelegate;
	static FPKT_AdClosedDelegate InterstitialClosedDelegate;
	static FPKT_AdCompletedDelegate InterstitialCompletedDelegate;
	static FPKT_AdFailedToShowDelegate InterstitialFailedToShowDelegate;
	static FPKT_AdDisplayedDelegate InterstitialDisplayedDelegate;
    static FPKT_AdClickedDelegate InterstitialClickedDelegate;
	static FPKT_AdSkippedDelegate InterstitialSkippedDelegate;
	static FPKT_AdGratifiedDelegate InterstitialGratifiedDelegate;

	static FPKT_BannerLoadedDelegate BannerLoadedDelegate;
	static FPKT_BannerLoadFailedDelegate BannerLoadFailedDelegate;
    static FPKT_BannerClickedDelegate BannerClickedDelegate;

	DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FPKT_AdCachingCompletedDynamicDelegate, FString, ScreenName, bool, IsRewarded, FString, Reward);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FPKT_AdCachingFailedDynamicDelegate, FString, ScreenName, bool, IsRewarded, FString, ErrorMessage);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPKT_AdClosedDynamicDelegate, FString, ScreenName, bool, IsRewarded);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPKT_AdCompletedDynamicDelegate, FString, ScreenName, bool, IsRewarded);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FPKT_AdFailedToShowDynamicDelegate, FString, ScreenName, bool, IsRewarded, FString, ErrorMessage);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPKT_AdDisplayedDynamicDelegate, FString, ScreenName, bool, IsRewarded);
    DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPKT_AdClickedDynamicDelegate, FString, ScreenName, bool, IsRewarded);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPKT_AdSkippedDynamicDelegate, FString, ScreenName, bool, IsRewarded);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FPKT_AdGratifiedDynamicDelegate, FString, ScreenName, bool, IsRewarded, FString, RewardValue);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPKT_BannerLoadedDynamicDelegate, FString, ScreenName);
	DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPKT_BannerLoadFailedDynamicDelegate, FString, ScreenName, FString, Message);
    DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FPKT_BannerClickedDynamicDelegate, FString, ScreenName);


	// video ads
	UPROPERTY(BlueprintAssignable)
	FPKT_AdCachingCompletedDynamicDelegate VideoAdCachingCompleted;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdCachingFailedDynamicDelegate VideoAdCachingFailed;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdClosedDynamicDelegate VideoAdClosed;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdCompletedDynamicDelegate VideoAdCompleted;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdFailedToShowDynamicDelegate VideoAdFailedToShow;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdDisplayedDynamicDelegate VideoAdDisplayed;
    
    UPROPERTY(BlueprintAssignable)
    FPKT_AdClickedDynamicDelegate VideoAdClicked;
    
    UPROPERTY(BlueprintAssignable)
    FPKT_AdSkippedDynamicDelegate VideoAdSkipped;

	UPROPERTY(BlueprintAssignable)
	FPKT_AdGratifiedDynamicDelegate VideoAdGratified;

	
	// interstitials
	UPROPERTY(BlueprintAssignable)
	FPKT_AdCachingCompletedDynamicDelegate InterstitialCachingCompleted;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdCachingFailedDynamicDelegate InterstitialCachingFailed;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdClosedDynamicDelegate InterstitialClosed;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdCompletedDynamicDelegate InterstitialCompleted;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdFailedToShowDynamicDelegate InterstitialFailedToShow;
	
	UPROPERTY(BlueprintAssignable)
	FPKT_AdDisplayedDynamicDelegate InterstitialDisplayed;
    
    UPROPERTY(BlueprintAssignable)
    FPKT_AdClickedDynamicDelegate InterstitialClicked;
    
    UPROPERTY(BlueprintAssignable)
    FPKT_AdSkippedDynamicDelegate InterstitialSkipped;

	UPROPERTY(BlueprintAssignable)
	FPKT_AdGratifiedDynamicDelegate InterstitialGratified;
	

	// banners
	UPROPERTY(BlueprintAssignable)
	FPKT_BannerLoadedDynamicDelegate BannerLoaded;

	UPROPERTY(BlueprintAssignable)
	FPKT_BannerLoadFailedDynamicDelegate BannerLoadFailed;

    UPROPERTY(BlueprintAssignable)
    FPKT_BannerClickedDynamicDelegate BannerClicked;
    

	void OnRegister() override;
	void OnUnregister() override;
	
private:	

	void HandleVideoAdCachingCompleted(FString screenName, bool isRewarded, FString reward) { VideoAdCachingCompleted.Broadcast(screenName, isRewarded, reward); }
	void HandleVideoAdCachingFailed(FString screenName, bool isRewarded, FString errorMessage) { VideoAdCachingFailed.Broadcast(screenName, isRewarded, errorMessage); }
	void HandleVideoAdClosed(FString screenName, bool isRewarded) { VideoAdClosed.Broadcast(screenName, isRewarded); }
	void HandleVideoAdCompleted(FString screenName, bool isRewarded) { VideoAdCompleted.Broadcast(screenName, isRewarded); }
	void HandleVideoAdFailedToShow(FString screenName, bool isRewarded, FString errorMessage) { VideoAdFailedToShow.Broadcast(screenName, isRewarded, errorMessage); }
	void HandleVideoAdDisplayed(FString screenName, bool isRewarded) { VideoAdDisplayed.Broadcast(screenName, isRewarded); }
    void HandleVideoAdClicked(FString screenName, bool isRewarded) { VideoAdClicked.Broadcast(screenName, isRewarded); }
	void HandleVideoAdSkipped(FString screenName, bool isRewarded) { VideoAdSkipped.Broadcast(screenName, isRewarded); }
	void HandleVideoAdGratified(FString screenName, bool isRewarded, FString rewardValue) { VideoAdGratified.Broadcast(screenName, isRewarded, rewardValue); }

	void HandleInterstitialCachingCompleted(FString screenName, bool isRewarded, FString reward) { InterstitialCachingCompleted.Broadcast(screenName, isRewarded, reward); }
	void HandleInterstitialCachingFailed(FString screenName, bool isRewarded, FString errorMessage) { InterstitialCachingFailed.Broadcast(screenName, isRewarded, errorMessage); }
	void HandleInterstitialClosed(FString screenName, bool isRewarded) { InterstitialClosed.Broadcast(screenName, isRewarded); }
	void HandleInterstitialCompleted(FString screenName, bool isRewarded) { InterstitialCompleted.Broadcast(screenName, isRewarded); }
	void HandleInterstitialFailedToShow(FString screenName, bool isRewarded, FString errorMessage) { InterstitialFailedToShow.Broadcast(screenName, isRewarded, errorMessage); }
	void HandleInterstitialDisplayed(FString screenName, bool isRewarded) { InterstitialDisplayed.Broadcast(screenName, isRewarded); }
    void HandleInterstitialClicked(FString screenName, bool isRewarded) { InterstitialClicked.Broadcast(screenName, isRewarded); }
	void HandleInterstitialSkipped(FString screenName, bool isRewarded) { InterstitialSkipped.Broadcast(screenName, isRewarded); }
	void HandleInterstitialGratified(FString screenName, bool isRewarded, FString rewardValue) { InterstitialGratified.Broadcast(screenName, isRewarded, rewardValue); }

	void HandleBannerLoaded(FString screenName) { BannerLoaded.Broadcast(screenName); }
	void HandleBannerLoadFailed(FString screenName, FString message) { BannerLoadFailed.Broadcast(screenName, message); }
    void HandleBannerClicked(FString screenName) { BannerClicked.Broadcast(screenName); }

};
