Esempio n. 1
0
        public void UrlGeneration()
        {
            RequestBuilder rb = RequestBuilder.InitiateRequest("http://baseurl.com/");

            rb.AddPath("path1");
            rb.AddPath("path2");
            rb.AddQuery("key1", null);
            rb.AddQuery("key2", "value2");
            rb.SetResource("test.html");

            string expectedUrl = "http://baseurl.com/path1/path2/test.html?key1&key2=value2";

            Assert.AreEqual <string>(expectedUrl, rb.AssembledUrl);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the genres, filtered by <see cref="filter" />.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public async Task <IEnumerable <GenreDto> > GetGenres(GenreFilter filter)
        {
            var request = new RequestBuilder()
                          .BaseUri(this.Url)
                          .AddQuery(nameof(filter.Skip), filter.Skip)
                          .AddQuery(nameof(filter.Take), filter.Take);

            if (!string.IsNullOrEmpty(filter.Search))
            {
                request.AddQuery(nameof(filter.Search), filter.Search);
            }
            return(await this.ExecuteAndParse <GenreDto[]>(request));
        }
Esempio n. 3
0
        /// <summary>
        /// Gets my books, filtered by <see cref="filter" />.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        public async Task <IPaginatedEnumerable <BookDto> > GetMyBooks(BookFilter filter)
        {
            var request = new RequestBuilder()
                          .BaseUri(this.CombineUrl("mybooks"))
                          .AddQuery(nameof(filter.Skip), filter.Skip)
                          .AddQuery(nameof(filter.Take), filter.Take);

            if (!string.IsNullOrEmpty(filter.Search))
            {
                request.AddQuery(nameof(filter.Search), filter.Search);
            }

            if (filter.Genres != null)
            {
                foreach (var genreId in filter.Genres)
                {
                    request.AddQuery(nameof(filter.Genres), genreId);
                }
            }

            return(await this.ExecuteAndParse <PaginatedEnumerable <BookDto> >(request));
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the feedback, filtered by <see cref="filter" />.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException">Missing Book ID!</exception>
        public async Task <IPaginatedEnumerable <BookFeedbackDto> > GetFeedback(FeedbackFilter filter)
        {
            if (filter.BookId == 0)
            {
                throw new ArgumentException("Missing Book ID!", nameof(filter.BookId));
            }

            var request = new RequestBuilder()
                          .BaseUri(this.Url)
                          .AddQuery(nameof(filter.BookId), filter.BookId)
                          .AddQuery(nameof(filter.Skip), filter.Skip)
                          .AddQuery(nameof(filter.Take), filter.Take);

            if (!string.IsNullOrEmpty(filter.Search))
            {
                request.AddQuery(nameof(filter.Search), filter.Search);
            }

            return(await this.ExecuteAndParse <PaginatedEnumerable <BookFeedbackDto> >(request));
        }