Last active
September 22, 2021 06:03
Revisions
-
ByteDev revised this gist
Sep 22, 2021 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,11 @@ ```csharp public interface ICustomerApiClient { Task<SearchCustomerResponse> SearchAsync(SearchCustomerRequest request, CancellationToken cancellationToken = default); } // ... public class CustomerApiClient : ICustomerApiClient { private readonly HttpClient _httpClient; -
ByteDev revised this gist
Sep 22, 2021 . 1 changed file with 25 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,34 +1,34 @@ ```csharp public class CustomerApiClient : ICustomerApiClient { private readonly HttpClient _httpClient; private readonly CustomerApiClientConfig _config; private readonly RequestFactory _requestFactory; public CustomerApiClient(HttpClient httpClient, CustomerApiClientConfig config) { _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); _config = config ?? throw new ArgumentNullException(nameof(config)); _requestFactory = new RequestFactory(config); } public async Task<SearchCustomerResponse> SearchAsync(SearchCustomerRequest request, CancellationToken cancellationToken = default) { try { var httpRequest = _requestFactory.Create(request, _config.SearchCustomerUri); var httpResponse = await _httpClient.SendAsync(httpRequest, cancellationToken); return await ResponseHandler.HandleAsync<SearchCustomerResponse>(httpResponse); } catch (Exception ex) { throw new CustomerApiClientException("Error occurred while searching for customer.", ex); } } // ... more methods for API operations } ``` -
ByteDev renamed this gist
Sep 22, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ByteDev created this gist
Sep 22, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ ```csharp public class CustomerApiClient : ICustomerApiClient { private readonly HttpClient _httpClient; private readonly CustomerApiClientConfig _config; private readonly RequestFactory _requestFactory; public CustomerApiClient(HttpClient httpClient, CustomerApiClientConfig config) { _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); _config = config ?? throw new ArgumentNullException(nameof(config)); _requestFactory = new RequestFactory(config); } public async Task<SearchCustomerResponse> SearchAsync(SearchCustomerRequest request, CancellationToken cancellationToken = default) { try { var httpRequest = _requestFactory.Create(request, _config.SearchCustomerUri); var httpResponse = await _httpClient.SendAsync(httpRequest, cancellationToken); return await ResponseHandler.HandleAsync<SearchCustomerResponse>(httpResponse); } catch (Exception ex) { throw new CustomerApiClientException("Error occurred while searching for customer.", ex); } } // ... more methods for API operations } ```