TheMovieDB 0.1.0

A robust and idiomatic Rust API wrapper for The Movie Database (TMDb) v3 API.
Documentation
# Base Module

The `base` module provides the core `TMDB` struct and error handling for API key issues. It handles the fundamental aspects of making requests to The Movie Database (TMDb) API.

## Enums

### `APIKeyError`

Represents errors related to the TMDb API key.

#### Variants

- `MissingAPIKey`: Indicates that the `TMDB_API_KEY` environment variable is not set.

## Structs

### `TMDB`

This is the base struct for interacting with the TMDb API. It manages the base URI, HTTP client session, request headers, and URL paths.

#### Fields

- `base_uri`: The base URI for TMDb API requests (e.g., `https://api.themoviedb.org/3`).
- `session`: An optional `reqwest::Client` instance for making HTTP requests. If `None`, a new client is created for each request.
- `timeout`: An optional timeout in seconds for HTTP requests.
- `headers`: `reqwest::header::HeaderMap` containing default headers for requests (e.g., `Content-Type`, `Accept`, `Connection`).
- `base_path`: The base path for API endpoints (e.g., `movie`, `tv`).
- `urls`: A `HashMap` storing specific endpoint paths relative to the `base_path`.

#### Methods

- `new() -> Self`: Creates a new `TMDB` instance with default headers and an empty base path and URLs.
- `_get_path(&self, key: &str) -> String`: Constructs the full path for a given URL key by combining `base_path` and the URL from `urls`.
- `_get_complete_url(&self, path: &str) -> String`: Combines the `base_uri` with a given path to form a complete URL.
- `_get_params(&self, params: &mut HashMap<String, String>) -> Result<(), APIKeyError>`: Inserts the `api_key` from the `TMDB_API_KEY` environment variable into the provided `params` HashMap. Returns an `APIKeyError::MissingAPIKey` if the environment variable is not set.
- `_request(&self, method: Method, path: &str, params: Option<HashMap<String, String>>, payload: Option<Value>) -> Result<Value, Box<dyn std::error::Error + Send + Sync + 'static>>`: The core method for making HTTP requests to the TMDb API. It handles URL construction, parameter insertion, request execution, and error handling.
- `_get(&self, path: &str, params: Option<HashMap<String, String>>) -> Result<Value, Box<dyn std::error::Error + Send + Sync + 'static>>`: A convenience method for making GET requests.
- `_post(&self, path: &str, params: Option<HashMap<String, String>>, payload: Option<Value>) -> Result<Value, Box<dyn std::error::Error + Send + Sync + 'static>>`: A convenience method for making POST requests.
- `_delete(&self, path: &str, params: Option<HashMap<String, String>>, payload: Option<Value>) -> Result<Value, Box<dyn std::error::Error + Send + Sync + 'static>>`: A convenience method for making DELETE requests.