Example #1
0
        public Task <IReadOnlyList <SearchResult <SimpleDeal> > > Search(string term, DealSearchFilters filters)
        {
            Ensure.ArgumentNotNull(term, nameof(term));
            Ensure.ArgumentNotNull(filters, nameof(filters));
            if (filters.ExactMatch.HasValue && filters.ExactMatch.Value == true)
            {
                if (term.Length < 1)
                {
                    throw new ArgumentException("The search term must have at least 1 character", nameof(term));
                }
            }
            else
            {
                if (term.Length < 2)
                {
                    throw new ArgumentException("The search term must have at least 2 characters", nameof(term));
                }
            }

            var parameters = filters.Parameters;

            parameters.Add("term", term);
            var options = new ApiOptions
            {
                StartPage = filters.StartPage,
                PageCount = filters.PageCount,
                PageSize  = filters.PageSize
            };

            return(ApiConnection.SearchAll <SearchResult <SimpleDeal> >(ApiUrls.DealsSearch(), parameters, options));
        }