#nullable enable
using System;
using System.Threading.Tasks;
using IGP.UnitySDK.Abstractions;
using IGP.UnitySDK.Models;

namespace IGP.UnitySDK
{
    /// <summary>
    /// Public Unity-facing IGP SDK entrypoint.
    /// Games should depend on this API surface rather than legacy Arena-named classes.
    /// </summary>
    public static class IGPSDK
    {
        public static Task<AchievementReportResult> UnlockAchievementAsync(
            IIGPRuntimeClient runtimeClient,
            string achievementKey,
            string? eventId = null,
            long? occurredAtUnixMs = null,
            int? appId = null)
        {
            if (runtimeClient == null)
            {
                throw new ArgumentNullException(nameof(runtimeClient));
            }

            return runtimeClient.UnlockAchievementAsync(
                achievementKey,
                eventId,
                occurredAtUnixMs,
                appId);
        }

        public static Task<AchievementReportResult> ReportAchievementProgressAsync(
            IIGPRuntimeClient runtimeClient,
            string achievementKey,
            double progressValue,
            string? progressSourceKey = null,
            string? eventId = null,
            long? occurredAtUnixMs = null,
            int? appId = null)
        {
            if (runtimeClient == null)
            {
                throw new ArgumentNullException(nameof(runtimeClient));
            }

            return runtimeClient.ReportAchievementProgressAsync(
                achievementKey,
                progressValue,
                progressSourceKey,
                eventId,
                occurredAtUnixMs,
                appId);
        }

        public static Task<AchievementClearResult> ClearAchievementsAsync(
            IIGPRuntimeClient runtimeClient,
            int? appId = null)
        {
            if (runtimeClient == null)
            {
                throw new ArgumentNullException(nameof(runtimeClient));
            }

            return runtimeClient.ClearAchievementsAsync(appId);
        }
    }
}
