#pragma once

#include "UObject/Object.h"
#include "UObject/ScriptMacros.h"
#include "PokktAdsPrivatePCH.h"

#include "PokktAdsFunctions.generated.h"


UCLASS(NotBlueprintable)
class UPokktAdsFunctions : public UObject {
	GENERATED_BODY()
	
public:	

	/**
	 * Pokkt standard APIs
	 **/
	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising settings"), Category = "Pokkt|Settings")
	static void SetPokktConfig(FString appId, FString secKey);

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising settings"), Category = "Pokkt|Settings")
	static void SetThirdPartyId(FString thirdPartyId) { notifyNative(SET_THIRDPARTY_ID_OP, thirdPartyId); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising version"), Category = "Pokkt")
	static FString GetSDKVersion() { return getSDKVersionOnNative(); }


	/**
	 * Video ads related APIs
	 **/
	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising video"), Category = "Pokkt|VideoAds")
	static void CacheRewardedVideoAd(FString screenName) { notifyNative(VIDEO_CACHE_REWARDED_OP, screenName); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising video"), Category = "Pokkt|VideoAds")
	static void ShowRewardedVideoAd(FString screenName) { notifyNative(VIDEO_SHOW_REWARDED_OP, screenName); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising video"), Category = "Pokkt|VideoAds")
	static void CacheNonRewardedVideoAd(FString screenName) { notifyNative(VIDEO_CACHE_NONREWARDED_OP, screenName); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising video"), Category = "Pokkt|VideoAds")
	static void ShowNonRewardedVideoAd(FString screenName) { notifyNative(VIDEO_SHOW_NONREWARDED_OP, screenName); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising video"), Category = "Pokkt|VideoAds")
	static bool IsVideoAdCached(FString screenName, bool isRewarded) { return isVideoAdCachedOnNative(screenName, isRewarded); }


	/**
	 * Interstitial related APIs
	 **/
	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising intersitial"), Category = "Pokkt|Interstitial")
	static void CacheRewardedInterstitialAd(FString screenName) { notifyNative(INTERSTITIAL_CACHE_REWARDED_OP, screenName); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising intersitial"), Category = "Pokkt|Interstitial")
	static void ShowRewardedInterstitialAd(FString screenName) { notifyNative(INTERSTITIAL_SHOW_REWARDED_OP, screenName); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising intersitial"), Category = "Pokkt|Interstitial")
	static void CacheNonRewardedInterstitialAd(FString screenName) { notifyNative(INTERSTITIAL_CACHE_NONREWARDED_OP, screenName); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising intersitial"), Category = "Pokkt|Interstitial")
	static void ShowNonRewardedInterstitialAd(FString screenName) { notifyNative(INTERSTITIAL_SHOW_NONREWARDED_OP, screenName); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising interstitial"), Category = "Pokkt|Interstitial")
	static bool IsInterstitialCached(FString screenName, bool isRewarded) { return isInterstitialCachedOnNative(screenName, isRewarded); }


	/**
	 * Banner related APIs
	 **/
	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising banner"), Category = "Pokkt|Banner")
	static void LoadBanner(FString screenName, int bannerPosition);

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising banner"), Category = "Pokkt|Banner")
	static void DestroyBanner(FString screenName) { notifyNative(BANNER_DESTROY_OP, screenName); }


	/**
	 * Debugging related APIs
	 **/
	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising debug"), Category = "Pokkt|Debugging")
	static void ShouldDebug(bool value) { notifyNative(DEBUGGING_SHOULD_DEBUG_OP, value ? "true" : "false"); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising debug"), Category = "Pokkt|Debugging")
	static void ExportLog() { notifyNative(DEBUGGING_EXPORT_LOG_OP); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising debug"), Category = "Pokkt|Debugging")
	static void ShowToast(FString message) { notifyNative(DEBUGGING_SHOW_TOAST_OP, message); }

	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt ad advertising debug"), Category = "Pokkt|Debugging")
	static void ShowLog(FString message) { notifyNative(DEBUGGING_SHOW_LOG_OP, message); }


	/**
	 * Consent Access Data
	 **/
	UFUNCTION(BlueprintCallable, meta = (Keywords = "pokkt consent gdpr"), Category = "Pokkt")
	static void SetPokktConsentInfo(bool gdprApplicable, bool gdprConsentAvailable);


	/**
	 * handle messages via native (java/obj-c)
	 **/
	static void handleNativeMessage(FString operation, FString param);

private:
	// use this to notify native pokkt runtime
	static void notifyNative(FString operation, FString param = "");

	// sdk version
	static FString getSDKVersionOnNative();

	// ad cached
	static bool isVideoAdCachedOnNative(FString screenName, bool isRewarded);
	static bool isInterstitialCachedOnNative(FString screenName, bool isRewarded);
};
