@@ -50,9 +50,7 @@ public async Task<T> GetAsync<T>(
50
50
{
51
51
EnsureHttpClient ( ) ;
52
52
53
- string requestUri = queryParams == null ? uri : QueryHelpers . AddQueryString ( uri , queryParams ) ;
54
-
55
- var response = await SendAsync ( requestUri , HttpMethod . Get , headers , cancellationToken : cancellationToken ) ;
53
+ var response = await SendAsync ( uri , HttpMethod . Get , queryParams , headers , cancellationToken : cancellationToken ) ;
56
54
57
55
return await response . ParseStreamAsync < T > ( serializerSettings ) ;
58
56
}
@@ -79,10 +77,13 @@ private static async Task<Exception> BuildException(HttpResponseMessage response
79
77
private async Task < HttpResponseMessage > SendAsync (
80
78
string requestUri ,
81
79
HttpMethod httpMethod ,
80
+ IDictionary < string , string > queryParams = null ,
82
81
IDictionary < string , string > headers = null ,
83
82
Action < HttpRequestMessage > attachContent = null ,
84
83
CancellationToken cancellationToken = default )
85
84
{
85
+ requestUri = AddQueryString ( requestUri , queryParams ) ;
86
+
86
87
HttpRequestMessage httpRequest = new HttpRequestMessage ( httpMethod , requestUri ) ;
87
88
httpRequest . Headers . Authorization = new AuthenticationHeaderValue ( "Bearer" , _options . AuthToken ) ;
88
89
httpRequest . Headers . Add ( "Notion-Version" , _options . NotionVersion ) ;
@@ -127,9 +128,7 @@ void AttachContent(HttpRequestMessage httpRequest)
127
128
httpRequest . Content = new StringContent ( JsonConvert . SerializeObject ( body , defaultSerializerSettings ) , Encoding . UTF8 , "application/json" ) ;
128
129
}
129
130
130
- string requestUri = queryParams == null ? uri : QueryHelpers . AddQueryString ( uri , queryParams ) ;
131
-
132
- var response = await SendAsync ( requestUri , HttpMethod . Post , headers , AttachContent , cancellationToken : cancellationToken ) ;
131
+ var response = await SendAsync ( uri , HttpMethod . Post , queryParams , headers , AttachContent , cancellationToken : cancellationToken ) ;
133
132
134
133
return await response . ParseStreamAsync < T > ( serializerSettings ) ;
135
134
}
@@ -144,9 +143,7 @@ void AttachContent(HttpRequestMessage httpRequest)
144
143
httpRequest . Content = new StringContent ( serializedBody , Encoding . UTF8 , "application/json" ) ;
145
144
}
146
145
147
- string requestUri = queryParams == null ? uri : QueryHelpers . AddQueryString ( uri , queryParams ) ;
148
-
149
- var response = await SendAsync ( requestUri , new HttpMethod ( "PATCH" ) , headers , AttachContent , cancellationToken : cancellationToken ) ;
146
+ var response = await SendAsync ( uri , new HttpMethod ( "PATCH" ) , queryParams , headers , AttachContent , cancellationToken : cancellationToken ) ;
150
147
151
148
return await response . ParseStreamAsync < T > ( serializerSettings ) ;
152
149
}
@@ -161,5 +158,10 @@ private HttpClient EnsureHttpClient()
161
158
162
159
return _httpClient ;
163
160
}
161
+
162
+ private static string AddQueryString ( string uri , IDictionary < string , string > queryParams )
163
+ {
164
+ return queryParams == null ? uri : QueryHelpers . AddQueryString ( uri , queryParams ) ;
165
+ }
164
166
}
165
167
}
0 commit comments