<commit_before>﻿using Brandbank.Api.Clients;
using Brandbank.Xml.Helpers;
using Brandbank.Xml.Models.Message;
using Microsoft.Extensions.Logging;
using System;
using System.IO;
using System.Xml.Schema;

namespace Brandbank.Api
{
    public class BrandbankApi
    {
        private readonly Guid _authGuid;
        private readonly string _directory;
        private readonly ValidationEventHandler _validationEventHandler;

        public BrandbankApi(Guid authGuid, string directory) : this(authGuid, directory, createValidationEventHandler())
        {
        }

        public BrandbankApi(Guid authGuid, string directory, ValidationEventHandler validationEventHandler)
        {
            _authGuid = authGuid;
            _directory = directory;
            _validationEventHandler = validationEventHandler;
        }

        public void GetUnsent(Func<MessageType, IBrandbankMessageSummary> productProcessor)
        {
            GetUnsent(productProcessor, createLogger<IGetUnsentClient>());
        }
        public void GetUnsent(Func<MessageType, IBrandbankMessageSummary> productProcessor, ILogger<IGetUnsentClient> logger)
        {
            GetUnsent(productProcessor, logger, Path.Combine("Schemas", "BrandbankXML_v6.xsd"), string.Empty);
        }

        public void GetUnsent(Func<MessageType, IBrandbankMessageSummary> productProcessor, ILogger<IGetUnsentClient> logger, string xsdPath, string nameSpace)
        {
            using (var unsentClient = new GetUnsentClientLogger(logger, new GetUnsentClient(_authGuid)))
                while (
                    unsentClient.GetUnsentProductData()
                        .ValidateXml(xsdPath, nameSpace, _validationEventHandler)
                        .ConvertTo<MessageType>()<commit_msg>Updated formatting in Brandbank API<commit_after>﻿using Brandbank.Api.Clients;
using Brandbank.Xml.Helpers;
using Brandbank.Xml.Models.Message;
using Microsoft.Extensions.Logging;
using System;
using System.IO;
using System.Xml.Schema;

namespace Brandbank.Api
{
    public class BrandbankApi
    {
        private readonly Guid _authGuid;
        private readonly string _directory;
        private readonly ValidationEventHandler _validationEventHandler;

        public BrandbankApi(Guid authGuid, string directory) : this(authGuid, directory, createValidationEventHandler())
        {
        }

        public BrandbankApi(Guid authGuid, string directory, ValidationEventHandler validationEventHandler)
        {
            _authGuid = authGuid;
            _directory = directory;
            _validationEventHandler = validationEventHandler;
        }

        public void GetUnsent(Func<MessageType, IBrandbankMessageSummary> productProcessor)
        {
            GetUnsent(productProcessor, createLogger<IGetUnsentClient>());
        }

        public void GetUnsent(Func<MessageType, IBrandbankMessageSummary> productProcessor, ILogger<IGetUnsentClient> logger)
        {
            GetUnsent(productProcessor, logger, Path.Combine("Schemas", "BrandbankXML_v6.xsd"), string.Empty);
        }

        public void GetUnsent(Func<MessageType, IBrandbankMessageSummary> productProcessor, ILogger<IGetUnsentClient> logger, string xsdPath, string nameSpace)
        {
            using (var unsentClient = new GetUnsentClientLogger(logger, new GetUnsentClient(_authGuid)))
                while (
                    unsentClient.GetUnsentProductData()
                        .ValidateXml(xsdPath, nameSpace, _validationEventHandler)
                        .ConvertTo<MessageType>()
{'fraction_non_alphanumeric': 0.07128824024698288, 'fraction_numerical': 0.000561324726354196, 'mean_word_length': 3.0684931506849313, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5422614', 'n_tokens_mistral': 892, 'n_tokens_neox': 879, 'n_words': 193}