# `Stancer.DynamicAPI`

Dynamically generated Stancer API functions from OpenAPI specification.

This module generates all available API functions at runtime from the Stancer OpenAPI spec.
Each function is automatically documented and type-specified based on the schema.

## Generated Functions

Functions are generated for each endpoint in the OpenAPI spec, including:
- `tokenize_card/1` - POST /tokens
- `create_payment/1` - POST /payments
- `get_payment/1` - GET /payments/{id}
- `capture_payment/2` - POST /payments/{id}/capture
- `refund_payment/2` - POST /payments/{id}/refund
- `get_card/1` - GET /cards/{id}
- `delete_card/1` - DELETE /cards/{id}
- And many more endpoints based on the Stancer API

All functions return `{:ok, response_data}` on success or `{:error, reason}` on failure.

# `call`

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

Call an API endpoint dynamically by name with parameters.

Parameters:
- `operation_id`: The operationId from OpenAPI
- `params`: Map or list of parameters for the operation

Returns: `{:ok, response}` or `{:error, reason}`

Example:
```elixir
{:ok, token} = Stancer.DynamicAPI.call("post_tokens", %{
  "card" => %{
    "number" => "4111111111111111",
    "exp_month" => 12,
    "exp_year" => 2026,
    "cvc" => "123"
  }
})
```

# `get_endpoint_info`

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

Get information about a specific endpoint.

Parameters:
- `operation_id`: The operationId from OpenAPI (e.g., "post_tokens")

Returns: `{:ok, endpoint_info}` or `{:error, :not_found}`

# `get_endpoints`

```elixir
@spec get_endpoints() :: {:ok, [map()]} | {:error, term()}
```

Load the OpenAPI specification and return all available endpoints.

Returns a list of endpoint maps with metadata from the OpenAPI spec.

# `get_operations_by_resource`

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

Get all available operations grouped by tag/resource.

Returns a map where keys are resource names and values are lists of operations.

# `list_operations`

```elixir
@spec list_operations() :: {:ok, [map()]} | {:error, term()}
```

List all available API operations with their documentation.

Returns a list of operation maps with full metadata.

# `print_api_docs`

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

Print formatted documentation for all available operations.

This is useful for exploring the API in development.

---

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