# `Tinkex.API.ResponseHandler`
[🔗](https://github.com/North-Shore-AI/tinkex/blob/v0.4.0/lib/tinkex/api/response_handler.ex#L1)

HTTP response handling and error parsing for Tinkex API.

Handles:
- Status code-based response processing
- JSON decoding
- Error categorization
- Response wrapping for different modes
- Retry-After header parsing

# `handle`

```elixir
@spec handle(
  {:ok, Finch.Response.t()} | {:error, term()},
  keyword()
) :: {:ok, map() | Tinkex.API.Response.t()} | {:error, Tinkex.Error.t()}
```

Handles a Finch response or error, returning standardized result.

Supports different response modes via opts[:response]:
- nil or :raw: Returns decoded JSON data
- :wrapped: Returns `Tinkex.API.Response` struct with metadata

## Options

- `:response` - Response mode (:wrapped or nil)
- `:method` - HTTP method (for response metadata)
- `:url` - Request URL (for response metadata)
- `:retries` - Number of retries performed
- `:elapsed_native` - Request duration in native time units

# `parse_retry_after`

```elixir
@spec parse_retry_after([{String.t(), String.t()}]) :: non_neg_integer()
```

Parses Retry-After headers into milliseconds.

Supports both formats:
- retry-after-ms: Direct milliseconds value
- retry-after: Seconds value (converted to ms)

Returns 1000ms (1 second) as default if header is missing or invalid.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
