Higher order function that takes one of our bound API methods and wraps it to support returning the raw `APIResponse` object directly.
(func: Callable[P, R])
| 735 | |
| 736 | |
| 737 | def to_raw_response_wrapper(func: Callable[P, R]) -> Callable[P, APIResponse[R]]: |
| 738 | """Higher order function that takes one of our bound API methods and wraps it |
| 739 | to support returning the raw `APIResponse` object directly. |
| 740 | """ |
| 741 | |
| 742 | @functools.wraps(func) |
| 743 | def wrapped(*args: P.args, **kwargs: P.kwargs) -> APIResponse[R]: |
| 744 | extra_headers: dict[str, str] = {**(cast(Any, kwargs.get("extra_headers")) or {})} |
| 745 | extra_headers[RAW_RESPONSE_HEADER] = "raw" |
| 746 | |
| 747 | kwargs["extra_headers"] = extra_headers |
| 748 | |
| 749 | return cast(APIResponse[R], func(*args, **kwargs)) |
| 750 | |
| 751 | return wrapped |
| 752 | |
| 753 | |
| 754 | def async_to_raw_response_wrapper(func: Callable[P, Awaitable[R]]) -> Callable[P, Awaitable[AsyncAPIResponse[R]]]: |