/// <summary>
        /// Initializes a new instance of the <see cref="BaseClient"/> class.
        /// </summary>
        /// <param name="httpClient">An optional HTTP client which may me injected in order to facilitate testing.</param>
        /// <param name="options">A <see cref="BaseClientOptions"/> instance that defines the configuration settings to use with the client.</param>
        /// <returns>Interface to the Twilio SendGrid REST API.</returns>
        protected BaseClient(HttpClient httpClient, BaseClientOptions options)
        {
            this.options = options ?? throw new ArgumentNullException(nameof(options));

            this.client = httpClient ?? CreateHttpClientWithRetryHandler(options);
            if (this.options.RequestHeaders != null && this.options.RequestHeaders.TryGetValue(ContentType, out var contentType))
            {
                this.MediaType = contentType;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseClient"/> class.
 /// </summary>
 /// <param name="webProxy">Web proxy.</param>
 /// <param name="options">A <see cref="BaseClientOptions"/> instance that defines the configuration settings to use with the client.</param>
 /// <returns>Interface to the Twilio SendGrid REST API.</returns>
 protected BaseClient(IWebProxy webProxy, BaseClientOptions options)
     : this(CreateHttpClientWithWebProxy(webProxy, options), options)
 {
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseClient"/> class.
 /// </summary>
 /// <param name="webProxy">Web proxy.</param>
 /// <param name="options">A <see cref="BaseClientOptions"/> instance that defines the configuration settings to use with the client.</param>
 /// <returns>Interface to the Twilio SendGrid REST API.</returns>
 public BaseClient(IWebProxy webProxy, BaseClientOptions options)
     : this(CreateHttpClientWithWebProxy(webProxy), options)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseClient"/> class.
 /// </summary>
 /// <param name="options">A <see cref="BaseClientOptions"/> instance that defines the configuration settings to use with the client.</param>
 /// <returns>Interface to the Twilio SendGrid REST API.</returns>
 protected BaseClient(BaseClientOptions options)
     : this(httpClient : null, options)
 {
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseClient"/> class.
 /// </summary>
 /// <param name="options">A <see cref="BaseClientOptions"/> instance that defines the configuration settings to use with the client.</param>
 /// <returns>Interface to the Twilio SendGrid REST API.</returns>
 public BaseClient(BaseClientOptions options)
     : this(httpClient : null, options)
 {
 }