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: StringImplementations§
Source§impl BappApiClient
impl BappApiClient
Sourcepub fn with_bearer(self, token: &str) -> Self
pub fn with_bearer(self, token: &str) -> Self
Set Bearer token authentication.
Sourcepub fn with_token(self, token: &str) -> Self
pub fn with_token(self, token: &str) -> Self
Set Token-based authentication.
Sourcepub fn with_tenant(self, tenant: &str) -> Self
pub fn with_tenant(self, tenant: &str) -> Self
Set the default tenant ID.
Sourcepub fn with_user_agent(self, ua: &str) -> Self
pub fn with_user_agent(self, ua: &str) -> Self
Set a custom User-Agent header.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set the HTTP client timeout.
Sourcepub fn with_max_retries(self, n: usize) -> Self
pub fn with_max_retries(self, n: usize) -> Self
Set the maximum number of retries on transient errors.
Sourcepub async fn request_multipart(
&self,
method: Method,
path: &str,
fields: &[(&str, &str)],
files: &[(&str, &str)],
) -> Result<Option<Value>, Error>
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.
Sourcepub async fn get_app(&self, app_slug: &str) -> Result<Option<Value>, Error>
pub async fn get_app(&self, app_slug: &str) -> Result<Option<Value>, Error>
Get app configuration by slug.
Sourcepub async fn list_introspect(
&self,
content_type: &str,
) -> Result<Option<Value>, Error>
pub async fn list_introspect( &self, content_type: &str, ) -> Result<Option<Value>, Error>
Get entity list introspect for a content type.
Sourcepub async fn detail_introspect(
&self,
content_type: &str,
pk: Option<&str>,
) -> Result<Option<Value>, Error>
pub async fn detail_introspect( &self, content_type: &str, pk: Option<&str>, ) -> Result<Option<Value>, Error>
Get entity detail introspect for a content type.
Sourcepub async fn list(
&self,
content_type: &str,
filters: Option<&[(&str, &str)]>,
) -> Result<PagedList, Box<dyn Error>>
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.
Sourcepub async fn get(
&self,
content_type: &str,
id: &str,
) -> Result<Option<Value>, Error>
pub async fn get( &self, content_type: &str, id: &str, ) -> Result<Option<Value>, Error>
Get a single entity by content type and ID.
Sourcepub async fn create(
&self,
content_type: &str,
data: Option<&Value>,
) -> Result<Option<Value>, Error>
pub async fn create( &self, content_type: &str, data: Option<&Value>, ) -> Result<Option<Value>, Error>
Create a new entity.
Sourcepub async fn update(
&self,
content_type: &str,
id: &str,
data: Option<&Value>,
) -> Result<Option<Value>, Error>
pub async fn update( &self, content_type: &str, id: &str, data: Option<&Value>, ) -> Result<Option<Value>, Error>
Full update of an entity.
Sourcepub async fn patch(
&self,
content_type: &str,
id: &str,
data: Option<&Value>,
) -> Result<Option<Value>, Error>
pub async fn patch( &self, content_type: &str, id: &str, data: Option<&Value>, ) -> Result<Option<Value>, Error>
Partial update of an entity.
Sourcepub async fn delete(
&self,
content_type: &str,
id: &str,
) -> Result<Option<Value>, Error>
pub async fn delete( &self, content_type: &str, id: &str, ) -> Result<Option<Value>, Error>
Delete an entity.
Sourcepub fn get_document_views(record: &Value) -> Vec<Value>
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.
Sourcepub fn get_document_url(
&self,
record: &Value,
output: &str,
label: Option<&str>,
variation: Option<&str>,
download: bool,
) -> Option<String>
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 forpublic_viewentries (e.g."v4").
Sourcepub 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>>
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.
Sourcepub async fn download_document(
&self,
record: &Value,
dest: &str,
output: &str,
label: Option<&str>,
variation: Option<&str>,
download: bool,
) -> Result<bool, Box<dyn Error>>
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.
Sourcepub async fn detail_task(&self, code: &str) -> Result<Option<Value>, Error>
pub async fn detail_task(&self, code: &str) -> Result<Option<Value>, Error>
Get task configuration by code.
Sourcepub async fn run_task(
&self,
code: &str,
payload: Option<&Value>,
) -> Result<Option<Value>, Error>
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.
Sourcepub async fn run_task_async(
&self,
code: &str,
payload: Option<&Value>,
poll_interval: Option<Duration>,
timeout: Option<Duration>,
) -> Result<Value, Box<dyn Error>>
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.