<commit_before>﻿using System;
using System.Collections.Generic;
using SevenDigital.Api.Wrapper.EndpointResolution.RequestHandlers;
using SevenDigital.Api.Wrapper.Http;

namespace SevenDigital.Api.Wrapper.EndpointResolution
{
	public class RequestCoordinator : IRequestCoordinator
	{
		private readonly IEnumerable<RequestHandler> _requestHandlers;

		public IHttpClient HttpClient { get; set; }

		public RequestCoordinator(IHttpClient httpClient, IEnumerable<RequestHandler> requestHandlers)
		{
			HttpClient = httpClient;
			_requestHandlers = requestHandlers;
		}

		public string ConstructEndpoint(RequestData requestData)
		{
			return ConstructBuilder(requestData).ConstructEndpoint(requestData);
		}

		private RequestHandler ConstructBuilder(RequestData requestData)
		{
			var upperInvariant = requestData.HttpMethod.ToUpperInvariant();
			foreach (var requestHandler in _requestHandlers)
			{
				if (requestHandler.HandlesMethod(upperInvariant))
				{
					return requestHandler;
				}
			}
			throw new NotImplementedException("No RequestHandlers supplied that can deal with this method");
		}

		public virtual Response HitEndpoint(RequestData requestData)
		{
			var builder = ConstructBuilder(requestData);
			builder.HttpClient = HttpClient;
			return builder.HitEndpoint(requestData);
		}

		public virtual void HitEndpointAsync(RequestData requestData, Action<Response> callback)
		{
			var builder = ConstructBuilder(requestData);
			builder.HttpClient = HttpClient;
			builder.HitEndpointAsync(requestData, callback);
		}
	}
}<commit_msg>Rename "ConstructBuilder" to "FindRequestHandler" as "ConstructBuilder" is a weak name that no longer accurately describes what this does Also more detail in the error message<commit_after>﻿using System;
using System.Collections.Generic;
using SevenDigital.Api.Wrapper.EndpointResolution.RequestHandlers;
using SevenDigital.Api.Wrapper.Http;

namespace SevenDigital.Api.Wrapper.EndpointResolution
{
	public class RequestCoordinator : IRequestCoordinator
	{
		private readonly IEnumerable<RequestHandler> _requestHandlers;

		public IHttpClient HttpClient { get; set; }

		public RequestCoordinator(IHttpClient httpClient, IEnumerable<RequestHandler> requestHandlers)
		{
			HttpClient = httpClient;
			_requestHandlers = requestHandlers;
		}

		public string ConstructEndpoint(RequestData requestData)
		{
			var requestHandler = FindRequestHandler(requestData.HttpMethod);
			return requestHandler.ConstructEndpoint(requestData);
		}

		private RequestHandler FindRequestHandler(string httpMethod)
		{
			var upperHttpMethodName = httpMethod.ToUpperInvariant();
			foreach (var requestHandler in _requestHandlers)
			{
				if (requestHandler.HandlesMethod(upperHttpMethodName))
				{
					return requestHandler;
				}
			}

			string errorMessage = string.Format("No RequestHandler supplied for method '{0}'", upperHttpMethodName);
			throw new NotImplementedException(errorMessage);
		}

		public virtual Response HitEndpoint(RequestData requestData)
		{
			var requestHandler = FindRequestHandler(requestData.HttpMethod);
			requestHandler.HttpClient = HttpClient;
			return requestHandler.HitEndpoint(requestData);
		}

		public virtual void HitEndpointAsync(RequestData requestData, Action<Response> callback)
		{
			var requestHandler = FindRequestHandler(requestData.HttpMethod);
			requestHandler.HttpClient = HttpClient;
			requestHandler.HitEndpointAsync(requestData, callback);
		}
	}
}
{'fraction_non_alphanumeric': 0.07175925925925926, 'fraction_numerical': 0.00028935185185185184, 'mean_word_length': 5.609942638623327, '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': '2277597', 'n_tokens_mistral': 1033, 'n_tokens_neox': 892, 'n_words': 210}