@@ -21,14 +21,7 @@ public class ThirdwebClient
2121 internal string BundleId { get ; }
2222 internal ITimeoutOptions FetchTimeoutOptions { get ; }
2323
24- private ThirdwebClient (
25- string clientId = null ,
26- string secretKey = null ,
27- string bundleId = null ,
28- ITimeoutOptions fetchTimeoutOptions = null ,
29- IThirdwebHttpClient httpClient = null ,
30- Dictionary < string , string > headers = null
31- )
24+ private ThirdwebClient ( string clientId = null , string secretKey = null , string bundleId = null , ITimeoutOptions fetchTimeoutOptions = null , IThirdwebHttpClient httpClient = null )
3225 {
3326 if ( string . IsNullOrEmpty ( clientId ) && string . IsNullOrEmpty ( secretKey ) )
3427 {
@@ -49,21 +42,30 @@ private ThirdwebClient(
4942
5043 this . FetchTimeoutOptions = fetchTimeoutOptions ?? new TimeoutOptions ( ) ;
5144
52- this . HttpClient = httpClient ?? new ThirdwebHttpClient ( ) ;
53-
54- this . HttpClient . SetHeaders (
55- headers
56- ?? new Dictionary < string , string >
57- {
58- { "x-sdk-name" , "Thirdweb.NET" } ,
59- { "x-sdk-os" , System . Runtime . InteropServices . RuntimeInformation . OSDescription } ,
60- { "x-sdk-platform" , "dotnet" } ,
61- { "x-sdk-version" , Constants . VERSION } ,
62- { "x-client-id" , this . ClientId } ,
63- { "x-secret-key" , this . SecretKey } ,
64- { "x-bundle-id" , this . BundleId }
65- }
66- ) ;
45+ if ( httpClient != null )
46+ {
47+ this . HttpClient = httpClient ;
48+ }
49+ else
50+ {
51+ var defaultHeaders = new Dictionary < string , string >
52+ {
53+ { "x-sdk-name" , "Thirdweb.NET" } ,
54+ { "x-sdk-os" , System . Runtime . InteropServices . RuntimeInformation . OSDescription } ,
55+ { "x-sdk-platform" , "dotnet" } ,
56+ { "x-sdk-version" , Constants . VERSION } ,
57+ { "x-client-id" , this . ClientId } ,
58+ } ;
59+ if ( ! string . IsNullOrEmpty ( this . SecretKey ) )
60+ {
61+ defaultHeaders . Add ( "x-secret-key" , this . SecretKey ) ;
62+ }
63+ if ( ! string . IsNullOrEmpty ( this . BundleId ) )
64+ {
65+ defaultHeaders . Add ( "x-bundle-id" , this . BundleId ) ;
66+ }
67+ this . HttpClient = new ThirdwebHttpClient ( defaultHeaders ) ;
68+ }
6769 }
6870
6971 /// <summary>
@@ -74,17 +76,9 @@ private ThirdwebClient(
7476 /// <param name="bundleId">The bundle ID (optional).</param>
7577 /// <param name="fetchTimeoutOptions">The fetch timeout options (optional).</param>
7678 /// <param name="httpClient">The HTTP client (optional).</param>
77- /// <param name="headers">The headers to set on the HTTP client (optional).</param>
7879 /// <returns>A new instance of <see cref="ThirdwebClient"/>.</returns>
79- public static ThirdwebClient Create (
80- string clientId = null ,
81- string secretKey = null ,
82- string bundleId = null ,
83- ITimeoutOptions fetchTimeoutOptions = null ,
84- IThirdwebHttpClient httpClient = null ,
85- Dictionary < string , string > headers = null
86- )
80+ public static ThirdwebClient Create ( string clientId = null , string secretKey = null , string bundleId = null , ITimeoutOptions fetchTimeoutOptions = null , IThirdwebHttpClient httpClient = null )
8781 {
88- return new ThirdwebClient ( clientId , secretKey , bundleId , fetchTimeoutOptions , httpClient , headers ) ;
82+ return new ThirdwebClient ( clientId , secretKey , bundleId , fetchTimeoutOptions , httpClient ) ;
8983 }
9084}
0 commit comments