<commit_before>﻿using System;
using System.Net.Http;
using Newtonsoft.Json;

namespace PexelsNet
{
    public class PexelsClient
    {
        private readonly string _apiKey;
        private const string BaseUrl = "http://api.pexels.com/v1/";

        public PexelsClient(string apiKey)
        {
            _apiKey = apiKey;
        }

        private HttpClient InitHttpClient()
        {
            var client = new HttpClient();

            client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", _apiKey);

            return client;
        }

        public Page Search(string query, int page = 1, int perPage = 15)
        {
            var client = InitHttpClient();

            HttpResponseMessage response = client.GetAsync(BaseUrl + "search?query=" + Uri.EscapeDataString(query) + "&per_page="+ perPage + "&page=" + page).Result;

            return GetResult(response);
        }

        public Page Popular(int page = 1, int perPage = 15)
        {
            var client = InitHttpClient();

            HttpResponseMessage response = client.GetAsync(BaseUrl + "popular?per_page=" + perPage + "&page=" + page).Result;

            return GetResult(response);
        }

        private static Page GetResult(HttpResponseMessage response)
        {
            var body = response.Content.ReadAsStringAsync().Result;

            response.EnsureSuccessStatusCode();

            if (response.IsSuccessStatusCode)
            {
                return JsonConvert.DeserializeObject<Page>(body);
            }

            throw new PexelsNetException(response.StatusCode, body);
        }
    }
}<commit_msg>Make use of asynchronous methods<commit_after>using System;
using System.Net.Http;
using Newtonsoft.Json;
using System.Threading.Tasks;

namespace PexelsNet
{
    public class PexelsClient
    {
        private readonly string _apiKey;
        private const string BaseUrl = "http://api.pexels.com/v1/";

        public PexelsClient(string apiKey)
        {
            _apiKey = apiKey;
        }

        private HttpClient InitHttpClient()
        {
            var client = new HttpClient();

            client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", _apiKey);

            return client;
        }

        public async Task<Page> SearchAsync(string query, int page = 1, int perPage = 15)
        {
            var client = InitHttpClient();

            HttpResponseMessage response = await client.GetAsync(BaseUrl + "search?query=" + Uri.EscapeDataString(query) + "&per_page=" + perPage + "&page=" + page);

            return await GetResultAsync(response);
        }

        public async Task<Page> PopularAsync(int page = 1, int perPage = 15)
        {
            var client = InitHttpClient();

            HttpResponseMessage response = await client.GetAsync(BaseUrl + "popular?per_page=" + perPage + "&page=" + page);

            return await GetResultAsync(response);
        }

        private static async Task<Page> GetResultAsync(HttpResponseMessage response)
        {
            var body = await response.Content.ReadAsStringAsync();

            response.EnsureSuccessStatusCode();

            if (response.IsSuccessStatusCode)
            {
                return JsonConvert.DeserializeObject<Page>(body);
            }

            throw new PexelsNetException(response.StatusCode, body);
        }
    }
}
{'fraction_non_alphanumeric': 0.0920859076198882, 'fraction_numerical': 0.004118858487790526, 'mean_word_length': 2.1805425631431246, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2850855', 'n_tokens_mistral': 909, 'n_tokens_neox': 869, 'n_words': 208}