﻿namespace Stove.StoveSDK
{
    using System;
    using System.Collections.Generic;
    using UnityEngine;

    /**
     * Operation UI provided by the Stove.
     * @since 2.0.0
     */
    public class OperationUI
    {
        /**
         * Provides the ability to display screens for updates, checks or account sanctions, withdrawal, dormancy, etc.
         * @param result Result to handle.
         * @param action Handle Result.
         * @since 2.0.0
         */
        public static void HandleResult(Result result, Action<Result>action)
        {
            Debug.Log("OperationUI.HandleResult");
            string identifier = StoveSDK.Instance.AddAction(payload =>
            {
                Result callbackResult = new Result(payload["result"] as Dictionary<string, object>);
                
                Debug.Log("OperationUI.HandleResult Result(" + callbackResult + ")");
                action.Invoke(callbackResult);
            });
            AuthUIInterface.HandleResult(result.ToJSONString(), identifier);
        }
    }
}


