pub struct BlockingApiClient { /* private fields */ }Expand description
Generic blocking JSON REST client. Generic blocking JSON REST client.
This is the synchronous counterpart of crate::ApiClient.
Implementations§
Source§impl BlockingApiClient
impl BlockingApiClient
Sourcepub fn new(base_url: impl AsRef<str>) -> Result<Self, ClientError>
pub fn new(base_url: impl AsRef<str>) -> Result<Self, ClientError>
Creates a new client with the given base URL.
The URL is normalized to include a trailing slash, so relative endpoint paths join correctly.
Returns a new client with a raw access token attached to all requests.
This sets Authorization: <token> (without Bearer prefix).
Sourcepub fn get_json(&self, path: &str) -> Result<Value, ClientError>
pub fn get_json(&self, path: &str) -> Result<Value, ClientError>
Sends a GET request and parses the response as JSON.
Sourcepub fn get_json_with_query(
&self,
path: &str,
query: &[(&str, &str)],
) -> Result<Value, ClientError>
pub fn get_json_with_query( &self, path: &str, query: &[(&str, &str)], ) -> Result<Value, ClientError>
Sends a GET request with query parameters and parses the response as JSON.
Sourcepub fn request_json(
&self,
method: Method,
path: &str,
body: Option<Value>,
) -> Result<Value, ClientError>
pub fn request_json( &self, method: Method, path: &str, body: Option<Value>, ) -> Result<Value, ClientError>
Sends a request and parses the response as JSON.
Use Self::request_json_with_query when query parameters are needed.
Sourcepub fn request_json_with_query(
&self,
method: Method,
path: &str,
query: &[(&str, &str)],
body: Option<Value>,
) -> Result<Value, ClientError>
pub fn request_json_with_query( &self, method: Method, path: &str, query: &[(&str, &str)], body: Option<Value>, ) -> Result<Value, ClientError>
Sends a request with query parameters and parses the response as JSON.
Returns Value::Null for successful responses with an empty body.