pub struct ApiClient { /* private fields */ }Implementations§
Source§impl ApiClient
impl ApiClient
pub fn new(base_url: impl AsRef<str>) -> Result<Self>
pub fn with_basic_auth( self, username: impl Into<String>, token: impl Into<String>, ) -> Self
pub fn with_bearer_token(self, token: impl Into<String>) -> Self
pub fn with_genie_key(self, api_key: impl Into<String>) -> Self
pub fn with_retry_config(self, config: RetryConfig) -> Self
pub fn base_url(&self) -> &str
Sourcepub fn http_client(&self) -> &Client
pub fn http_client(&self) -> &Client
Returns a reference to the underlying HTTP client for raw requests (e.g., multipart uploads).
pub async fn get<T: DeserializeOwned>(&self, path: &str) -> Result<T>
pub async fn post<T: DeserializeOwned, B: Serialize + ?Sized>( &self, path: &str, body: &B, ) -> Result<T>
pub async fn put<T: DeserializeOwned, B: Serialize + ?Sized>( &self, path: &str, body: &B, ) -> Result<T>
pub async fn delete<T: DeserializeOwned>(&self, path: &str) -> Result<T>
pub async fn delete_with_body<T: DeserializeOwned, B: Serialize + ?Sized>( &self, path: &str, body: &B, ) -> Result<T>
Sourcepub async fn delete_no_content(&self, path: &str) -> Result<()>
pub async fn delete_no_content(&self, path: &str) -> Result<()>
DELETE that expects 204 No Content (no response body).
Sourcepub async fn get_text(&self, path: &str) -> Result<String>
pub async fn get_text(&self, path: &str) -> Result<String>
Get plain text content from an endpoint. Sets Accept: text/plain; charset=utf-8 header. Includes retry logic and rate limiting.
Sourcepub fn resolve_url(&self, path: &str) -> Result<Url>
pub fn resolve_url(&self, path: &str) -> Result<Url>
Resolve path against the base URL, applying the same-origin (SSRF)
check used by every request. Public so callers can validate or preview a
path without sending anything.
Sourcepub async fn request_raw(&self, req: RawRequest<'_>) -> Result<RawResponse>
pub async fn request_raw(&self, req: RawRequest<'_>) -> Result<RawResponse>
Send an arbitrary request and return the status, headers and body bytes.
Unlike ApiClient::request, a non-2xx status is returned as
Ok(RawResponse) rather than mapped to an ApiError, so callers can
surface the API’s own error body. Only transport failures and URL
validation produce Err. Same-origin validation, auth and rate limiting
still apply.
Retries on 429/5xx are limited to idempotent methods. request retries
POSTs, which can double-create; a raw passthrough must not inherit that.
Sourcepub async fn get_bytes(&self, path: &str) -> Result<Vec<u8>>
pub async fn get_bytes(&self, path: &str) -> Result<Vec<u8>>
Get binary content from an endpoint. Includes retry logic and rate limiting.