# Dime.Scheduler for Rust
Official Rust client for the [Dime.Scheduler](https://dimescheduler.com) API. One async client,
a typed accessor per entity, and the same accessor names as the .NET, JavaScript, Python and
Go SDKs.
## Installation
```toml
[dependencies]
dimescheduler = "0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
```
## Quick start
```rust
use dimescheduler::{entities::Category, DimeSchedulerClient, Environment};
#[tokio::main]
async fn main() -> dimescheduler::Result<()> {
// Reads DIMESCHEDULER_API_KEY and targets production.
let client = DimeSchedulerClient::from_env()?;
// Or pick the environment explicitly:
// let client = DimeSchedulerClient::with_environment("api-key", Environment::Test);
client
.categories
.create(&Category {
name: "INSTALL".into(),
display_name: "Install".into(),
color: "#22d3ee".into(),
})
.await?;
for dto in client.categories.get_all().await? {
println!("{:?}", dto.name);
}
Ok(())
}
```
## Accessors
Every import-shaped entity (`client.categories`, `client.resources`, `client.tags`, …) exposes
`create`, `create_many`, `update`, `update_many`, `delete`, `delete_many` and `get_all`. Write
methods take an `entities::*` value and return the API's response envelope; `get_all` returns
the matching `types::*Dto` list.
| `appointments` | `get(start, end, &resources)`, `get_by_id(id)` |
| `jobs` | `get(job_no)` |
| `tasks` | `list(&TaskListOptions)` |
| `notifications` | `get(page, limit, &NotificationListOptions)` |
| `resource_capacities`, `time_entries`, `time_sessions` | `get(start, end)` |
| `calendars`, `resource_types`, `appointment_dependencies`, `appointment_fields` | `get_all()` only |
| `task_budget_entries` | `create`, `create_many`, `delete`, `delete_many` only |
| `task_assignments` | `create(&req)`, `delete(&req)` |
| `connectors`, `geocoding`, `imports`, `messages`, `optimization`, `recommendation`, `recurring_appointments`, `users` | see the rustdoc |
Dates are plain strings in the API's own format: RFC 3339 for appointments and resource
capacities, `YYYY-MM-DD` for time entries and sessions.
## Generated types
`dimescheduler::entities` holds the import bodies you send, `dimescheduler::types` the DTOs,
request types and enums, and `dimescheduler::models` the server's domain read-models that
appear nested inside DTOs. All structs derive `Default`, so build them with
`..Default::default()`. They are generated from the OpenAPI spec; see
[`scripts/codegen.py`](scripts/codegen.py).
## Errors
Every method returns `dimescheduler::Result<T>`. A non-2xx response is
`Error::Api { status, body }` where `body` is already the human-readable message when the
API sent one of its known error shapes. Transport failures are `Error::Http`.
This crate does **not** retry. A `429` or `5xx` is returned to you; retry at the call site
if your workload needs it.
## Environments
`Environment::Production` (`https://api.dimescheduler.com`), `Environment::Test`,
`Environment::Sandbox`.
## License
MIT