Skip to main content

Crate jortt

Crate jortt 

Source
Expand description

§jortt-rs

jortt is an async-first Rust SDK for the Jortt API.

§Highlights

  • Typed operation enums for every operation in the pinned Jortt OpenAPI snapshot (126 operations)
  • Generated method surface for every operation (client.methods().<tag>().<operation>())
  • High-level JorttClient with domain handles (customers, invoices, projects, reports, …)
  • One canonical request builder: RequestBuilder
  • One canonical error builder: ErrorBuilder
  • Hybrid auth design:
    • user-supplied AccessTokenSource for request-time bearer tokens
    • explicit OAuth helper flows for auth-code, refresh-token, and client-credentials
  • RawClient escape hatch for ad-hoc endpoints while keeping typed API stable
  • Structured Jortt API error parsing (error.code, error.key, error.message, error.details)

§Install

[dependencies]
jortt = "0.1.0"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

§Quick Start (Bearer Token Source)

use std::sync::Arc;

use jortt::{JorttClient, ListCustomersQuery, StaticAccessToken};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let token_source = Arc::new(StaticAccessToken::new("YOUR_ACCESS_TOKEN"));

    let client = JorttClient::builder()
        .with_token_source(token_source)
        .build()?;

    let customers = client
        .list_customers(&ListCustomersQuery {
            query: Some("janssen".to_string()),
            page: None,
        })
        .await?;

    println!("customers found: {}", customers.data.len());
    Ok(())
}

§Full Coverage Method Surface

use std::sync::Arc;

use jortt::{JorttClient, RequestBuilder, StaticAccessToken};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = JorttClient::builder()
        .with_token_source(Arc::new(StaticAccessToken::new("YOUR_ACCESS_TOKEN")))
        .build()?;

    let customers = client
        .methods()
        .customers()
        .get_customers(RequestBuilder::new().query_param("query", "acme").build())
        .await?;

    println!("{customers}");
    Ok(())
}

§Quick Start (Hybrid OAuth Helpers)

use jortt::{OAuthClient, OAuthConfig, Scope};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let oauth = OAuthClient::new(OAuthConfig::default())?;

    let tokens = oauth
        .exchange_client_credentials(
            "CLIENT_ID",
            "CLIENT_SECRET",
            &[Scope::CustomersRead, Scope::InvoicesRead],
        )
        .await?;

    println!("access token length: {}", tokens.access_token.len());
    Ok(())
}

§Raw Escape Hatch

use std::sync::Arc;

use jortt::{HttpMethod, JorttClient, OperationRequest, StaticAccessToken};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = JorttClient::builder()
        .with_token_source(Arc::new(StaticAccessToken::new("YOUR_ACCESS_TOKEN")))
        .build()?;

    let response = client
        .raw()
        .execute(
            HttpMethod::Get,
            "/customers/{customer_id}",
            OperationRequest::new().with_path_param("customer_id", "408d4652-b07a-4195-817e-0390bb0c9428"),
        )
        .await?;

    println!("response: {response}");
    Ok(())
}

§Documentation Index

§Stability

This crate is currently 0.x and follows a pre-1.0 compatibility policy (see Versioning Policy).

§Jortt Rust SDK

Async-first Rust SDK for the Jortt API. The crate provides:

  • typed operation modules for all OpenAPI tags,
  • a raw operation escape hatch,
  • hybrid OAuth helpers, and
  • robust API error parsing.

Re-exports§

pub use api::endpoints::ApiMethods;
pub use api::DomainApi;
pub use api::OperationRequest;
pub use api::PathParam;
pub use api::QueryParam;
pub use api::RequestBuilder;
pub use auth::AccessTokenSource;
pub use auth::OAuthClient;
pub use auth::OAuthConfig;
pub use auth::Scope;
pub use auth::StaticAccessToken;
pub use auth::TokenSet;
pub use client::JorttClient;
pub use client::JorttClientBuilder;
pub use error::ApiError;
pub use error::ApiErrorDetail;
pub use error::ErrorBuilder;
pub use error::JorttError;
pub use models::CreateInvoiceRequest;
pub use models::Customer;
pub use models::Invoice;
pub use models::InvoiceDownload;
pub use models::InvoiceLineItemRequest;
pub use models::LedgerAccount;
pub use models::ListCustomersQuery;
pub use models::ListCustomersResponse;
pub use models::ListInvoicesQuery;
pub use models::ListInvoicesResponse;
pub use models::ListLedgerAccountsResponse;
pub use models::Money;
pub use models::UpsertCustomerRequest;
pub use api::operations::*;

Modules§

api
Typed operation APIs and request builders. Typed operation execution API.
auth
Authentication abstractions and OAuth helpers.
client
High-level SDK client facade. High-level Jortt API client.
error
Structured SDK and API errors.
ids
Strongly typed resource identifiers.
models
Request/response domain models. Model namespace.
raw
Raw escape hatch for ad-hoc endpoints. Raw operation escape hatch.