# `Lather.DynamicClient`
[🔗](https://github.com/awksedgreep/lather/blob/v1.0.49/lib/lather/dynamic_client.ex#L1)

Dynamic SOAP client that can work with any SOAP service.

This client uses WSDL analysis to understand service operations and
dynamically builds SOAP requests without requiring service-specific code.

# `t`

```elixir
@type t() :: %Lather.DynamicClient{
  base_client: Lather.Client.t(),
  default_options: keyword(),
  service_info: map()
}
```

# `call`

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

Calls a SOAP operation dynamically.

## Parameters

  * `client` - The dynamic client
  * `operation_name` - Name of the operation to call
  * `parameters` - Map of parameters for the operation
  * `options` - Additional call options

## Options

  * `:headers` - Additional SOAP headers
  * `:timeout` - Request timeout override
  * `:validate` - Whether to validate parameters (default: true)
  * `:namespace_prefix` - Namespace prefix for the operation element (e.g. `"ns0"`).
    Overrides the client-level `:namespace_prefix` set in `new/2` for this call only.

## Examples

    {:ok, response} = Lather.DynamicClient.call(
      client,
      "GetUser",
      %{"userId" => "12345"}
    )

    {:ok, response} = Lather.DynamicClient.call(
      client,
      "CreateUser",
      %{"userData" => %{"name" => "John", "email" => "john@example.com"}},
      headers: [%{"Authentication" => "Bearer token123"}]
    )

# `generate_service_report`

```elixir
@spec generate_service_report(t()) :: String.t()
```

Generates a report of the service capabilities.

## Examples

    report = Lather.DynamicClient.generate_service_report(client)
    IO.puts(report)

# `get_operation_info`

```elixir
@spec get_operation_info(t(), String.t()) ::
  {:ok, map()} | {:error, :operation_not_found}
```

Gets detailed information about a specific operation.

## Parameters

  * `client` - The dynamic client
  * `operation_name` - Name of the operation to inspect

## Examples

    {:ok, operation_info} = Lather.DynamicClient.get_operation_info(client, "GetUser")
    # %{
    #   name: "GetUser",
    #   required_parameters: ["userId"],
    #   optional_parameters: [],
    #   return_type: "User",
    #   soap_action: "http://example.com/GetUser"
    # }

# `get_service_info`

```elixir
@spec get_service_info(t()) :: map()
```

Gets service information including endpoints, namespaces, and types.

## Examples

    service_info = Lather.DynamicClient.get_service_info(client)
    # %{
    #   service_name: "MyService",
    #   target_namespace: "http://example.com/service",
    #   endpoints: [...],
    #   operations: [...],
    #   types: [...]
    # }

# `list_operations`

```elixir
@spec list_operations(t()) :: [map()]
```

Lists all available operations for the service.

## Examples

    operations = Lather.DynamicClient.list_operations(client)
    # [
    #   %{name: "GetUser", required_parameters: ["userId"], ...},
    #   %{name: "CreateUser", required_parameters: ["userData"], ...}
    # ]

# `new`

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

Creates a new dynamic client from a WSDL URL or file path.

## Parameters

  * `wsdl_source` - URL or file path to the WSDL
  * `options` - Client configuration options

## Options

  * `:service_name` - Specific service name if WSDL contains multiple services
  * `:endpoint_override` - Override the endpoint URL from WSDL
  * `:default_headers` - Default headers to include in all requests
  * `:authentication` - Authentication configuration
  * `:timeout` - Default request timeout
  * `:soap_version` - SOAP protocol version (`:v1_1` or `:v1_2`, auto-detected if not specified)
  * `:namespace_prefix` - Default namespace prefix for operation elements in all calls (e.g. `"ns0"`).
    Can be overridden per call via `call/4`.

## Examples

    {:ok, client} = Lather.DynamicClient.new("http://example.com/service?wsdl")

    {:ok, client} = Lather.DynamicClient.new(
      "http://example.com/service?wsdl",
      authentication: {:basic, "user", "pass"},
      timeout: 60_000
    )

# `validate_parameters`

```elixir
@spec validate_parameters(t(), String.t(), map()) :: :ok | {:error, term()}
```

Validates parameters for a specific operation without making the call.

## Parameters

  * `client` - The dynamic client
  * `operation_name` - Name of the operation
  * `parameters` - Parameters to validate

## Examples

    :ok = Lather.DynamicClient.validate_parameters(client, "GetUser", %{"userId" => "123"})

    {:error, {:missing_required_parameter, "userId"}} =
      Lather.DynamicClient.validate_parameters(client, "GetUser", %{})

---

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