<commit_before>﻿using System;
using System.Threading;
using System.Threading.Tasks;
using SFA.DAS.NLog.Logger;
using SFA.DAS.ProviderApprenticeshipsService.Domain.Interfaces;
using SFA.DAS.Reservations.Api.Types;

namespace SFA.DAS.ProviderApprenticeshipsService.Infrastructure.Services
{
    public class ReservationsService : IReservationsService
    {
        private readonly IReservationsApiClient _reservationsApiClient;
        private readonly ILog _logger;

        public ReservationsService(IReservationsApiClient reservationsApiClient, ILog logger)
        {
            _reservationsApiClient = reservationsApiClient;
            _logger = logger;
        }

        public Task<bool> IsAutoReservationEnabled(long accountId)
        {
            return IsAutoReservationEnabledWithLog(accountId);
        }

        public async Task<bool> IsAutoReservationEnabledWithLog(long accountId)
        {
            try
            {
                return await IsAutoReservationEnabled(accountId, CancellationToken.None);
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Getting auto reservation status for account {accountId}");
                throw;
            }
        }

        public async Task<bool> IsAutoReservationEnabled(long accountId, CancellationToken cancellationToken)
        {
            var request = new ReservationAllocationStatusMessage { AccountId = accountId };

            var result = await _reservationsApiClient.GetReservationAllocationStatus(request, cancellationToken);

            return result.AutoReservations;
        }
    }
}<commit_msg>Shuffle call sequence in reservationService<commit_after>﻿using System;
using System.Threading;
using System.Threading.Tasks;
using SFA.DAS.NLog.Logger;
using SFA.DAS.ProviderApprenticeshipsService.Domain.Interfaces;
using SFA.DAS.Reservations.Api.Types;

namespace SFA.DAS.ProviderApprenticeshipsService.Infrastructure.Services
{
    public class ReservationsService : IReservationsService
    {
        private readonly IReservationsApiClient _reservationsApiClient;
        private readonly ILog _logger;

        public ReservationsService(IReservationsApiClient reservationsApiClient, ILog logger)
        {
            _reservationsApiClient = reservationsApiClient;
            _logger = logger;
        }

        public Task<bool> IsAutoReservationEnabled(long accountId)
        {
            return IsAutoReservationEnabledWithLog(accountId, CancellationToken.None);
        }

        public Task<bool> IsAutoReservationEnabled(long accountId, CancellationToken cancellationToken)
        {
            return IsAutoReservationEnabledWithLog(accountId, cancellationToken);
        }

        private async Task<bool> IsAutoReservationEnabledWithLog(long accountId, CancellationToken cancellationToken)
        {
            try
            {
                var request = new ReservationAllocationStatusMessage { AccountId = accountId };

                var result = await _reservationsApiClient.GetReservationAllocationStatus(request, cancellationToken);

                return result.AutoReservations;
            }
            catch (Exception ex)
            {
                _logger.Error(ex, $"Getting auto reservation status for account {accountId}");
                throw;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.06060606060606061, 'fraction_numerical': 0.0, 'mean_word_length': 2.675764192139738, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2281715', 'n_tokens_mistral': 858, 'n_tokens_neox': 837, 'n_words': 171}