using dodohold.core;
using Dataoke;
using Tea;
using AlibabaCloud.SDK.BssOpenApi20171214.Models;

namespace molilian.core
{
    public enum EIPInstanceType
    {
        EcsInstance,
        NetworkInterface,
    }

    public partial class AliyunPlus
    {
        string _app_key = string.Empty;
        string _app_secret = string.Empty;

        public AliyunPlus(string app_key, string app_secret)
        {
            _app_key = app_key;
            _app_secret = app_secret;
        }

        /// <summary>
        /// 获取余额
        /// </summary>
        public QueryAccountBalanceResponse QueryAccountBalance()
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new()
            {
                AccessKeyId = _app_key,
                AccessKeySecret = _app_secret,
                Endpoint = "business.aliyuncs.com"
            };

            AlibabaCloud.SDK.BssOpenApi20171214.Client client = new(config);

            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new();
            try
            {
                var response = client.QueryAccountBalanceWithOptions(runtime);
                return response;
            }
            catch (TeaException error)
            {
                // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
                // 错误 message
                Console.WriteLine(error.Message);
                // 诊断地址
                Console.WriteLine(error.Data["Recommend"]);
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
                // 错误 message
                Console.WriteLine(error.Message);
                // 诊断地址
                Console.WriteLine(error.Data["Recommend"]);
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            return null;
            //            {
            //                "Message": "success",
            //  "RequestId": "90492EBF-F8B4-5124-A65F-5321760AC223",
            //  "Data": {
            //                    "AvailableCashAmount": "107.16",
            //    "MybankCreditAmount": "0.00",
            //    "Currency": "CNY",
            //    "AvailableAmount": "107.16",
            //    "CreditAmount": "0.00",
            //    "QuotaLimit": "0.00"
            //  },
            //  "Code": "200",
            //  "Success": true
            //}
        }



    }
}


