﻿// Copyright 2013-2022 AFI,Inc. All rights reserved

using UnityEngine;
using BackEnd;

public class UtilsGroup : BaseGroup {
    public override string GetGroupName() {
        return "기타";
    }

    public override void SetSubFunctionButton() {
        UIManager.Instance.AddSubFunction("서버 시간 조회", CouponList);
        UIManager.Instance.AddSubFunction("프로젝트 상태 조회", GetServerStatus);
        UIManager.Instance.AddSubFunction("프로젝트 버전 조회", GetLatestVersion);
        UIManager.Instance.AddSubFunction("구글 해시키 조회", GetGoogleHash);
        UIManager.Instance.AddSubFunction("야간푸시 동의 여부", AgreeNightPushNotification);

    }

    private void CouponList() {
        requestUI.SetExecuteButtonAction( () => {
            var bro = Backend.Utils.GetServerTime();
            ShowResultData(bro);
        }); 
    }
    
    private void GetServerStatus() {
        requestUI.SetExecuteButtonAction( () => {
            var bro = Backend.Utils.GetServerStatus();
            ShowResultData(bro);
        }); 
    }
    
    private void GetLatestVersion() {
        requestUI.SetExecuteButtonAction( () => {
            var bro = Backend.Utils.GetLatestVersion();
            ShowResultData(bro);
        }); 
    }
    
    private void GetGoogleHash() {
        requestUI.SetExecuteButtonAction( () => {
            var bro = Backend.Utils.GetLatestVersion();
            UIManager.Instance.OpenResultUI(bro.ToString());
        }); 
    }
    
    private void AgreeNightPushNotification() {
        requestUI.AddInputField("야간푸시 동의(true/false)");

        requestUI.SetExecuteButtonAction( () => {
            var isAgree = InputParseByBool(0, 0);

            var bro =  Backend.Android.AgreeNightPushNotification(isAgree);
            UIManager.Instance.OpenResultUI(bro.ToString());
        }); 
    }
}