public async Task <WallhavenSearch> search(string query, string sorting = "toplist", string toprange = "1M", bool random = false)
        {
            var rr = new RestRequest("search", Method.GET);

            if (query != null)
            {
                rr.AddQueryParameter("q", query);
            }
            if (random)
            {
                rr.AddQueryParameter("seed", Guid.NewGuid().ToString("n"));
            }
            rr.AddQueryParameter("sorting", sorting);
            rr.AddQueryParameter("topRange", toprange);
            return(this.client.Execute(rr)?.Content?.DeserializeObject <WallhavenSearch>());
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var api = GetNorthwindApi();

            var categoriesRequest = new RestRequest("categories", RestSharp.Method.GET)
            {
                JsonSerializer = new NewtonsoftJsonSerializer(new Newtonsoft.Json.JsonSerializer()
                {
                    Formatting = Newtonsoft.Json.Formatting.Indented
                })
            };

            categoriesRequest.AddQueryParameter("count", "5");

            var productsRequest = new RestRequest("products", RestSharp.Method.GET)
            {
                JsonSerializer = new NewtonsoftJsonSerializer(new Newtonsoft.Json.JsonSerializer()
                {
                    Formatting = Newtonsoft.Json.Formatting.Indented
                })
            };

            productsRequest.AddQueryParameter("count", "10");

            api.ExecuteAsync(categoriesRequest, response =>
            {
                Console.WriteLine(">>>>>>>>>>>>>>>CATEGORIES<<<<<<<<<<<<<<<");
                Console.WriteLine(response.Content);
            });

            api.ExecuteAsync(productsRequest, response =>
            {
                Console.WriteLine(">>>>>>>>>>>>>>>>PRODUCTS<<<<<<<<<<<<<<<");
                Console.WriteLine(response.Content);
            });

            Console.ReadLine();
        }