<commit_before>namespace TvDbSharper
{
    using System;
    using System.Net.Http.Headers;
    using System.Threading;
    using System.Threading.Tasks;

    using TvDbSharper.JsonSchemas;

    public class RestClient : IRestClient
    {
        private const string DefaultBaseUrl = "https://api.thetvdb.com";

        public RestClient(IHttpJsonClient jsonClient)
        {
            this.JsonClient = jsonClient;

            if (this.JsonClient.BaseUrl == null)
            {
                this.JsonClient.BaseUrl = DefaultBaseUrl;
            }
        }

        private IHttpJsonClient JsonClient { get; }

        public async Task AuthenticateAsync(AuthenticationRequest authenticationRequest, CancellationToken cancellationToken)
        {
            if (authenticationRequest == null)
            {
                throw new ArgumentNullException(nameof(authenticationRequest));
            }

            var response = await this.JsonClient.PostJsonAsync<AuthenticationResponse>("/login", authenticationRequest, cancellationToken);

            this.JsonClient.AuthorizationHeader = new AuthenticationHeaderValue("Bearer", response.Token);
        }

        public async Task<ActorResponse[]> GetSeriesActorsAsync(int seriesId, CancellationToken cancellationToken)
            => await this.GetDataAsync<ActorResponse[]>($"/series/{seriesId}/actors", cancellationToken);

        public async Task<SeriesResponse> GetSeriesAsync(int seriesId, CancellationToken cancellationToken)
            => await this.GetDataAsync<SeriesResponse>($"/series/{seriesId}", cancellationToken);

        public async Task<EpisodeResponse[]> GetSeriesEpisodesAsync(int seriesId, CancellationToken cancellationToken)
            => await this.GetDataAsync<EpisodeResponse[]>($"/series/{seriesId}/episodes", cancellationToken);

        public async Task RefreshTokenAsync(CancellationToken cancellationToken)
        {
            var response = await this.JsonClient.GetJsonAsync<AuthenticationResponse>("/refresh_token", cancellationToken);

            this.JsonClient.AuthorizationHeader = new AuthenticationHeaderValue("Bearer", response.Token);
        }

        // public async Task<SearchResponse[]> SearchSeriesAsync(string name, CancellationToken cancellationToken)
        // {
        // return await this.GetDataAsync<SearchResponse[]>($"/search/series?name={Uri.EscapeDataString(name)}", cancellationToken);
        // }
        private async Task<T> GetDataAsync<T>(string requestUri, CancellationToken cancellationToken)
        {
            return (await this.JsonClient.GetJsonDataAsync<T>(requestUri, cancellationToken)).Data;
        }
    }
}<commit_msg>Extracted function<commit_after>namespace TvDbSharper
{
    using System;
    using System.Net.Http.Headers;
    using System.Threading;
    using System.Threading.Tasks;

    using TvDbSharper.JsonSchemas;

    public class RestClient : IRestClient
    {
        private const string DefaultBaseUrl = "https://api.thetvdb.com";

        public RestClient(IHttpJsonClient jsonClient)
        {
            this.JsonClient = jsonClient;

            if (this.JsonClient.BaseUrl == null)
            {
                this.JsonClient.BaseUrl = DefaultBaseUrl;
            }
        }

        private IHttpJsonClient JsonClient { get; }

        public async Task AuthenticateAsync(AuthenticationRequest authenticationRequest, CancellationToken cancellationToken)
        {
            if (authenticationRequest == null)
            {
                throw new ArgumentNullException(nameof(authenticationRequest));
            }

            var response = await this.JsonClient.PostJsonAsync<AuthenticationResponse>("/login", authenticationRequest, cancellationToken);

            this.UpdateAuthenticationHeader(response.Token);
        }

        public async Task<ActorResponse[]> GetSeriesActorsAsync(int seriesId, CancellationToken cancellationToken)
            => await this.GetDataAsync<ActorResponse[]>($"/series/{seriesId}/actors", cancellationToken);

        public async Task<SeriesResponse> GetSeriesAsync(int seriesId, CancellationToken cancellationToken)
            => await this.GetDataAsync<SeriesResponse>($"/series/{seriesId}", cancellationToken);

        public async Task<EpisodeResponse[]> GetSeriesEpisodesAsync(int seriesId, CancellationToken cancellationToken)
            => await this.GetDataAsync<EpisodeResponse[]>($"/series/{seriesId}/episodes", cancellationToken);

        public async Task RefreshTokenAsync(CancellationToken cancellationToken)
        {
            var response = await this.JsonClient.GetJsonAsync<AuthenticationResponse>("/refresh_token", cancellationToken);

            this.UpdateAuthenticationHeader(response.Token);
        }

        // public async Task<SearchResponse[]> SearchSeriesAsync(string name, CancellationToken cancellationToken)
        // {
        // return await this.GetDataAsync<SearchResponse[]>($"/search/series?name={Uri.EscapeDataString(name)}", cancellationToken);
        // }
        private async Task<T> GetDataAsync<T>(string requestUri, CancellationToken cancellationToken)
        {
            return (await this.JsonClient.GetJsonDataAsync<T>(requestUri, cancellationToken)).Data;
        }

        private void UpdateAuthenticationHeader(string token)
        {
            this.JsonClient.AuthorizationHeader = new AuthenticationHeaderValue("Bearer", token);
        }
    }
}
{'fraction_non_alphanumeric': 0.09119266055045872, 'fraction_numerical': 0.0, 'mean_word_length': 3.1232980332829046, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 35, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '750879', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1308, 'n_words': 251}