示例#1
0
        private void BuildConfigs(AvitoConfigs configs)
        {
            if (string.IsNullOrWhiteSpace(configs.BaseUrl))
            {
                throw new ArgumentNullException("BaseUrl can not be null or empty.");
            }

            if (configs.NotificationPeriod <= 0)
            {
                throw new ArgumentNullException("NotificationPeriod should be greater then 0.");
            }

            if (string.IsNullOrWhiteSpace(configs.EmailConfig.SendGridKey))
            {
                throw new ArgumentNullException("SendGridKey can not be null or empty.");
            }

            if (configs.EmailConfig.ToEmails.Count == 0)
            {
                throw new ArgumentNullException("At list one ToEmail should be specified.");
            }

            var queryParamsList = configs.QueryParams
                                  .Select(x => $"{x.Key}={x.Value}");

            _url = $"{configs.BaseUrl}{string.Join("&", queryParamsList)}";
            _notificationPeriod = configs.NotificationPeriod;
            _emailConfig        = configs.EmailConfig;
            _logPath            = configs.LogPath;
        }
示例#2
0
 public AvitoFlatService(AvitoConfigs configs)
 {
     BuildConfigs(configs);
     _repository  = new AvitoFlatRepository(_url);
     _cachedItems = new List <Flat>();
 }