loops_so/lib.rs
1//! Unofficial Rust SDK for [Loops.so](https://loops.so), the email platform
2//! for SaaS.
3//!
4//! Two layers:
5//!
6//! - [`LoopsClient`] wraps every Loops endpoint with typed arguments, maps
7//! failures to [`LoopsError`], and enforces [safe mode](LoopsClientBuilder::safe_mode).
8//! This is what most code should use.
9//! - [`generated`] is generated from the Loops OpenAPI spec by [oas3-gen]. It
10//! holds the request and response models the client returns, plus the raw
11//! `LoopsOpenApiSpecClient` (see [`LoopsClient::low_level`]).
12//!
13//! ```no_run
14//! # async fn run() -> loops_so::Result<()> {
15//! use loops_so::{ConfigureOptions, TransactionalOptions};
16//!
17//! // Or set the LOOPS_API_KEY environment variable.
18//! loops_so::configure(ConfigureOptions::new().api_key("your_api_key"));
19//! let client = loops_so::get_client()?;
20//!
21//! let variables = client.get_transactional_variables("clfq6dinn000yl70fgwwyp82l").await?;
22//! client
23//! .send_transactional_email(
24//! "clfq6dinn000yl70fgwwyp82l",
25//! "user@example.com",
26//! TransactionalOptions::new()
27//! .data_variable("firstName", "Jane")
28//! .data_variable("inviteLink", "https://myapp.com/invite/abc123"),
29//! )
30//! .await?;
31//! # let _ = variables;
32//! # Ok(())
33//! # }
34//! ```
35//!
36//! [oas3-gen]: https://github.com/eklipse2k8/oas3-gen
37
38mod client;
39mod config;
40mod error;
41pub mod responses;
42pub mod routes;
43mod spec;
44#[cfg(feature = "testing")]
45pub mod testing;
46
47/// Code generated from the Loops OpenAPI spec. Never edit by hand: `just
48/// regenerate` replaces the whole directory.
49///
50/// Two oas3-gen limitations matter if you use these models directly:
51///
52/// - A decoded member of a discriminated union (a workflow node, an audience
53/// filter condition) does not re-emit its tag (`typeName`, `type`) when
54/// serialized again. Build request JSON yourself rather than re-sending a
55/// decoded model.
56/// - The low-level client decodes some failure bodies into untagged enums
57/// that keep only the fields the first matching variant knows. The
58/// high-level [`LoopsClient`] never does this: its [`LoopsError::Api`]
59/// carries the raw JSON body.
60#[allow(
61 clippy::all,
62 clippy::pedantic,
63 missing_docs,
64 rustdoc::bare_urls,
65 rustdoc::broken_intra_doc_links,
66 rustdoc::invalid_html_tags
67)]
68pub mod generated;
69
70pub use client::{
71 ContactFields, ContactId, DeleteNodeOptions, EmailFormat, EmailMessageUpdate, EventOptions,
72 LoopsClient, LoopsClientBuilder, NodePlacement, Page, PreviewOptions, TransactionalOptions,
73 get_client, reset_client,
74};
75pub use config::{
76 API_KEY_ENV_VAR, ConfigureOptions, DEFAULT_BASE_URL, LoopsConfig, configure, get_config,
77};
78pub use error::{LoopsError, Result};
79pub use responses::{
80 Contact, TransactionalEmail, TransactionalEmailPagination, TransactionalEmailsResponse,
81};
82pub use spec::{LOOPS_API_VERSION, OPENAPI_SPEC, openapi_spec_path};