Example #1
0
        public string GetNewsHeadlinesRaw(string query = "TOPALL AND LEN", uint number = 10)
        {
            NewsHeadlinesRequest request = new NewsHeadlinesRequest
            {
                query  = query,
                number = number.ToString()
            };
            var response = SerializeAndSendRequest <NewsHeadlinesRequest>(request);

            return(response);
        }
Example #2
0
        public string GetNewsHeadlinesRaw(string query,
                                          uint?number,
                                          string from,
                                          string to)
        {
            string[] formats = { "yyyy-MM-dd", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm:sszzz", "yyyy-MM-ddTHH:mm:ssZ" };

            if (query == null)
            {
                query = "TOPALL AND LEN";
            }

            DateTime expectedDate;

            if (from != null)
            {
                if (!DateTime.TryParseExact(from, formats, null, DateTimeStyles.None, out expectedDate))
                {
                    EikonException error = new EikonException(HttpStatusCode.BadRequest, "Unsupported from Date Format. (yyyy-MM-dd, yyyy-MM-ddTHH:mm:SS, yyyy-MM-ddTHH:mm:SSzzz, or yyyy-MM-ddTHH:mm:ssZ");
                    _logger?.LogError(error.Message);
                    error.Source = "NewsHeadlines";
                    throw (error);
                }
            }
            if (to != null)
            {
                if (!DateTime.TryParseExact(to, formats, null, DateTimeStyles.None, out expectedDate))
                {
                    EikonException error = new EikonException(HttpStatusCode.BadRequest, "Unsupported to Date Format. (yyyy-MM-dd, yyyy-MM-ddTHH:mm:SS, yyyy-MM-ddTHH:mm:SSzzz, or yyyy-MM-ddTHH:mm:ssZ");

                    _logger?.LogError(error.Message);
                    error.Source = "NewsHeadlines";
                    throw (error);
                }
            }
            NewsHeadlinesRequest request = new NewsHeadlinesRequest
            {
                query    = query,
                number   = number?.ToString(),
                dateFrom = from,
                dateTo   = to,
                // timezone = timezone,
                repository = null
            };

            var response = SerializeAndSendRequest <NewsHeadlinesRequest>(request);

            return(response);
        }
Example #3
0
        public string GetNewsHeadlinesRaw(string query,
                                          uint?number,
                                          DateTime?from,
                                          DateTime?to)
        {
            string startDateFormatString = "yyyy-MM-ddTHH:mm:sszzz";
            string endDateFormatString   = "yyyy-MM-ddTHH:mm:sszzz";

            if (from?.Kind == DateTimeKind.Utc)
            {
                startDateFormatString = "yyyy-MM-ddTHH:mm:ssZ";
            }

            if (to?.Kind == DateTimeKind.Utc)
            {
                endDateFormatString = "yyyy-MM-ddTHH:mm:ssZ";
            }


            if (query == null)
            {
                query = "TOPALL AND LEN";
            }
            NewsHeadlinesRequest request = new NewsHeadlinesRequest
            {
                query    = query,
                number   = number?.ToString(),
                dateFrom = from != null?from?.ToString(startDateFormatString) : null,
                               dateTo = to != null?to?.ToString(endDateFormatString) : null,
                                            // timezone = timezone,
                                            repository = null
            };

            var response = SerializeAndSendRequest <NewsHeadlinesRequest>(request);

            return(response);
        }