private async Task <HttpResponseMessage> SendAsync(AdditionalRequestSettings additionalSettings, ApiDataContractAttribute metadata, object dataContract, Func <JToken, JToken> transformation) { return(await Connection.SendAsync(additionalSettings?.Endpoint ?? metadata?.Endpoint, additionalSettings?.UrlParameters, ConvertToJsonString(dataContract, transformation), _httpMethodMap[(additionalSettings?.HttpMethod).GetValueOrDefault(TestCoreFramework.Enums.HttpMethod.None) == TestCoreFramework.Enums.HttpMethod.None ? metadata.HttpMethod : additionalSettings.HttpMethod] , additionalSettings?.ContentType ?? "application/json")); }
public ApiResponse <T> Send <T>(object dataContract, Func <JToken, JToken> transformation = null, AdditionalRequestSettings additionalSettings = null) { return(SendAsync <T>(dataContract, transformation, additionalSettings).Result); }
public async Task <ApiResponse <T> > SendAsync <T>(object dataContract, Func <JToken, JToken> transformation = null, AdditionalRequestSettings additionalSettings = null) { using (Util.LogHelper.LoggerForCurrentTest.EnterReproStep("Send an arbitrary request for dataContract " + dataContract.GetType().FullName)) { var metadata = dataContract.GetType().GetTypeInfo().GetCustomAttribute <ApiDataContractAttribute>(); if ((metadata?.Endpoint == null && additionalSettings?.Endpoint == null) || (metadata?.HttpMethod == TestCoreFramework.Enums.HttpMethod.None && additionalSettings?.HttpMethod == TestCoreFramework.Enums.HttpMethod.None)) { throw new ArgumentException("Could not obtain necessary data to prepare a request. Please specify all values either in ApiDataContractAttribute applied to data contract."); } return(ProcessResponseWithContent <T>(await SendAsync(additionalSettings, metadata, dataContract, transformation))); } }