using System;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace Unity.Services.Mediation
{
///
/// Interface of a Rewarded Ad.
///
public interface IRewardedAd : IDisposable
{
///
/// Event to be triggered by the adapter when an Ad is loaded.
///
event EventHandler OnLoaded;
///
/// Event to be triggered by the adapter when an Ad fails to load.
///
event EventHandler OnFailedLoad;
///
/// Event to be triggered by the adapter when a Rewarded Ad is shown.
///
event EventHandler OnShowed;
///
/// Event to be triggered by the adapter when the user clicks on the RewardedAd.
///
event EventHandler OnClicked;
///
/// Event to be triggered by the adapter when the RewardedAd is closed.
///
event EventHandler OnClosed;
///
/// Event to be triggered by the adapter when the RewardedAd has an error.
///
event EventHandler OnFailedShow;
///
/// Event to be triggered by the adapter when a reward needs to be issued.
///
event EventHandler OnUserRewarded;
///
///Gets the state of the RewardedAd
///
AdState AdState { get; }
///
/// Gets the id of the ad unit.
///
string AdUnitId { get; }
///
/// Method to tell the Mediation SDK to load an Ad.
///
/// LoadAsync Task
/// Thrown when the ad failed to load
Task LoadAsync();
///
/// Method to tell the Mediation SDK to show the loaded Ad.
///
/// Optional, allows setting optional parameters for showing a rewarded ad.
/// ShowAsync Task
/// Thrown when the ad failed to show
Task ShowAsync(RewardedAdShowOptions showOptions = null);
}
///
/// Contains optional parameters for showing a rewarded ad.
///
public class RewardedAdShowOptions
{
///
/// Allows providing data for a server to server redeem callback.
///
public S2SRedeemData S2SData { get; set; }
///
/// If set to true, the ad will automatically load another ad after it is done showing, so it is not necessary
/// to call LoadAsync again. This will occur when the OnClosed or OnFailedShow event is triggered.
///
public bool AutoReload { get; set; } = false;
}
///
/// Contains the Server to Server redeem callback data.
/// Make sure the rewarded ad is properly configured for server to server redeem callback authentication and a server URL is set in the dashboard.
///
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct S2SRedeemData
{
///
/// Unique identifier of the user being rewarded
///
public string UserId;
///
/// Optional custom data provided to the server
/// For example in a json format: "{\"reward\":\"Gems\",\"amount\":20}"
///
public string CustomData;
}
}