pub struct HttpClient { /* private fields */ }Implementations§
Source§impl HttpClient
impl HttpClient
pub fn new(base_url: String, api_key: String) -> Self
Sourcepub fn with_platform(self, platform: Option<String>) -> Self
pub fn with_platform(self, platform: Option<String>) -> Self
Builder-style setter for the runtime platform header. A blank/whitespace value is treated as absent so the header is never sent empty.
Sourcepub fn with_environment(self, environment: Option<String>) -> Self
pub fn with_environment(self, environment: Option<String>) -> Self
Builder-style setter for the Remote Config environment header. A
blank/whitespace value is treated as absent so the header is never sent
empty (the backend then defaults to prod).
pub fn with_max_attempts(self, n: u32) -> Self
pub fn with_min_backoff(self, d: Duration) -> Self
pub fn with_request_timeout(self, d: Duration) -> Self
Sourcepub fn with_logger(self, logger: Arc<Logger>) -> Self
pub fn with_logger(self, logger: Arc<Logger>) -> Self
Attach a structured logger. When set, each logical request emits a
Debug record (path, method, status, attempt, correlation_id) and an
Error record on terminal failure. Authorization and the api key
are never included in any emitted record.
pub fn get_json<T: DeserializeOwned>( &self, req: HttpRequest<'_>, ) -> RovenueResult<HttpResponse<T>>
Sourcepub fn post_sessions(
&self,
subscriber_id: &str,
events: &[Value],
) -> RovenueResult<()>
pub fn post_sessions( &self, subscriber_id: &str, events: &[Value], ) -> RovenueResult<()>
POST a batch of session telemetry events to /v1/sdk/sessions.
Best-effort: returns Ok(()) for any 2xx, and discards the response body.
Sourcepub fn post_attributes(
&self,
subscriber_id: &str,
attributes: &Map<String, Value>,
) -> RovenueResult<()>
pub fn post_attributes( &self, subscriber_id: &str, attributes: &Map<String, Value>, ) -> RovenueResult<()>
POST a batch of attribute mutations to /v1/me/attributes. The
subscriber is resolved server-side from the user-scope header.
attributes maps key -> Some(value) to set, or None to delete.
pub fn post_json<B: Serialize, T: DeserializeOwned>( &self, req: HttpPostRequest<'_>, body: &B, ) -> RovenueResult<HttpResponse<T>>
Sourcepub fn post_json_status<B: Serialize>(
&self,
req: HttpPostRequest<'_>,
body: &B,
) -> RovenueResult<(u16, Option<Value>)>
pub fn post_json_status<B: Serialize>( &self, req: HttpPostRequest<'_>, body: &B, ) -> RovenueResult<(u16, Option<Value>)>
POST that surfaces the raw HTTP status instead of collapsing 4xx into an
error. Returns Ok((status, body)) for any 2xx or 4xx response (body is
None when empty or non-JSON); retries 5xx/network/timeout and returns
Err only when those are exhausted. Used by callers that map specific
4xx codes themselves (e.g. funnel claim 404/410/409).