Expand description
Unofficial Rust SDK for Loops.so, the email platform for SaaS.
Two layers:
LoopsClientwraps every Loops endpoint with typed arguments, maps failures toLoopsError, and enforces safe mode. This is what most code should use.generatedis generated from the Loops OpenAPI spec by oas3-gen. It holds the request and response models the client returns, plus the rawLoopsOpenApiSpecClient(seeLoopsClient::low_level).
use loops_so::{ConfigureOptions, TransactionalOptions};
// Or set the LOOPS_API_KEY environment variable.
loops_so::configure(ConfigureOptions::new().api_key("your_api_key"));
let client = loops_so::get_client()?;
let variables = client.get_transactional_variables("clfq6dinn000yl70fgwwyp82l").await?;
client
.send_transactional_email(
"clfq6dinn000yl70fgwwyp82l",
"user@example.com",
TransactionalOptions::new()
.data_variable("firstName", "Jane")
.data_variable("inviteLink", "https://myapp.com/invite/abc123"),
)
.await?;Re-exports§
pub use responses::Contact;pub use responses::TransactionalEmail;pub use responses::TransactionalEmailPagination;pub use responses::TransactionalEmailsResponse;
Modules§
- generated
- Code generated from the Loops OpenAPI spec. Never edit by hand:
just regeneratereplaces the whole directory. - responses
- Hand-written response models for endpoints whose generated model is too loose to be useful.
- routes
- The named table of every Loops endpoint
LoopsClientcalls. - testing
- A mock Loops API for testing code that uses this crate.
Structs§
- Configure
Options - The settings to change in a
configurecall. Unset fields keep their current value. - Contact
Fields - Contact fields for
create_contactandupsert_contact. Unset fields are left out of the request. - Delete
Node Options - Optional parts of
delete_workflow_node. - Email
Message Update - Changes for
update_email_message. Unset fields are left unchanged. - Event
Options - Optional parts of
send_event. - Loops
Client - High-level client for the Loops API.
- Loops
Client Builder - Builds a
LoopsClient. Every setting left unset falls back to the process-wide defaults fromconfigure. - Loops
Config - The process-wide defaults
LoopsClientfalls back to. - Page
- Pagination for the list endpoints.
- Preview
Options - Values used to render
preview_email_message. - Transactional
Options - Optional parts of
send_transactional_email.
Enums§
- Contact
Id - How a contact is identified: by email, by user ID, or both.
- Email
Format - How an email message renders.
- Loops
Error - Every way a
LoopsClientcall can fail. - Node
Placement - Where
create_workflow_nodeinserts the new node.
Constants§
- API_
KEY_ ENV_ VAR - The environment variable read when no API key was configured.
- DEFAULT_
BASE_ URL - The base URL of the Loops API. The
/v1version segment is part of each endpoint path, not of the base URL. - LOOPS_
API_ VERSION - The
info.versionof the shipped spec.just generaterewrites it together with the spec and the generated code. - OPENAPI_
SPEC - The shipped OpenAPI spec, as YAML.
Functions§
- configure
- Change the process-wide defaults. Only the fields set on
optionschange. - get_
client - The process-wide client, created from the
configuredefaults on first use. - get_
config - The current process-wide defaults, with the API key falling back to the
LOOPS_API_KEYenvironment variable. - openapi_
spec_ path - Filesystem path of the shipped OpenAPI spec inside the crate sources.
- reset_
client - Drop the process-wide client so the next
get_clientbuilds a fresh one. Call it afterconfigure, or in test teardown.
Type Aliases§
- Result
- Result alias used throughout the SDK.