README.md

# OpenClawCases SDK for Elixir

`openclawcases_sdk` is the official Elixir SDK for the OpenClawCases API.
It helps developers retrieve historical case data, inspect individual case
records, and load aggregated reporting metrics.

The package is intentionally lightweight:

- typed public structs for clients, responses, and errors
- a thin request layer built on `Req`
- convenience helpers for case and reporting endpoints
- package metadata prepared for Hex publishing

## Installation

Add the dependency to your `mix.exs`:

```elixir
def deps do
  [
    {:openclawcases_sdk, "~> 0.1.0"}
  ]
end
```

Then fetch dependencies:

```bash
mix deps.get
```

## Quick Start

```elixir
client =
  OpenclawcasesSDK.new(
    api_key: System.fetch_env!("OPENCLAWCASES_API_KEY")
  )

{:ok, response} =
  OpenclawcasesSDK.list_cases(client, params: %{limit: 20})

response.status
response.body
```

## Built-In Helpers

List historical cases:

```elixir
OpenclawcasesSDK.list_cases(client, params: %{limit: 25, industry: "retail"})
```

Fetch a case record:

```elixir
OpenclawcasesSDK.get_case(client, "case_123")
```

Load a named report:

```elixir
OpenclawcasesSDK.get_report(client, "weekly-summary")
```

Load aggregate statistics:

```elixir
OpenclawcasesSDK.get_statistics(client, params: %{range: "90d"})
```

## Configuration

The client accepts these options:

- `:api_key` - API key used for authenticated requests
- `:base_url` - defaults to `https://openclawcases.com`
- `:api_key_header` - defaults to `"authorization"`
- `:api_key_prefix` - defaults to `"Bearer"`
- `:headers` - additional request headers
- `:receive_timeout` - request timeout in milliseconds
- `:req_options` - raw `Req` options merged into each request

## Generic Requests

You can still call lower-level helpers for endpoints not yet wrapped:

```elixir
OpenclawcasesSDK.get(client, "/v1/datasets")
```

```elixir
OpenclawcasesSDK.request(client, :post, "/v1/reports/custom", body: %{group_by: ["industry"]})
```

## Publishing Notes

Before the next public release, update these items:

- replace the `@source_url_placeholder` in `mix.exs` with the public repository URL
- align helper paths with the production OpenClawCases API contract
- expand tests around filters, pagination, and long-running report jobs

## Official Links

- Homepage: [https://openclawcases.com/](https://openclawcases.com/)
- Official documentation and support: [https://openclawcases.com/](https://openclawcases.com/)

## License

MIT