<commit_before>﻿using Contentful.Core;
using Microsoft.Extensions.Configuration;
using StockportContentApi.Config;

namespace StockportContentApi.Client
{
    public interface IContentfulClientManager
    {
        IContentfulClient GetClient(ContentfulConfig config);
        IContentfulManagementClient GetManagementClient(ContentfulConfig config);
    }

    public class ContentfulClientManager : IContentfulClientManager
    {
        private readonly System.Net.Http.HttpClient _httpClient;
        private IConfiguration _configuration;

        public ContentfulClientManager(System.Net.Http.HttpClient httpClient, IConfiguration configuration)
        {
            _httpClient = httpClient;
            _configuration = configuration;
        }

        public IContentfulClient GetClient(ContentfulConfig config)
        {
            bool.TryParse(_configuration["Contentful:UsePreviewAPI"], out var usePreviewApi);
            var client = new ContentfulClient(_httpClient, !usePreviewApi ? config.AccessKey : "", usePreviewApi ? config.AccessKey : "", config.SpaceKey)
            {
                ResolveEntriesSelectively = true
            };

            return client;
        }
            
        public IContentfulManagementClient GetManagementClient(ContentfulConfig config)
        {
            var client = new ContentfulManagementClient(_httpClient, config.ManagementKey, config.SpaceKey);
            return client;
        }
    }
}<commit_msg>David - Fixing contentful client creation after update<commit_after>﻿using Contentful.Core;
using Microsoft.Extensions.Configuration;
using StockportContentApi.Config;

namespace StockportContentApi.Client
{
    public interface IContentfulClientManager
    {
        IContentfulClient GetClient(ContentfulConfig config);
        IContentfulManagementClient GetManagementClient(ContentfulConfig config);
    }

    public class ContentfulClientManager : IContentfulClientManager
    {
        private readonly System.Net.Http.HttpClient _httpClient;
        private IConfiguration _configuration;

        public ContentfulClientManager(System.Net.Http.HttpClient httpClient, IConfiguration configuration)
        {
            _httpClient = httpClient;
            _configuration = configuration;
        }

        public IContentfulClient GetClient(ContentfulConfig config)
        {
            bool.TryParse(_configuration["Contentful:UsePreviewAPI"], out var usePreviewApi);
            var client = new ContentfulClient(_httpClient, !usePreviewApi ? config.AccessKey : "", usePreviewApi ? config.AccessKey : "", config.SpaceKey, usePreviewApi)
            {
                ResolveEntriesSelectively = true
            };

            return client;
        }
            
        public IContentfulManagementClient GetManagementClient(ContentfulConfig config)
        {
            var client = new ContentfulManagementClient(_httpClient, config.ManagementKey, config.SpaceKey);
            return client;
        }
    }
}
{'fraction_non_alphanumeric': 0.06187624750499002, 'fraction_numerical': 0.0, 'mean_word_length': 2.8850129198966408, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7657290', 'n_tokens_mistral': 694, 'n_tokens_neox': 686, 'n_words': 147}