# `Skir.RPC.ServiceClient`
[🔗](https://github.com/gepheum/skir/blob/main/lib/skir/rpc/service_client.ex#L1)

HTTP client for unary SkirRPC methods.

# `header`

```elixir
@type header() :: {String.t(), String.t()}
```

# `http_method`

```elixir
@type http_method() :: :get | :post
```

# `t`

```elixir
@type t() :: %Skir.RPC.ServiceClient{
  headers: [header()],
  service_url: String.t(),
  transport: module() | function(),
  transport_opts: keyword()
}
```

# `invoke`

```elixir
@spec invoke(t(), Skir.Method.t(), term(), keyword()) ::
  {:ok, term()} | {:error, Skir.RPC.RpcError.t()}
```

Invokes a method and returns `{:ok, response}` or `{:error, %Skir.RPC.RpcError{}}`. Options include `:headers`, `:http_method` (`:post` or `:get`), `:keep_unrecognized_values`, and transport options.

# `invoke!`

```elixir
@spec invoke!(t(), Skir.Method.t(), term(), keyword()) :: term()
```

Invokes a method, returning the decoded response or raising `Skir.RPC.RpcError`.

# `new`

```elixir
@spec new(String.t(), keyword()) :: {:ok, t()} | {:error, String.t()}
```

Creates an HTTP client, returning `{:ok, client}` or `{:error, message}`. Accepts `:headers`, `:transport`, and `:transport_opts`.

# `new!`

```elixir
@spec new!(String.t(), keyword()) :: t()
```

Creates an HTTP client or raises `ArgumentError` for an invalid URL or options.

# `with_default_header`

```elixir
@spec with_default_header(t(), String.t(), String.t()) :: t()
```

Returns a client with the default header replaced case-insensitively, or added if absent.

---

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