77
88from integrify .logger import LOGGER_FUNCTION
99from integrify .schemas import APIResponse , DryResponse , PayloadBaseModel
10- from integrify .utils import _UNSET , _ResponseT
10+ from integrify .utils import UNSET , _ResponseT
1111
1212
1313class APIClient :
@@ -105,8 +105,8 @@ def __getattribute__(self, name: str) -> Any:
105105 verb ,
106106 handler ,
107107 # Exclude unset values, to trigger pydantic defaults
108- * (arg for arg in args if arg is not _UNSET ),
109- ** {k : v for k , v in kwds .items () if v is not _UNSET },
108+ * (arg for arg in args if arg is not UNSET ),
109+ ** {k : v for k , v in kwds .items () if v is not UNSET },
110110 )
111111
112112
@@ -178,7 +178,7 @@ def handle_payload(self, *args, **kwds):
178178 return self .__req_model .model_dump (
179179 by_alias = True ,
180180 exclude = self .req_model .URL_PARAM_FIELDS ,
181- exclude_none = True ,
181+ exclude_unset = True ,
182182 mode = 'json' ,
183183 )
184184
@@ -275,6 +275,7 @@ def sync_req(
275275 verb : str ,
276276 handler : APIPayloadHandler ,
277277 * args ,
278+ headers : Optional [dict ] = None ,
278279 ** kwds ,
279280 ) -> Union [httpx .Response , APIResponse [_ResponseT ], DryResponse ]:
280281 """Sync sorğu atan funksiya
@@ -287,19 +288,19 @@ def sync_req(
287288 assert isinstance (self .client , httpx .Client )
288289
289290 data = handler .handle_request (* args , ** kwds )
290- headers = handler .headers
291+ full_headers = { ** handler .headers , ** ( headers or {})}
291292 full_url = handler .set_urlparams (url )
292293
293294 if self .dry or handler .dry :
294295 return DryResponse (
295296 url = full_url ,
296297 verb = verb ,
297298 request_args = handler .req_args ,
298- headers = headers ,
299+ headers = full_headers ,
299300 data = data ,
300301 )
301302
302- request_kwds = {'headers' : headers , ** handler .req_args }
303+ request_kwds = {'headers' : full_headers , ** handler .req_args }
303304
304305 if verb == 'GET' :
305306 request_kwds ['params' ] = data
@@ -325,6 +326,7 @@ async def async_req( # pragma: no cover
325326 verb : str ,
326327 handler : APIPayloadHandler ,
327328 * args ,
329+ headers : Optional [dict ] = None ,
328330 ** kwds ,
329331 ) -> Union [httpx .Response , APIResponse [_ResponseT ], DryResponse ]:
330332 """Async sorğu atan funksiya
@@ -337,7 +339,7 @@ async def async_req( # pragma: no cover
337339 assert isinstance (self .client , httpx .AsyncClient )
338340
339341 data = handler .handle_request (* args , ** kwds )
340- headers = handler .headers
342+ full_headers = { ** handler .headers , ** ( headers or {})}
341343 full_url = handler .set_urlparams (url )
342344
343345 if self .dry :
@@ -346,11 +348,11 @@ async def async_req( # pragma: no cover
346348 url = full_url ,
347349 verb = verb ,
348350 request_args = handler .req_args ,
349- headers = headers ,
351+ headers = full_headers ,
350352 data = data ,
351353 )
352354
353- request_kwds = {'headers' : headers , ** handler .req_args }
355+ request_kwds = {'headers' : full_headers , ** handler .req_args }
354356
355357 if verb == 'GET' :
356358 request_kwds ['params' ] = data
0 commit comments