#if UNITY_ANDROID

namespace Stove.StoveSDK
{
    using UnityEngine;

    public class GameLogInterface
    {
        static AndroidJavaObject wrapper = new AndroidJavaObject("com.stove.unity.GameLogWrapper");

        // Proxy implementing com.stove.unity.GameLogWrapper$UserInfoResolver.
        // The native module invokes resolve() lazily at every log-creation time
        // (on a background thread) so the newest user info is always used.
        class UserInfoResolverProxy : AndroidJavaProxy
        {
            public UserInfoResolverProxy() : base("com.stove.unity.GameLogWrapper$UserInfoResolver") { }

            // Method name must match the Java interface method.
            public string resolve()
            {
                return GameLog.ResolveUserInfoJson();
            }
        }

        // Kept alive for the app lifetime.
        static readonly UserInfoResolverProxy resolverProxy = new UserInfoResolverProxy();

        internal static void Configure(
            string serverUrl,
            string serviceId,
            string marketGameId,
            string environment,
            int batchSize,
            string ip,
            string gdsJson,
            string language,
            string externalId)
        {
            wrapper.CallStatic(
                "configure",
                serverUrl,
                serviceId,
                marketGameId,
                environment,
                batchSize,
                ip,
                gdsJson,
                language,
                externalId,
                resolverProxy);
        }

        internal static void Add(string logEvent, string identifier)
        {
            wrapper.CallStatic("add", logEvent, identifier);
        }

        internal static void Flush()
        {
            wrapper.CallStatic("flush");
        }
    }
}

#endif
