﻿using UnityEngine;

namespace LicenseSpring
{

    public class LicenseSpringSDKObject : MonoBehaviour
    {
        #region Declaration

        public string licenseKey = "";

        [SerializeField]
        private string apiKey;
        public string ApiKey
        {
            set
            {
                apiKey = value;
            }
            get
            {
                return apiKey;
            }
        }

        [SerializeField]
        private string sharedKey;
        public string SharedKey
        {
            set
            {
                sharedKey = value;
            }
            get
            {
                return sharedKey;
            }
        }

        [SerializeField]
        private string productCode;
        public string ProductCode
        {
            set
            {
                productCode = value;
            }
            get
            {
                return productCode;
            }
        }
        
        [Tooltip("Check true, if you use custom product name and product version")]
        public bool UseCustomProductData;

        [Tooltip("Check true, if you need use debug data")]
        public bool DebugData;

        /// <summary>
        /// test data appName: "Unity LicenseSpring Test", appVersion: "0.0.1"
        /// </summary>

        [SerializeField]
        private string appName;
        public string AppName
        {
            set
            {
                appName = value;
            }
            get
            {
                return appName;
            }
        }

        [SerializeField]
        private string appVersion;
        public string AppVersion
        {
            set
            {
                appVersion = value;
            }
            get
            {
                return appVersion;
            }
        }

        LicenseSpringSDK licenseSDK;

        #endregion

        private void Start()
        {
            DontDestroyOnLoad(this.gameObject);

            licenseSDK = this.gameObject.GetComponent<LicenseSpringSDK>();

            if (!UseCustomProductData)
            {
                appName = Application.productName;
                appVersion = Application.version;
            }

            licenseSDK.InitializeSDK();
        }
    }
}