Skip to main content

BappApiClient

Struct BappApiClient 

Source
pub struct BappApiClient {
    pub host: String,
    pub tenant: Option<String>,
    pub app: String,
    /* private fields */
}
Expand description

BAPP Auto API client.

Fields§

§host: String§tenant: Option<String>§app: String

Implementations§

Source§

impl BappApiClient

Source

pub fn new() -> Self

Create a new client with the default host.

Source

pub fn with_host(self, host: &str) -> Self

Create a new client pointing at host.

Source

pub fn with_bearer(self, token: &str) -> Self

Set Bearer token authentication.

Source

pub fn with_token(self, token: &str) -> Self

Set Token-based authentication.

Source

pub fn with_tenant(self, tenant: &str) -> Self

Set the default tenant ID.

Source

pub fn with_app(self, app: &str) -> Self

Set the default app slug.

Source

pub fn with_user_agent(self, ua: &str) -> Self

Set a custom User-Agent header.

Source

pub fn with_timeout(self, timeout: Duration) -> Self

Set the HTTP client timeout.

Source

pub fn with_max_retries(self, n: usize) -> Self

Set the maximum number of retries on transient errors.

Source

pub async fn request_multipart( &self, method: Method, path: &str, fields: &[(&str, &str)], files: &[(&str, &str)], ) -> Result<Option<Value>, Error>

Send a multipart/form-data request. Use for file uploads. fields are plain text fields, files are (field_name, file_path) pairs.

Source

pub async fn me(&self) -> Result<Option<Value>, Error>

Get current user profile.

Source

pub async fn get_app(&self, app_slug: &str) -> Result<Option<Value>, Error>

Get app configuration by slug.

Source

pub async fn list_introspect( &self, content_type: &str, ) -> Result<Option<Value>, Error>

Get entity list introspect for a content type.

Source

pub async fn detail_introspect( &self, content_type: &str, pk: Option<&str>, ) -> Result<Option<Value>, Error>

Get entity detail introspect for a content type.

Source

pub async fn list( &self, content_type: &str, filters: Option<&[(&str, &str)]>, ) -> Result<PagedList, Box<dyn Error>>

List entities of a content type. Returns a PagedList.

Source

pub async fn get( &self, content_type: &str, id: &str, ) -> Result<Option<Value>, Error>

Get a single entity by content type and ID.

Source

pub async fn create( &self, content_type: &str, data: Option<&Value>, ) -> Result<Option<Value>, Error>

Create a new entity.

Source

pub async fn update( &self, content_type: &str, id: &str, data: Option<&Value>, ) -> Result<Option<Value>, Error>

Full update of an entity.

Source

pub async fn patch( &self, content_type: &str, id: &str, data: Option<&Value>, ) -> Result<Option<Value>, Error>

Partial update of an entity.

Source

pub async fn delete( &self, content_type: &str, id: &str, ) -> Result<Option<Value>, Error>

Delete an entity.

Source

pub fn get_document_views(record: &Value) -> Vec<Value>

Extract available document views from a record.

Works with both public_view (new) and view_token (legacy) formats. Returns a Vec of JSON objects with keys: label, token, type, variations, and default_variation.

Source

pub fn get_document_url( &self, record: &Value, output: &str, label: Option<&str>, variation: Option<&str>, download: bool, ) -> Option<String>

Build a document render/download URL from a record.

Works with both public_view and view_token formats. Prefers public_view when both are present on a record.

  • output: "html", "pdf", "jpg", or "context".
  • label: select a specific view by label (None = first available).
  • variation: variation code for public_view entries (e.g. "v4").
Source

pub async fn get_document_content( &self, record: &Value, output: &str, label: Option<&str>, variation: Option<&str>, download: bool, ) -> Result<Option<Vec<u8>>, Box<dyn Error>>

Fetch document content (PDF, HTML, JPG, etc.) as bytes.

Builds the URL via [get_document_url] and performs a plain GET request. Returns Ok(None) when the record has no view tokens.

Source

pub async fn download_document( &self, record: &Value, dest: &str, output: &str, label: Option<&str>, variation: Option<&str>, download: bool, ) -> Result<bool, Box<dyn Error>>

Stream document content directly to a file.

Like [get_document_content] but streams to dest without buffering the entire document in memory.

Source

pub async fn list_tasks(&self) -> Result<Option<Value>, Error>

List all available task codes.

Source

pub async fn detail_task(&self, code: &str) -> Result<Option<Value>, Error>

Get task configuration by code.

Source

pub async fn run_task( &self, code: &str, payload: Option<&Value>, ) -> Result<Option<Value>, Error>

Run a task. Uses GET when no payload, POST otherwise.

Source

pub async fn run_task_async( &self, code: &str, payload: Option<&Value>, poll_interval: Option<Duration>, timeout: Option<Duration>, ) -> Result<Value, Box<dyn Error>>

Run a long-running task and poll until finished. Returns the final task data which includes “file” when the task produces a download.

Trait Implementations§

Source§

impl Debug for BappApiClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BappApiClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more