hey_sdk/lib.rs
1//! The Rust client for the [HEY](https://www.hey.com) API.
2//!
3//! Types, routes and service methods are generated from the Smithy model in the
4//! repository's `spec/` directory; everything else in this crate is the plumbing they
5//! share: authentication, retries, redirects, the response cache, pagination and account
6//! scope. All of it sends through one [`http::HttpClient`], which an application may
7//! replace with its own; the `reqwest` feature, on by default, ships one.
8//!
9//! ```no_run
10//! use hey_sdk::{Client, Config, StaticTokenProvider};
11//!
12//! # async fn run() -> Result<(), hey_sdk::Error> {
13//! let client = Client::new(Config::default(), StaticTokenProvider::new(std::env::var("HEY_TOKEN").unwrap()))?;
14//! for mailbox in client.boxes().list().await?.iter() {
15//! println!("{} ({})", mailbox.name, mailbox.kind);
16//! }
17//! # Ok(())
18//! # }
19//! ```
20
21#![forbid(unsafe_code)]
22// docs.rs builds with `--cfg docsrs` on nightly, where `doc_cfg` badges the items that
23// exist only with a feature on.
24#![cfg_attr(docsrs, feature(doc_cfg))]
25#![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used))]
26
27mod account_scope;
28/// Who a request goes out as: the token it carries and the strategy that puts it on.
29pub mod auth;
30/// The response cache: JSON reads kept by `ETag`, so a repeated one is answered from a 304.
31pub mod cache;
32/// The client, how it is built, and the send every call goes through.
33pub mod client;
34/// What a client needs to know before it can talk to HEY, and where that is read from.
35pub mod config;
36/// The error every call can answer with, its categories, and the exit status each maps to.
37pub mod error;
38pub mod form;
39mod generated;
40pub mod http;
41/// Signing in to HEY over OAuth 2.0: discovery, the authorization code flow with PKCE, and
42/// refresh.
43pub mod oauth;
44pub mod observability;
45/// A request the client has not sent yet, and everything a caller may say about it first.
46pub mod operation;
47/// Paginated reads: one page with the cursor for the next, and the walks that follow it.
48pub mod pagination;
49mod raw;
50pub mod resilience;
51/// What the model says about an operation: its method, its path template and how it behaves.
52pub mod route;
53/// The checks that keep credentials on the HEY origin, and the redaction that keeps them out
54/// of logs.
55pub mod security;
56pub mod services;
57mod trace;
58/// The scalars HEY's records are made of: dates, instants, and strings that must not be
59/// logged.
60pub mod types;
61/// Recognizing HEY paths and URLs as pasted from the web app, offline.
62pub mod url;
63/// The SDK's version, the API contract it was built against, and the `User-Agent` naming
64/// both.
65pub mod version;
66
67pub use auth::{AuthStrategy, BearerAuth, StaticTokenProvider, TokenProvider};
68pub use client::{Client, ClientBuilder, Response};
69pub use config::Config;
70pub use error::{Error, ErrorCode};
71pub use form::FormResponse;
72pub use http::HttpClient;
73pub use operation::Operation;
74pub use pagination::Page;
75pub use types::{Date, DateTime, SensitiveString};
76pub use version::{API_VERSION, VERSION};
77
78/// The request and response types HEY speaks, generated from the model.
79pub mod models {
80 pub use crate::generated::types::*;
81}
82
83/// Every modelled route, generated from the model.
84pub mod routes {
85 pub use crate::generated::routes::*;
86 pub use crate::route::{Pagination, ParamKind, ParamRole, Retry, Route, RouteParam};
87}