using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using ZuluFeedsSampleApp.Model;
using ZuluFeedsSampleApp.Sender;
using ZuluFeedsSampleApp.Configuration;



namespace ZuluFeedsSampleApp.Feeds
{
    public class ZuluFeedsGatewayImpl : IZuluFeedsGateway
    {
        #region Properties
        private readonly ZuluTradeAuthenticationInfo _authenticationInfo;
        private readonly ZuluTradingServerConfig _config;
        private readonly IZuluFeedsRequestGenerator _generator = new ZuluFeedsRequestGeneratorImpl();
        #endregion

        #region Constructor
        public ZuluFeedsGatewayImpl(ZuluTradeAuthenticationInfo authenticationInfo, ZuluTradingServerConfig config)
        {
            _authenticationInfo = authenticationInfo;
            _config = config;
        }
        #endregion

        public WebResponse getStream()
        {
            try
            {
                WebResponse response = FeedsRequestSender.sendRequest(_config, _authenticationInfo, _generator.getStreamRequest());
                return response;
            }
            catch (Exception e) {
                Console.WriteLine("Exception when getting response: " + e.Message);
                return null;
            }
        }
    }
}
