Esempio n. 1
0
        public static async Task <SearchResult <TResult> > Search <TResult>(
            this ISearchable <TResult> resource,
            string query = null,
            IDictionary <string, string> filters = null,
            Ordering?order = null,
            int?page       = null
            ) where TResult : ModelBase
        {
            var opts = new SearchOptions
            {
                Scope   = resource.Scope,
                Query   = query,
                Filters = filters,
                Order   = order,
                Page    = page,
            };

            var path = "/search";

            if (!opts.IsEmpty())
            {
                var content = serializer.ExtractFormValues(opts);
                path += $"?{await content.ReadAsStringAsync().ConfigureAwait(false)}";
            }

            return(await resource.Requester.Request <SearchResult <TResult> >(
                       resource.Endpoint,
                       "GET",
                       path
                       ).ConfigureAwait(false));
        }