Ejemplo n.º 1
0
        /// <summary>
        /// Get the presence messages history for the channel by specifying a query
        /// </summary>
        /// <returns><see cref="PaginatedResource{PresenceMessage}"/></returns>
        public IPaginatedResource <PresenceMessage> PresenceHistory(DataRequestQuery query)
        {
            var request = _restClient.RestMethods.CreateGetRequest(basePath + "/presence", _options);

            request.AddQueryParameters(query.GetParameters());
            return(_restClient.RestMethods.ExecuteRequest <PaginatedResource <PresenceMessage> >(request));
        }
Ejemplo n.º 2
0
        public void History_WithOptions_AddsParametersToRequest()
        {
            var rest = GetRestClient();

            rest.ExecuteHttpRequest = delegate(AblyRequest request)
            {
                _currentRequest = request;
                return(new AblyResponse()
                {
                    TextResponse = "[]"
                });
            };
            var      channel = rest.Channels.Get("Test");
            var      query   = new DataRequestQuery();
            DateTime now     = DateTime.Now;

            query.Start     = now.AddHours(-1);
            query.End       = now;
            query.Direction = QueryDirection.Forwards;
            query.Limit     = 1000;
            channel.History(query);

            _currentRequest.AssertContainsParameter("start", query.Start.Value.ToUnixTimeInMilliseconds().ToString());
            _currentRequest.AssertContainsParameter("end", query.End.Value.ToUnixTimeInMilliseconds().ToString());
            _currentRequest.AssertContainsParameter("direction", query.Direction.ToString().ToLower());
            _currentRequest.AssertContainsParameter("limit", query.Limit.Value.ToString());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Return the message history of the channel
        /// </summary>
        /// <param name="query"><see cref="DataRequestQuery"/></param>
        /// <returns><see cref="PaginatedResource{T}"/> of Messages</returns>
        public IPaginatedResource <Message> History(DataRequestQuery query)
        {
            query.Validate();

            var request = _restClient.RestMethods.CreateGetRequest(basePath + "/messages", _options);

            request.AddQueryParameters(query.GetParameters());

            return(_restClient.RestMethods.ExecuteRequest <PaginatedResource <Message> >(request));
        }
Ejemplo n.º 4
0
        public void History_WithInvalidStartOrEnd_Throws(DateTime?start, DateTime?end)
        {
            var rest    = GetRestClient();
            var channel = rest.Channels.Get("Test");
            var query   = new DataRequestQuery()
            {
                Start = start, End = end
            };

            Assert.Throws <AblyException>(delegate { channel.History(query); });
        }
Ejemplo n.º 5
0
        public void History_WithInvalidLimit_Throws(int limit)
        {
            var rest    = GetRestClient();
            var channel = rest.Channels.Get("Test");
            var query   = new DataRequestQuery()
            {
                Limit = limit
            };

            Assert.Throws <AblyException>(delegate { channel.History(query); });
        }
Ejemplo n.º 6
0
        public void GetLinkQuery_WithHeadersAndAskingForNextLink_ReturnsCorrectRequestQuery()
        {
            //Arrange

            var nextDataRequest = DataRequestQuery.Parse(NextQueryString);

            //Act
            var actual = DataRequestQuery.GetLinkQuery(GetSampleHistoryRequestHeaders(), "next");

            //Assert
            Assert.Equal(nextDataRequest, actual);
        }
Ejemplo n.º 7
0
 public DataRequestQueryParseFacts()
 {
     _query = DataRequestQuery.Parse(HeaderValue);
 }