Skip to main content

basecamp_sdk/
lib.rs

1#![doc = include_str!("../README.md")]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
4//!
5//! # Request construction policy
6//!
7//! Request bodies, query-parameter structs and [`Config`] are plain `pub` structs with
8//! `Default` and no `#[non_exhaustive]`, so they are built literally —
9//! `CreateTodoRequestContent { content, ..Default::default() }` — from any crate. A field
10//! the model adds to one of them is therefore a source break, accepted as a `0.MINOR`
11//! release under the pre-1.0 policy. Response models and open enumerations (`ErrorCode`,
12//! the model's own string enums) are `#[non_exhaustive]`: a field or variant the API grows
13//! is not a break. A shape that requests and responses share (`QuestionSchedule`) is a
14//! request shape, and stays literal-constructible. Types with private fields ([`Error`],
15//! [`Client`]) need neither.
16//!
17//! # Re-exported dependencies
18//!
19//! [`chrono`] types are the model's date and time representation and [`reqwest`]'s
20//! builder is the shipped transport's seam, so both crates are re-exported here at the
21//! version this crate was built against: use `basecamp_sdk::chrono` and
22//! `basecamp_sdk::reqwest` rather than guessing the matching minor. A minor bump of either
23//! is a `0.MINOR` release of this crate.
24//!
25//! # Public traits
26//!
27//! [`HttpClient`], [`AuthStrategy`], [`TokenProvider`] and [`Hooks`] are `Send + Sync` and
28//! object-safe; the SDK holds each as an `Arc<dyn Trait>`. A method added to one of them
29//! gets a default body, so implementing them stays source-compatible across `0.x.PATCH`
30//! releases.
31
32pub mod auth;
33pub mod client;
34pub mod config;
35mod deadline;
36pub mod download;
37pub mod error;
38#[doc(hidden)]
39pub mod generated;
40pub mod hooks;
41pub mod http;
42pub mod mentions;
43#[cfg(feature = "oauth")]
44#[cfg_attr(docsrs, doc(cfg(feature = "oauth")))]
45pub mod oauth;
46pub mod operation;
47pub mod pagination;
48pub mod retry;
49pub mod route;
50pub mod security;
51pub mod services;
52pub mod types;
53pub mod url;
54pub mod version;
55pub mod webhooks;
56
57pub use auth::{AuthStrategy, BearerAuth, StaticTokenProvider, TokenProvider};
58pub use client::{AccountClient, Client, ClientBuilder, Response};
59pub use config::Config;
60pub use download::DownloadResult;
61pub use error::{Error, ErrorCode};
62pub use generated::OPERATION_COUNT;
63pub use hooks::Hooks;
64pub use http::HttpClient;
65pub use mentions::{mention_markup, mentioned_person_ids, person_id_from_sgid, with_mentions};
66#[cfg(feature = "oauth")]
67#[cfg_attr(docsrs, doc(cfg(feature = "oauth")))]
68pub use oauth::{
69    DeviceAuthorization, DeviceFlowError, DeviceFlowReason, DiscoveryOutcome, ExchangeRequest,
70    FallbackReason, OAuthClient, Pkce, ProtectedResourceMetadata, RefreshRequest,
71    RefreshingTokenProvider, SelectionError, SelectionFailure, ServerMetadata, Token,
72};
73pub use operation::Operation;
74pub use pagination::{ListMeta, ListResult, Page, PageItems};
75pub use types::{AuthRoutableUrl, Date, DateChange, DateTime, FlexibleTime, SensitiveString};
76pub use version::{API_VERSION, VERSION};
77
78pub use chrono;
79#[cfg(feature = "reqwest")]
80#[cfg_attr(docsrs, doc(cfg(feature = "reqwest")))]
81pub use reqwest;
82
83/// The request and response types the Basecamp API speaks, generated from the model.
84pub mod models {
85    pub use crate::generated::types::*;
86}
87
88/// Every modelled route as public data, generated from the model.
89pub mod routes {
90    pub use crate::generated::routes::*;
91    pub use crate::route::{
92        Backoff, BodyKind, OperationMetadata, Pagination, ParamKind, Representation, RetryConfig,
93        Route, RouteParam, WriteSemantics,
94    };
95}
96
97/// Per-operation behaviour from `behavior-model.json`, generated from the model.
98pub mod metadata {
99    pub use crate::generated::metadata::*;
100}