# `Lather.Operation.Builder`
[🔗](https://github.com/awksedgreep/lather/blob/v1.0.49/lib/lather/operation/builder.ex#L1)

Generic operation builder for SOAP services.

This module provides utilities to dynamically build SOAP requests for any operation
defined in a WSDL, without requiring hardcoded service implementations.

# `build_request`

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

Builds a SOAP request for any operation based on WSDL analysis.

## Parameters

  * `operation_info` - Operation information extracted from WSDL analysis
  * `parameters` - Map of parameters for the operation
  * `options` - Additional options for request building

## Options

  * `:style` - SOAP style (:document or :rpc, default: :document)
  * `:use` - SOAP use (:literal or :encoded, default: :literal)
  * `:namespace` - Target namespace for the operation
  * `:headers` - Additional SOAP headers
  * `:version` - SOAP version (`:v1_1` or `:v1_2`, default: `:v1_1`)
  * `:namespace_prefix` - Optional namespace prefix for the operation element (e.g. `"ns0"`)

## Examples

    operation_info = %{
      name: "GetUser",
      input: %{
        message: "GetUserRequest",
        parts: [%{name: "userId", type: "xsd:string"}]
      },
      soap_action: "http://example.com/GetUser"
    }

    params = %{"userId" => "12345"}

    {:ok, soap_envelope} = Lather.Operation.Builder.build_request(
      operation_info,
      params,
      namespace: "http://example.com/service"
    )

# `get_operation_metadata`

```elixir
@spec get_operation_metadata(map()) :: map()
```

Generates operation metadata for dynamic client usage.

## Parameters

  * `operation_info` - Operation information from WSDL

## Examples

    metadata = Lather.Operation.Builder.get_operation_metadata(operation_info)
    # %{
    #   name: "GetUser",
    #   required_parameters: ["userId"],
    #   optional_parameters: [],
    #   return_type: "User",
    #   soap_action: "http://example.com/GetUser"
    # }

# `parse_response`

```elixir
@spec parse_response(map(), map(), keyword()) :: {:ok, map()} | {:error, term()}
```

Extracts response data from SOAP envelope based on operation output specification.

## Parameters

  * `operation_info` - Operation information from WSDL
  * `response_envelope` - Parsed SOAP response envelope
  * `options` - Parsing options

## Examples

    operation_info = %{
      output: %{
        parts: [%{name: "user", type: "tns:User"}]
      }
    }

    {:ok, response_data} = Lather.Operation.Builder.parse_response(
      operation_info,
      parsed_response
    )

# `validate_parameters`

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

Validates parameters against operation input specification.

## Parameters

  * `operation_info` - Operation information from WSDL
  * `parameters` - Parameters to validate

## Examples

    iex> operation_info = %{input: %{parts: [%{name: "userId", type: "xsd:string"}]}}
    iex> Lather.Operation.Builder.validate_parameters(operation_info, %{"userId" => "123"})
    :ok

    iex> Lather.Operation.Builder.validate_parameters(operation_info, %{})
    {:error, {:missing_required_parameter, "userId"}}

---

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