Function send_request

Source
pub async fn send_request<T: DeserializeOwned + Send + 'static>(
    configuration: &ConfigurationRestApi,
    endpoint: &str,
    method: Method,
    params: BTreeMap<String, Value>,
    time_unit: Option<TimeUnit>,
    is_signed: bool,
) -> Result<RestApiResponse<T>>
Expand description

Sends an HTTP request to a REST API endpoint with optional authentication and configuration.

§Parameters

  • configuration: REST API configuration containing client, base path, and authentication details
  • endpoint: The specific API endpoint path to send the request to
  • method: HTTP method for the request (GET, POST, etc.)
  • params: Parameters to be sent with the request, as a key-value map
  • time_unit: Optional time unit for the request header
  • is_signed: Optional flag to indicate whether the request requires authentication

§Returns

A RestApiResponse containing the deserialized response data, or an error if the request fails

§Panics

This function will panic if any of the following .unwrap() calls fail:

  • Parsing the literal "application/json" into a header value (should never fail)
  • Parsing configuration.user_agent or configuration.api_key into header values
  • Parsing the literal "gzip, deflate, br" into a header value when compression is enabled

§Errors

Returns an anyhow::Result which can contain various connector-related errors during request processing