using Binance.TradeRobot.Common.DI;
using Binance.TradeRobot.Common.Http;
using Microsoft.Extensions.DependencyInjection;

namespace Binance.TradeRobot.Business
{
    [BatchRegistration(ServiceLifetime.Singleton, RegistrationType.Self)]
    public class DingBusiness
    {
        private RestApiService restApiService;
        public DingBusiness(RestApiService restApiService)
        {
            this.restApiService = restApiService;
        }

        public void Send(string content)
        {
            try
            {
                restApiService.SendRequest("https://oapi.dingtalk.com/robot/send", "?access_token=be2f574475269e83584fa3ef1a93ef68e28c15402afa1d193aa82a1a51164850", new
                {
                    msgtype = "text",
                    text = new
                    {
                        content
                    }
                }, null, System.Net.Http.HttpMethod.Post);
            }
            catch { }
        }
    }
}