@@ -21,14 +21,7 @@ public class ThirdwebClient
21
21
internal string BundleId { get ; }
22
22
internal ITimeoutOptions FetchTimeoutOptions { get ; }
23
23
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 )
32
25
{
33
26
if ( string . IsNullOrEmpty ( clientId ) && string . IsNullOrEmpty ( secretKey ) )
34
27
{
@@ -49,21 +42,30 @@ private ThirdwebClient(
49
42
50
43
this . FetchTimeoutOptions = fetchTimeoutOptions ?? new TimeoutOptions ( ) ;
51
44
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
+ }
67
69
}
68
70
69
71
/// <summary>
@@ -74,17 +76,9 @@ private ThirdwebClient(
74
76
/// <param name="bundleId">The bundle ID (optional).</param>
75
77
/// <param name="fetchTimeoutOptions">The fetch timeout options (optional).</param>
76
78
/// <param name="httpClient">The HTTP client (optional).</param>
77
- /// <param name="headers">The headers to set on the HTTP client (optional).</param>
78
79
/// <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 )
87
81
{
88
- return new ThirdwebClient ( clientId , secretKey , bundleId , fetchTimeoutOptions , httpClient , headers ) ;
82
+ return new ThirdwebClient ( clientId , secretKey , bundleId , fetchTimeoutOptions , httpClient ) ;
89
83
}
90
84
}
0 commit comments