public void WhenSearchingForACompany() { var terms = new Terms() { Name = "L" }; _result = Client.SearchCompaniesAsync(terms).Result; }
public void GivenARunningApiWhenSearchingForACompany() { var name = "GG"; var apiKey = Guid.NewGuid().ToString(); _resource = new MockResource(new ResourceIdentifier("GET", CreateCompaniesPath(), $"?api_key={apiKey}&filters={{\"name\":\"{name}\"}}")); _resource.ReturnsBody(JsonSearchResponse); _api = new Api(); _api.RegisterResource(_resource); _api.Start(); var client = new DueDilClientFactory(new DueDilSettings(_api.Uri, apiKey, _sandboxMode)).CreateClient(); _actual = client.SearchCompaniesAsync(new Terms(){Name = name}).Result; }
public void GivenARunningApiWhenGettingACompany() { var companyId = Guid.NewGuid().ToString(); var apiKey = Guid.NewGuid().ToString(); _resource = new MockResource(new ResourceIdentifier("GET", CreateCompanyPath(companyId), $"?api_key={apiKey}")); _resource.ReturnsBody(JsonSearchResponse); _api = new Api(); _api.RegisterResource(_resource); _api.Start(); var client = new DueDilClientFactory(new DueDilSettings(_api.Uri, apiKey, _sandboxMode)).CreateClient(); _actual = client.GetCompanyAsync(Locale.Uk, companyId).Result; }
public async Task <DueDilClientResponse <Company> > GetCompanyAsync(Locale locale, string companyId) { using (var httpClient = CreateHttpClient()) { var response = await httpClient.GetAsync(_getCompanyUriBuilder.BuildUri(locale, companyId)) .ConfigureAwait(false); var dueDilResponse = new DueDilClientResponse <Company>(); response.EnsureSuccessStatusCode(); dueDilResponse.Data = await response.Content.ReadAsAsync <Company>() .ConfigureAwait(false); return(dueDilResponse); } }
public async Task <DueDilClientResponse <SearchCompany> > SearchCompaniesAsync(Terms terms) { using (var httpClient = CreateHttpClient()) { var response = await httpClient.GetAsync(_searchCompaniesUriBuilder.BuildUri(terms)) .ConfigureAwait(false); var dueDilResponse = new DueDilClientResponse <SearchCompany>(); response.EnsureSuccessStatusCode(); dueDilResponse.Data = await response.Content.ReadAsAsync <SearchCompany>() .ConfigureAwait(false); return(dueDilResponse); } }
public async Task<DueDilClientResponse<Company>> GetCompanyAsync(Locale locale, string companyId) { using (var httpClient = CreateHttpClient()) { var response = await httpClient.GetAsync(_getCompanyUriBuilder.BuildUri(locale, companyId)) .ConfigureAwait(false); var dueDilResponse = new DueDilClientResponse<Company>(); response.EnsureSuccessStatusCode(); dueDilResponse.Data = await response.Content.ReadAsAsync<Company>() .ConfigureAwait(false); return dueDilResponse; } }
public async Task<DueDilClientResponse<SearchCompany>> SearchCompaniesAsync(Terms terms) { using (var httpClient = CreateHttpClient()) { var response = await httpClient.GetAsync(_searchCompaniesUriBuilder.BuildUri(terms)) .ConfigureAwait(false); var dueDilResponse = new DueDilClientResponse<SearchCompany>(); response.EnsureSuccessStatusCode(); dueDilResponse.Data = await response.Content.ReadAsAsync<SearchCompany>() .ConfigureAwait(false); return dueDilResponse; } }
public void GivenARunningApiWhenSearchingForACompany() { var name = "GG"; var apiKey = Guid.NewGuid().ToString(); _resource = new MockResource(new ResourceIdentifier("GET", CreateCompaniesPath(), $"?api_key={apiKey}&filters={{\"name\":\"{name}\"}}")); _resource.ReturnsBody(JsonSearchResponse); _api = new Api(); _api.RegisterResource(_resource); _api.Start(); var client = new DueDilClientFactory(new DueDilSettings(_api.Uri, apiKey, _sandboxMode)).CreateClient(); _actual = client.SearchCompaniesAsync(new Terms() { Name = name }).Result; }
public void WhenSearchingForACompany() { _result = Client.GetCompanyAsync(Locale.Uk, "bbeaf93e71060b699a7ba9922bc286694c0aa5a3").Result; }