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

    /**
     * Operation provided by the Stove.
     * @since 2.0.0
     */
    public class Operation
    {
        /**
         * Sanction error code.
         * @since 2.0.0
         */
        private const int OperationCodeSanction = 10122;

        /**
         * Withdraw error code.
         * @since 2.0.0
         */
        private const int OperationCodeWithdraw = 10172;

        /**
         * Inactive error code.
         * @since 2.0.0
         */
        private const int OperationCodeInactive = 11239;

        /**
         * Fetch data for updates, checks or account sanctions, withdrawal, dormancy, etc.         
         * @param action Fetch Result.
         * @see Result
         * @since 2.0.0
         */

        public static void Fetch(Action<Result> action)
        {
            Debug.Log("Operation.Fetch Action(" + action + ")");
            string identifier = StoveSDK.Instance.AddAction(payload =>
            {
                Result result = new Result(payload["result"] as Dictionary<string, object>);
                Debug.Log("Operation.Fetch Result(" + result + ")");
                action.Invoke(result);
            });
            AuthInterface.FetchOperation(identifier);
        }
    }
}


