use serde_json::Value;
use crate::api::OperationRequest;
use crate::api::operations::{HttpMethod, OperationSpec};
use crate::client::JorttClient;
use crate::error::JorttError;
#[derive(Clone)]
pub struct RawClient {
client: JorttClient,
}
impl RawClient {
pub fn new(client: JorttClient) -> Self {
Self { client }
}
pub async fn execute_spec(
&self,
spec: OperationSpec,
request: OperationRequest,
) -> Result<Value, JorttError> {
self.client.execute_spec(spec, request).await
}
pub async fn execute(
&self,
method: HttpMethod,
path_template: &str,
request: OperationRequest,
) -> Result<Value, JorttError> {
self.client
.execute(
method,
path_template,
request.path_params,
request.query_params,
request.body,
request.accept,
)
.await
}
}
impl JorttClient {
pub fn raw(&self) -> RawClient {
RawClient::new(self.clone())
}
}