public LoggingRequestSenderFacts() { _sender = Substitute.For <IHttpRequestSender>(); _sut = new LoggingRequestSender(_sender); _logger = Logger.CaptureTo(_logEvents); _request = new HttpRequestMessageTemplate(HttpMethod.Get, new Uri("/documents", UriKind.Relative)); }
/// <summary> /// Creates a new instance of <see cref="WaivesClient"/> using the given /// API URI and logger. By default, the client is created for the public /// Waives platform at https://api.waives.io/, and no logger is used. /// <see cref="Login"/> must be called on this client before attempting to /// use it for document operations. /// </summary> /// <param name="apiUri">The URI of the Waives API instance to use. Defaults /// to https://api.waives.io/. </param> /// <returns>A new <see cref="WaivesClient"/> instance ready for /// authentication. <see cref="Login"/> must be called on this client before /// attempting to use it for document operations. /// </returns> /// <example> /// <code> /// <![CDATA[ /// public static class Program /// { /// public static async Task Main(string[] args) /// { /// var client = WaivesClient.Create().Login("my-client-id", "my-client-secret"); /// foreach (var document in await client.GetAllDocuments()) /// { /// await Console.WriteLineAsync(document.Id); /// } /// } /// } /// ]]> /// </code> /// </example> public static WaivesClient Create(Uri apiUri = null) { apiUri = apiUri ?? new Uri(DefaultUrl); var requestSender = new LoggingRequestSender( new TimeoutHandlingRequestSender( new FailedRequestHandlingRequestSender( new ReliableRequestSender(new RequestSender( new HttpClient { BaseAddress = apiUri }))))); return(new WaivesClient(requestSender)); }